From 0551d78dffd5d377de382e34d9f6c77773c68202 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 28 May 2017 20:56:17 +0200 Subject: Fixed tracer usage in Entity physics handling. (#3720) --- src/Entities/Entity.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index dff7114d5..f776f881a 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1122,12 +1122,14 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) Vector3d HitCoords; Vector3i HitBlockCoords; eBlockFace HitBlockFace; - if (cLineBlockTracer::FirstSolidHitTrace(*GetWorld(), NextPos, NextPos + NextSpeed, HitCoords, HitBlockCoords, HitBlockFace)) + Vector3d wantNextPos = NextPos + NextSpeed * DtSec.count(); + auto isHit = cLineBlockTracer::FirstSolidHitTrace(*GetWorld(), NextPos, wantNextPos, HitCoords, HitBlockCoords, HitBlockFace); + if (isHit) { // Set our position to where the block was hit, minus a bit: // TODO: The real entity's m_Width should be taken into account here NextPos = HitCoords - NextSpeed.NormalizeCopy() * 0.1; - if (HitBlockFace == BLOCK_FACE_YM) + if (HitBlockFace == BLOCK_FACE_YP) { // We hit the ground, adjust the position to the top of the block: m_bOnGround = true; @@ -1161,11 +1163,11 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } } } - } - else - { - // We didn't hit anything, so move =] - NextPos += (NextSpeed * DtSec.count()); + else + { + // We didn't hit anything, so move: + NextPos += (NextSpeed * DtSec.count()); + } } SetPosition(NextPos); -- cgit v1.2.3