diff --git a/ClassicalSharp/Entities/Model/BlockModel.cs b/ClassicalSharp/Entities/Model/BlockModel.cs
index 8390f0d4b..a9ba534c6 100644
--- a/ClassicalSharp/Entities/Model/BlockModel.cs
+++ b/ClassicalSharp/Entities/Model/BlockModel.cs
@@ -75,7 +75,7 @@ namespace ClassicalSharp.Model {
return base.RenderDistance(p);
}
- int lastTexId = -1;
+ int lastTexId = -1, col;
public override void DrawModel(Entity p) {
// TODO: using 'is' is ugly, but means we can avoid creating
// a string every single time held block changes.
diff --git a/ClassicalSharp/Entities/Model/ChickenModel.cs b/ClassicalSharp/Entities/Model/ChickenModel.cs
index 502c634b5..4e2edb449 100644
--- a/ClassicalSharp/Entities/Model/ChickenModel.cs
+++ b/ClassicalSharp/Entities/Model/ChickenModel.cs
@@ -65,6 +65,7 @@ namespace ClassicalSharp.Model {
DrawRotate(0, 0, -Math.Abs(p.anim.armXRot), LeftWing, false);
DrawRotate(0, 0, Math.Abs(p.anim.armXRot), RightWing, false);
+ int col = cols[0];
for (int i = 0; i < cols.Length; i++) {
cols[i] = FastColour.ScalePacked(col, 0.7f);
}
diff --git a/ClassicalSharp/Entities/Model/HumanModels.cs b/ClassicalSharp/Entities/Model/HumanModels.cs
index 692698b40..85e21f865 100644
--- a/ClassicalSharp/Entities/Model/HumanModels.cs
+++ b/ClassicalSharp/Entities/Model/HumanModels.cs
@@ -71,7 +71,9 @@ namespace ClassicalSharp.Model {
public override void DrawModel(Entity p) {
p.anim.legXRot = 1.5f;
- game.ModelCache.Models[0].Instance.DrawModel(p);
+ IModel model = game.ModelCache.Models[0].Instance;
+ model.SetupState(p);
+ model.DrawModel(p);
}
}
diff --git a/ClassicalSharp/Entities/Model/IModel.cs b/ClassicalSharp/Entities/Model/IModel.cs
index 9e9926bde..d144160d0 100644
--- a/ClassicalSharp/Entities/Model/IModel.cs
+++ b/ClassicalSharp/Entities/Model/IModel.cs
@@ -67,7 +67,6 @@ namespace ClassicalSharp.Model {
/// assuming that the model is not rotated at all.
public abstract AABB PickingBounds { get; }
- protected Vector3 pos;
protected float cosHead, sinHead;
protected float uScale, vScale;
@@ -103,22 +102,9 @@ namespace ClassicalSharp.Model {
/// Sets up the state for, then renders an entity model,
/// based on the given entity's position and orientation.
public void Render(Entity p) {
- index = 0;
- pos = p.Position;
+ Vector3 pos = p.Position;
if (Bobbing) pos.Y += p.anim.bobbingModel;
-
- Vector3I P = Vector3I.Floor(p.EyePosition);
- col = game.World.IsValidPos(P) ? game.Lighting.LightCol(P.X, P.Y, P.Z) : game.Lighting.Outside;
- uScale = 1 / 64f; vScale = 1 / 32f;
-
- cols[0] = col;
- cols[1] = FastColour.ScalePacked(col, FastColour.ShadeYBottom);
- cols[2] = FastColour.ScalePacked(col, FastColour.ShadeZ); cols[3] = cols[2];
- cols[4] = FastColour.ScalePacked(col, FastColour.ShadeX); cols[5] = cols[4];
-
- float yawDelta = p.HeadY - p.RotY;
- cosHead = (float)Math.Cos(yawDelta * Utils.Deg2Rad);
- sinHead = (float)Math.Sin(yawDelta * Utils.Deg2Rad);
+ SetupState(p);
game.Graphics.SetBatchFormat(VertexFormat.P3fT2fC4b);
game.Graphics.PushMatrix();
@@ -129,6 +115,22 @@ namespace ClassicalSharp.Model {
game.Graphics.PopMatrix();
}
+ public void SetupState(Entity p) {
+ index = 0;
+ Vector3I P = Vector3I.Floor(p.EyePosition);
+ int col = game.World.IsValidPos(P) ? game.Lighting.LightCol(P.X, P.Y, P.Z) : game.Lighting.Outside;
+ uScale = 1 / 64f; vScale = 1 / 32f;
+
+ cols[0] = col;
+ cols[1] = FastColour.ScalePacked(col, FastColour.ShadeYBottom);
+ cols[2] = FastColour.ScalePacked(col, FastColour.ShadeZ); cols[3] = cols[2];
+ cols[4] = FastColour.ScalePacked(col, FastColour.ShadeX); cols[5] = cols[4];
+
+ float yawDelta = p.HeadY - p.RotY;
+ cosHead = (float)Math.Cos(yawDelta * Utils.Deg2Rad);
+ sinHead = (float)Math.Sin(yawDelta * Utils.Deg2Rad);
+ }
+
/// Performs the actual rendering of an entity model.
public abstract void DrawModel(Entity p);
@@ -148,7 +150,6 @@ namespace ClassicalSharp.Model {
return p.TransformMatrix(p.ModelScale, pos);
}
- protected int col;
protected int[] cols = new int[6];
protected internal ModelVertex[] vertices;
protected internal int index, texIndex;