1
0

cEntity: Added mass to entities.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1430 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
keyboard.osh@gmail.com 2013-04-28 18:54:43 +00:00
parent a0f7dea3be
commit 55b8495bf3
2 changed files with 29 additions and 0 deletions

View File

@ -33,6 +33,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z)
, m_HeadYaw( 0.0 )
, m_Rot(0.0, 0.0, 0.0)
, m_Pos(a_X, a_Y, a_Z)
, m_Mass (0.001) //Default 1g
, m_bDirtyHead(true)
, m_bDirtyOrientation(true)
, m_bDirtyPosition(true)
@ -506,6 +507,25 @@ void cEntity::SetHeadYaw(double a_HeadYaw)
void cEntity::SetMass(double a_Mass)
{
if (a_Mass > 0)
{
m_Mass = a_Mass;
}
else
{
//Make sure that mass is not zero. 1g is the default because we
//have to choose a number. It's perfectly legal to have a mass
//less than 1g as long as is NOT equal or less than zero.
m_Mass = 0.001;
}
}
void cEntity::SetRotation(double a_Rotation)
{
m_Rot.x = a_Rotation;

View File

@ -107,6 +107,7 @@ public:
cWorld * GetWorld(void) const { return m_World; }
double GetHeadYaw (void) const {return m_HeadYaw; }
double GetMass (void) const {return m_Mass; }
const Vector3d & GetPosition (void) const {return m_Pos; }
double GetPosX (void) const {return m_Pos.x; }
double GetPosY (void) const {return m_Pos.y; }
@ -125,6 +126,7 @@ public:
int GetChunkZ(void) const {return FAST_FLOOR_DIV(((int)m_Pos.z), cChunkDef::Width); }
void SetHeadYaw (double a_HeadYaw);
void SetMass (double a_Mass);
void SetPosX (double a_PosX);
void SetPosY (double a_PosY);
void SetPosZ (double a_PosZ);
@ -247,11 +249,18 @@ protected:
void ReferencedBy( cEntity*& a_EntityPtr );
void Dereference( cEntity*& a_EntityPtr );
private:
//Measured in degrees (MAX 360°)
double m_HeadYaw;
//Measured in meter/second (m/s)
Vector3d m_Speed;
//Measured in degrees (MAX 360°)
Vector3d m_Rot;
//Measured in meters (1 meter = 1 block) (m)
Vector3d m_Pos;
//Measured in meter/second
Vector3d m_WaterSpeed;
//Measured in Kilograms (Kg)
double m_Mass
} ; // tolua_export
typedef std::list<cEntity *> cEntityList;