From 2ae112fdf6b90bb4435dba34bcc2a23604e1e158 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 8 Jul 2019 21:37:47 +0200 Subject: more CAutomobile --- src/entities/Physical.cpp | 8 ++++---- src/entities/Physical.h | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/entities') diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index b2512ec2..c67dad84 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -457,7 +457,7 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector & float compression = 1.0f - springRatio; if(compression > 0.0f){ float step = min(CTimer::GetTimeStep(), 3.0f); - float impulse = -0.008f*m_fMass*step * springConst * compression * bias*2.0f; + float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f; ApplyMoveForce(springDir*impulse); ApplyTurnForce(springDir*impulse, point); } @@ -489,7 +489,7 @@ void CPhysical::ApplyGravity(void) { if(bAffectedByGravity) - m_vecMoveSpeed.z -= 0.008f * CTimer::GetTimeStep(); + m_vecMoveSpeed.z -= GRAVITY * CTimer::GetTimeStep(); } void @@ -1783,7 +1783,7 @@ CPhysical::ProcessShift(void) } bIsStuck = false; bIsInSafePosition = true; - m_fDistanceTravelled = (GetPosition() - *matrix.GetPosition()).Magnitude(); + m_fDistanceTravelled = (GetPosition() - matrix.GetPosition()).Magnitude(); RemoveAndAdd(); } } @@ -1925,7 +1925,7 @@ CPhysical::ProcessCollision(void) } } bHitByTrain = false; - m_fDistanceTravelled = (GetPosition() - *savedMatrix.GetPosition()).Magnitude(); + m_fDistanceTravelled = (GetPosition() - savedMatrix.GetPosition()).Magnitude(); m_phy_flagA80 = false; bIsStuck = false; diff --git a/src/entities/Physical.h b/src/entities/Physical.h index c1f9f1d9..c2fce334 100644 --- a/src/entities/Physical.h +++ b/src/entities/Physical.h @@ -8,6 +8,8 @@ enum { PHYSICAL_MAX_COLLISIONRECORDS = 6 }; +#define GRAVITY (0.008f) + class CTreadable; class CPhysical : public CEntity @@ -108,7 +110,23 @@ public: } const CVector &GetMoveSpeed() { return m_vecMoveSpeed; } + void SetMoveSpeed(float x, float y, float z) { + m_vecMoveSpeed.x = x; + m_vecMoveSpeed.y = y; + m_vecMoveSpeed.z = z; + } const CVector &GetTurnSpeed() { return m_vecTurnSpeed; } + void SetTurnSpeed(float x, float y, float z) { + m_vecTurnSpeed.x = x; + m_vecTurnSpeed.y = y; + m_vecTurnSpeed.z = z; + } + const CVector &GetCenterOfMass() { return m_vecCentreOfMass; } + void SetCenterOfMass(float x, float y, float z) { + m_vecCentreOfMass.x = x; + m_vecCentreOfMass.y = y; + m_vecCentreOfMass.z = z; + } void ApplyMoveSpeed(void); void ApplyTurnSpeed(void); -- cgit v1.2.3 From 74fcbc8c0a6bbac8e8057655c5f1133e15c63656 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 9 Jul 2019 09:57:44 +0200 Subject: more CAutomobile --- src/entities/Entity.h | 2 ++ src/entities/Physical.cpp | 4 ++-- src/entities/Physical.h | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/entities') diff --git a/src/entities/Entity.h b/src/entities/Entity.h index d055d25f..12a631d2 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -94,6 +94,8 @@ public: uint16 m_level; // int16 CReference *m_pFirstReference; + CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); } + CEntity(void); ~CEntity(void); diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index c67dad84..88287e26 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -62,7 +62,7 @@ CPhysical::CPhysical(void) m_phy_flagA10 = false; m_phy_flagA20 = false; - m_nLastCollType = 0; + m_nSurfaceTouched = SURFACE_DEFAULT; } CPhysical::~CPhysical(void) @@ -1918,7 +1918,7 @@ CPhysical::ProcessCollision(void) bHitByTrain || m_status == STATUS_PLAYER || IsPed() && ped->IsPlayer()){ if(IsVehicle()) - ((CVehicle*)this)->m_veh_flagD4 = true; + ((CVehicle*)this)->bVehicleColProcessed = true; if(CheckCollision()){ GetMatrix() = savedMatrix; return; diff --git a/src/entities/Physical.h b/src/entities/Physical.h index c2fce334..5bd98815 100644 --- a/src/entities/Physical.h +++ b/src/entities/Physical.h @@ -61,7 +61,7 @@ public: uint8 bHitByTrain : 1; // from nick uint8 m_phy_flagA80 : 1; - uint8 m_nLastCollType; + uint8 m_nSurfaceTouched; uint8 m_nZoneLevel; CPhysical(void); @@ -75,7 +75,7 @@ public: void ProcessShift(void); void ProcessCollision(void); - virtual int32 ProcessEntityCollision(CEntity *ent, CColPoint *point); + virtual int32 ProcessEntityCollision(CEntity *ent, CColPoint *colpoints); void RemoveAndAdd(void); void AddToMovingList(void); -- cgit v1.2.3