Don't render backfaces of held block. Fixes #443.

This commit is contained in:
UnknownShadow200 2017-06-25 14:49:17 +10:00
parent 757d18c4d8
commit 9d5f378be8
3 changed files with 10 additions and 30 deletions

View file

@ -21,7 +21,6 @@ namespace ClassicalSharp.Model {
float height;
TerrainAtlas1D atlas;
Vector3 minBB, maxBB;
public bool SwitchOrder = false;
ModelCache cache;
public BlockModel(Game game) : base(game) {
@ -112,21 +111,10 @@ namespace ClassicalSharp.Model {
void DrawParts(bool sprite) {
// SwitchOrder is needed for held block, which renders without depth testing
if (sprite) {
if (SwitchOrder) {
SpriteZQuad(Side.Back, false);
SpriteXQuad(Side.Right, false);
} else {
SpriteXQuad(Side.Right, false);
SpriteZQuad(Side.Back, false);
}
if (SwitchOrder) {
SpriteXQuad(Side.Right, true);
SpriteZQuad(Side.Back, true);
} else {
SpriteZQuad(Side.Back, true);
SpriteXQuad(Side.Right, true);
}
} else {
drawer.elementsPerAtlas1D = atlas.elementsPerAtlas1D;
drawer.invVerElementSize = atlas.invElementSize;
@ -143,17 +131,10 @@ namespace ClassicalSharp.Model {
drawer.TintColour = game.BlockInfo.FogColour[block];
drawer.Bottom(1, cols[1], GetTex(Side.Bottom), cache.vertices, ref index);
if (SwitchOrder) {
drawer.Right(1, cols[5], GetTex(Side.Right), cache.vertices, ref index);
drawer.Back(1, cols[2], GetTex(Side.Back), cache.vertices, ref index);
drawer.Left(1, cols[4], GetTex(Side.Left), cache.vertices, ref index);
drawer.Front(1, cols[3], GetTex(Side.Front), cache.vertices, ref index);
} else {
drawer.Front(1, cols[3], GetTex(Side.Front), cache.vertices, ref index);
drawer.Right(1, cols[5], GetTex(Side.Right), cache.vertices, ref index);
drawer.Back(1, cols[2], GetTex(Side.Back), cache.vertices, ref index);
drawer.Left(1, cols[4], GetTex(Side.Left), cache.vertices, ref index);
}
drawer.Top(1, cols[0], GetTex(Side.Top), cache.vertices, ref index);
}
}

View file

@ -98,7 +98,6 @@ namespace ClassicalSharp.Renderers {
pos.Z = -0.325f * (float)Math.Sin(angle * 2);
angleY = -90 * (float)Math.Sin(angle * 2);
held.block.SwitchOrder = angleY <= -30;
}
void DigSecondCycle() {
@ -117,7 +116,6 @@ namespace ClassicalSharp.Renderers {
held.held.RotX = (rotX * 0.33333f) * Utils.Rad2Deg;
angleY = -90 * (float)Math.Sin(angle);
held.block.SwitchOrder = angleY <= -30;
}
void ResetAnimationState(bool updateLastType, double period) {

View file

@ -46,7 +46,6 @@ namespace ClassicalSharp.Renderers {
anim.pos = Vector3.Zero;
type = game.Inventory.Selected;
held.RotX = 0;
block.SwitchOrder = false;
if (anim.doAnim) anim.Update(delta, last);
game.Graphics.SetMatrixMode(MatrixType.Projection);
@ -59,7 +58,9 @@ namespace ClassicalSharp.Renderers {
game.Graphics.DepthTest = false;
SetPos();
game.Graphics.FaceCulling = true;
block.Render(held);
game.Graphics.FaceCulling = false;
game.Graphics.LoadMatrix(ref game.View);
game.Graphics.SetMatrixMode(MatrixType.Projection);