1
0

Further physics improvements [SEE DESC]

This was mainly focused on pickups, but it works for other things too.

* Entities no longer clip through blocks positive-vertically (this fixes
pickup issues as well).
* Entities lie flat against a block when they hit it.
* Reduced entity (mainly pickup) block clipping in non vertical
directions.
This commit is contained in:
Tiger Wang 2013-09-05 21:41:47 +01:00
parent ad89a0d460
commit 178b5884fc

View File

@ -519,17 +519,16 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{ {
// Push out entity. // Push out entity.
if (NextChunk->GetBlock( RelBlockX + 1, BlockY, RelBlockZ ) == E_BLOCK_AIR) { NextPos.x += 0.2; } if (NextChunk->GetBlock( RelBlockX + 1, BlockY, RelBlockZ ) == E_BLOCK_AIR) { NextPos.x += 0.2; NextPos.z, NextPos.y = 0; }
else if (NextChunk->GetBlock( RelBlockX - 1, BlockY, RelBlockZ ) == E_BLOCK_AIR) { NextPos.x += -0.2; } else if (NextChunk->GetBlock( RelBlockX - 1, BlockY, RelBlockZ ) == E_BLOCK_AIR) { NextPos.x += -0.2; NextPos.z, NextPos.y = 0; }
else if (NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ + 1 ) == E_BLOCK_AIR) { NextPos.z += 0.2; } else if (NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ + 1 ) == E_BLOCK_AIR) { NextPos.z += 0.2; NextPos.x, NextPos.y = 0; }
else if (NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ - 1 ) == E_BLOCK_AIR) { NextPos.z += -0.2; } else if (NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ - 1 ) == E_BLOCK_AIR) { NextPos.z += -0.2; NextPos.x, NextPos.y = 0; }
else { NextPos.y += 0.2; } else { NextPos.y += 0.2; NextPos.z, NextPos.x = 0;}
m_bOnGround = true; m_bOnGround = true;
NextPos.y += 0.2;
LOGD("Entity #%d (%s) is inside a block at {%d, %d, %d}", LOGD("Entity #%d (%s) is inside a block at {%d,%d,%d}",
m_UniqueID, GetClass(), BlockX, BlockY, BlockZ m_UniqueID, GetClass(), BlockX, BlockY, BlockZ);
);
} }
if (!m_bOnGround) if (!m_bOnGround)
@ -647,8 +646,9 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
} }
} }
NextPos.Set(Tracer.RealHit.x,Tracer.RealHit.y,Tracer.RealHit.z); NextPos.Set(Tracer.RealHit.x,Tracer.RealHit.y,Tracer.RealHit.z);
NextPos.x += Tracer.HitNormal.x * 0.5f; NextPos.x += Tracer.HitNormal.x * 0.3f;
NextPos.z += Tracer.HitNormal.z * 0.5f; NextPos.y += Tracer.HitNormal.y * 0.1f; // Any larger produces entity vibration-upon-the-spot
NextPos.z += Tracer.HitNormal.z * 0.3f;
} }
else else
NextPos += (NextSpeed * a_Dt); NextPos += (NextSpeed * a_Dt);