1
0

Debug: arrow log their position in each tick

This commit is contained in:
madmaxoft 2013-08-26 22:27:28 +02:00
parent 4bbade9fc6
commit 71cfb8fcd2
3 changed files with 39 additions and 19 deletions

View File

@ -481,7 +481,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{
// TODO Add collision detection with entities.
a_Dt /= 1000;
a_Dt /= 1000; // Convert from msec to sec
Vector3d NextPos = Vector3d(GetPosX(),GetPosY(),GetPosZ());
Vector3d NextSpeed = Vector3d(GetSpeedX(),GetSpeedY(),GetSpeedZ());
int BlockX = (int) floor(NextPos.x);
@ -520,7 +520,8 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
m_bOnGround = true;
NextPos.y += 0.2;
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)
@ -548,9 +549,15 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if (NextSpeed.SqrLength() > 0.0004f)
{
NextSpeed.x *= 0.7f / (1 + a_Dt);
if ( fabs(NextSpeed.x) < 0.05 ) NextSpeed.x = 0;
if (fabs(NextSpeed.x) < 0.05)
{
NextSpeed.x = 0;
}
NextSpeed.z *= 0.7f / (1 + a_Dt);
if ( fabs(NextSpeed.z) < 0.05 ) NextSpeed.z = 0;
if (fabs(NextSpeed.z) < 0.05)
{
NextSpeed.z = 0;
}
}
}

View File

@ -115,6 +115,18 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
// DEBUG:
LOGD("Arrow %d: {%.02f, %.02f, %.02f}", m_UniqueID, GetPosX(), GetPosY(), GetPosZ());
}
void cArrowEntity::SpawnOn(cClientHandle & a_Client)
{
a_Client.SendSpawnObject(*this, pkArrow, 0, 0, 0);

View File

@ -127,6 +127,7 @@ protected:
double m_DamageCoeff;
// cEntity overrides:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void SpawnOn(cClientHandle & a_Client) override;
// tolua_begin