diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-13 18:54:52 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-09-29 22:33:13 +0200 |
commit | 7638b25cf618cfcce97c58ccdcaa8366a6bb8532 (patch) | |
tree | 76ddbf05d6f7549a0a2527a3091a05cce9833a7d | |
parent | Improved entity bounding box collision (diff) | |
download | cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.tar cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.tar.gz cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.tar.bz2 cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.tar.lz cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.tar.xz cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.tar.zst cuberite-7638b25cf618cfcce97c58ccdcaa8366a6bb8532.zip |
-rw-r--r-- | src/Entities/Entity.cpp | 14 | ||||
-rw-r--r-- | src/Entities/Pickup.cpp | 2 | ||||
-rw-r--r-- | src/Mobs/Sheep.cpp | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 00eeaf8e6..37ef925cf 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1078,7 +1078,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { switch (a_EntryFace) { - case BLOCK_FACE_NONE: ASSERT(!"Bounding box intersected a block; the direction vector was too short and didn't clear the block"); + case BLOCK_FACE_NONE: return 0; case BLOCK_FACE_XM: return (a_Intersection.GetMaxX() - a_Block.GetMinX()) / a_Direction.x; case BLOCK_FACE_XP: return (a_Intersection.GetMinX() - a_Block.GetMaxX()) / a_Direction.x; case BLOCK_FACE_YM: return (a_Intersection.GetMaxY() - a_Block.GetMinY()) / a_Direction.y; @@ -1091,14 +1091,13 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) void TestBoundingBoxCollisionWithEnvironment(const Vector3d a_TraceIntersection) { cBoundingBox Entity(a_TraceIntersection, m_Entity.GetWidth() / 2, m_Entity.GetHeight()); - Entity.Expand(0.025, 0.001, 0.025); + Entity.Expand(0.0, 0.001, 0.0); + + ASSERT(m_End != m_Start); auto Direction = m_End - m_Start; auto Backoff = std::make_pair(0.0, BLOCK_FACE_NONE); - Direction.Normalize(); - Direction *= 10; - for (const auto & Test : GetBlocksToTestAround(Entity)) { cChunk * Chunk; @@ -1139,8 +1138,8 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) virtual bool OnNextBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_EntryFace) override { + // TODO: comment // We hit a solid block, calculate the exact hit coords and abort trace: - //m_HitBlockCoords = a_BlockPos; m_HitBlockFace = a_EntryFace; double LineCoeff = 0; // Used to calculate where along the line an intersection with the bounding box occurs @@ -1167,7 +1166,8 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d & m_HitCoords; }; - while ((DtSec > 0.001) && (NextSpeed.SqrLength() > 0.0f)) + // TODO: comment + while ((DtSec > 0.001) && (NextSpeed.SqrLength() > 0.001)) { Vector3d HitCoords; eBlockFace HitBlockFace; diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 4b05c2b9b..9b793725b 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -94,7 +94,7 @@ protected: // cPickup: cPickup::cPickup(Vector3d a_Pos, const cItem & a_Item, bool IsPlayerCreated, Vector3f a_Speed, int a_LifetimeTicks, bool a_CanCombine): - Super(etPickup, a_Pos, 0.2, 0.2), + Super(etPickup, a_Pos, 0.25, 0.25), m_Timer(0), m_Item(a_Item), m_bCollected(false), diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 2a6d27969..a9916de79 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -12,7 +12,7 @@ cSheep::cSheep(int a_Color) : - Super("Sheep", mtSheep, "entity.sheep.hurt", "entity.sheep.death", "entity.sheep.ambient", 0.6, 1.3), + Super("Sheep", mtSheep, "entity.sheep.hurt", "entity.sheep.death", "entity.sheep.ambient", 0.9, 1.3), m_IsSheared(false), m_WoolColor(a_Color), m_TimeToStopEating(-1) |