From 6f595f81ec2a40e57d29fda71075ec6a356bb719 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 20 Feb 2016 00:00:39 +1100 Subject: [PATCH] Fix shadows on map water sides (Thanks Lemon), fix liquids being offset incorrectly. --- ClassicalSharp/Entities/EntityList.cs | 4 ++-- ClassicalSharp/Entities/Player.Shadows.cs | 7 +++++-- ClassicalSharp/Game/Game.cs | 2 +- ClassicalSharp/Map/ChunkMeshBuilder.cs | 2 +- ClassicalSharp/Rendering/MapBordersRenderer.cs | 10 ++++------ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ClassicalSharp/Entities/EntityList.cs b/ClassicalSharp/Entities/EntityList.cs index 864f71eca..364672e47 100644 --- a/ClassicalSharp/Entities/EntityList.cs +++ b/ClassicalSharp/Entities/EntityList.cs @@ -143,14 +143,14 @@ namespace ClassicalSharp { public void DrawShadows() { if( ShadowMode == EntityShadow.None ) return; Player.boundShadowTex = false; - game.Graphics.AlphaTest = false; game.Graphics.AlphaArgBlend = true; + game.Graphics.AlphaTestFunc( CompareFunc.Greater, 0.05f ); Players[255].DrawShadow( ShadowMode ); if( ShadowMode == EntityShadow.CircleAll ) DrawOtherShadows(); - game.Graphics.AlphaTest = true; game.Graphics.AlphaArgBlend = false; + game.Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f ); } void DrawOtherShadows() { diff --git a/ClassicalSharp/Entities/Player.Shadows.cs b/ClassicalSharp/Entities/Player.Shadows.cs index 2480948bb..e7ffe02f8 100644 --- a/ClassicalSharp/Entities/Player.Shadows.cs +++ b/ClassicalSharp/Entities/Player.Shadows.cs @@ -98,8 +98,11 @@ namespace ClassicalSharp { } byte GetShadowBlock( int x, int y, int z ) { - if( x < 0 || z < 0 || x >= game.Map.Width || z >= game.Map.Length ) - return y == (game.Map.SidesHeight - 1) ? (byte)game.Map.SidesBlock : (byte)0; + if( x < 0 || z < 0 || x >= game.Map.Width || z >= game.Map.Length ) { + if (y == game.Map.EdgeHeight - 1) return (byte)game.Map.EdgeBlock; + if (y == game.Map.SidesHeight - 1) return (byte)game.Map.SidesBlock; + return (byte)Block.Air; + } return game.Map.GetBlock( x, y, z ); } diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 5f71c0ede..f00020298 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -357,7 +357,7 @@ namespace ClassicalSharp { public void SetNewScreen( Screen screen ) { SetNewScreen( screen, true ); } public void SetNewScreen( Screen screen, bool disposeOld ) { - // don't switch to the new screen immediately if the user + // Don't switch to the new screen immediately if the user // is currently looking at a warning dialog. if( activeScreen is WarningScreen ) { WarningScreen warning = (WarningScreen)activeScreen; diff --git a/ClassicalSharp/Map/ChunkMeshBuilder.cs b/ClassicalSharp/Map/ChunkMeshBuilder.cs index b0b8fcbb5..2cefe4fb5 100644 --- a/ClassicalSharp/Map/ChunkMeshBuilder.cs +++ b/ClassicalSharp/Map/ChunkMeshBuilder.cs @@ -144,7 +144,7 @@ namespace ClassicalSharp { x2 = x + max.X; y2 = y + max.Y; z2 = z + max.Z; if( isTranslucent && info.CollideType[tile] != BlockCollideType.Solid ) { x1 -= 0.1f/16; x2 -= 0.1f/16f; z1 -= 0.1f/16f; z2 -= 0.1f/16f; - y1 += 0.1f/16; y2 += 0.1f/16f; + y1 -= 0.1f/16; y2 -= 0.1f/16f; } this.minBB = min; this.maxBB = max; minBB.Y = 1 - minBB.Y; maxBB.Y = 1 - maxBB.Y; diff --git a/ClassicalSharp/Rendering/MapBordersRenderer.cs b/ClassicalSharp/Rendering/MapBordersRenderer.cs index c63c05524..a3571ac1f 100644 --- a/ClassicalSharp/Rendering/MapBordersRenderer.cs +++ b/ClassicalSharp/Rendering/MapBordersRenderer.cs @@ -55,8 +55,7 @@ namespace ClassicalSharp { bool underWater = camPos.Y < game.Map.EdgeHeight; graphics.AlphaBlending = true; game.Players.DrawShadows(); - if( underWater ) - game.WeatherRenderer.Render( deltaTime ); + if( underWater ) game.WeatherRenderer.Render( deltaTime ); graphics.BindTexture( edgeTexId ); graphics.BindVb( edgesVb ); @@ -66,8 +65,7 @@ namespace ClassicalSharp { if( game.Map.EdgeBlock != Block.Air && camPos.Y >= yVisible ) graphics.DrawIndexedVb_TrisT2fC4b( edgesVertices * 6 / 4, 0 ); - if( !underWater ) - game.WeatherRenderer.Render( deltaTime ); + if( !underWater ) game.WeatherRenderer.Render( deltaTime ); graphics.AlphaBlending = false; graphics.Texturing = false; graphics.AlphaTest = false; @@ -175,7 +173,7 @@ namespace ClassicalSharp { fullColEdge = game.BlockInfo.FullBright[(byte)game.Map.EdgeBlock]; FastColour col = fullColEdge ? FastColour.White : map.Sunlight; foreach( Rectangle rec in rects ) { - DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, waterLevel, axisSize, col, ref vertices ); + DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, waterLevel - 0.1f/16f, axisSize, col, ref vertices ); } edgesVb = graphics.CreateVb( ptr, VertexFormat.Pos3fTex2fCol4b, edgesVertices ); } @@ -218,7 +216,7 @@ namespace ClassicalSharp { } } - void DrawY( int x1, int z1, int x2, int z2, int y, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices ) { + void DrawY( int x1, int z1, int x2, int z2, float y, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices ) { int endX = x2, endZ = z2, startZ = z1; for( ; x1 < endX; x1 += axisSize ) { x2 = x1 + axisSize;