1
0

Even better pickup physics

This commit is contained in:
Tiger Wang 2013-09-13 19:54:50 +01:00
parent 22b8f3a2e0
commit 47119b3027

View File

@ -520,31 +520,36 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
// Push out entity. // Push out entity.
BLOCKTYPE GotBlock; BLOCKTYPE GotBlock;
static const Vector3i CrossCoords[] = static const struct
{ {
Vector3i(1, 0, 0), int x, y, z;
Vector3i(-1, 0, 0), } gCrossCoords[] =
Vector3i(0, 0, 1), {
Vector3i(0, 0, -1), { 1, 0, 0},
{-1, 0, 0},
{ 0, 0, 1},
{ 0, 0, -1},
} ; } ;
Vector3i PushDirection(0, 1, 0);
for (int i = 0; i < ARRAYCOUNT(CrossCoords); i++) bool IsNoAirSurrounding = true;
for (int i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
{ {
NextChunk->UnboundedRelGetBlockType(RelBlockX + CrossCoords[i].x, BlockY, RelBlockZ + CrossCoords[i].z, GotBlock); NextChunk->UnboundedRelGetBlockType(RelBlockX + gCrossCoords[i].x, BlockY, RelBlockZ + gCrossCoords[i].z, GotBlock);
if (!g_BlockIsSolid[GotBlock]) if (!g_BlockIsSolid[GotBlock])
{ {
PushDirection = CrossCoords[i]; NextPos.x += gCrossCoords[i].x;
break; NextPos.z += gCrossCoords[i].z;
} IsNoAirSurrounding = false;
} // for i - CrossCoords[] }
NextPos += Vector3d(PushDirection) * 0.2; } // for i - gCrossCoords[]
if (IsNoAirSurrounding)
{ NextPos.y += 0.5; }
m_bOnGround = true; m_bOnGround = true;
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, m_UniqueID, GetClass(), BlockX, BlockY, BlockZ);
);
} }
if (!m_bOnGround) if (!m_bOnGround)