From 272125c769a63d67a6fa01ceb9b060328f17218f Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 25 Jan 2015 14:41:11 +1100 Subject: [PATCH] Fix corner case with slabs. --- Physics/Entity.Physics.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Physics/Entity.Physics.cs b/Physics/Entity.Physics.cs index 9b42b7bad..60f2a6754 100644 --- a/Physics/Entity.Physics.cs +++ b/Physics/Entity.Physics.cs @@ -18,7 +18,7 @@ namespace ClassicalSharp { bool GetBoundingBox( byte block, int x, int y, int z, out BoundingBox box ) { box = new BoundingBox( Vector3.Zero, Vector3.Zero ); - if( block == 0 || info.IsSprite( block ) || info.IsLiquid( block ) || block == (byte)Block.Snow ) return false; + if( CanWalkThrough( block ) ) return false; Vector3 min = new Vector3( x, y, z ); Vector3 max = new Vector3( x + 1, y + info.BlockHeight( block ), z + 1 ); box = new BoundingBox( min, max ); @@ -37,13 +37,17 @@ namespace ClassicalSharp { } } + bool CanWalkThrough( byte block ) { + return block == 0 || info.IsSprite( block ) || info.IsLiquid( block ) || block == (byte)Block.Snow; + } + bool IsFreeYForStep( BoundingBox blockBB ) { // NOTE: if non whole blocks are added, use a proper AABB test. int x = (int)Utils.Floor( blockBB.Min.X ); int y = (int)Utils.Floor( blockBB.Min.Y ); int z = (int)Utils.Floor( blockBB.Min.Z ); - return !info.IsOpaque( GetPhysicsBlockId( x, y + 1, z ) ) && - !info.IsOpaque( GetPhysicsBlockId( x, y + 2, z ) ); + return CanWalkThrough( GetPhysicsBlockId( x, y + 1, z ) ) && + CanWalkThrough( GetPhysicsBlockId( x, y + 2, z ) ); } // TODO: test for corner cases, and refactor this.