summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/entities/Entity.cpp12
-rw-r--r--src/entities/Entity.h4
-rw-r--r--src/entities/Physical.cpp118
-rw-r--r--src/entities/Physical.h8
4 files changed, 108 insertions, 34 deletions
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index 4653c173..988649ef 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -4,6 +4,7 @@
#include "RwHelper.h"
#include "ModelIndices.h"
#include "Timer.h"
+#include "Streaming.h"
#include "Entity.h"
#include "Object.h"
#include "World.h"
@@ -625,10 +626,15 @@ CEntity::SetupBigBuilding(void)
m_level = CTheZones::GetLevelFromPosition(&GetPosition());
if(mi->m_lodDistances[0] <= 2000.0f)
bStreamBIGBuilding = true;
- if(mi->m_lodDistances[0] > 2500.0f || mi->m_ignoreDrawDist)
+ if(m_modelIndex == islandLODindust ||
+ m_modelIndex == islandLODcomInd ||
+ m_modelIndex == islandLODcomSub ||
+ m_modelIndex == islandLODsubInd ||
+ m_modelIndex == islandLODsubCom ||
+ mi->m_lodDistances[0] > 5000.0f || mi->m_ignoreDrawDist)
m_level = LEVEL_GENERIC;
- else if(m_level == LEVEL_GENERIC)
- printf("%s isn't in a level\n", mi->GetModelName());
+// else if(m_level == LEVEL_GENERIC)
+// printf("%s isn't in a level\n", mi->GetModelName());
}
float WindTabel[] = {
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index 2749e3f7..c7a6f881 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -24,11 +24,11 @@ enum eEntityStatus
STATUS_PHYSICS,
STATUS_ABANDONED,
STATUS_WRECKED,
- STATUS_TRAIN_MOVING,
+ STATUS_TRAIN_MOVING, // these probably copied for FERRY
STATUS_TRAIN_NOT_MOVING,
STATUS_HELI,
STATUS_PLANE,
- STATUS_PLAYER_REMOTE,
+ STATUS_PLAYER_REMOTE, // 12 in LCS
STATUS_PLAYER_DISABLED,
STATUS_GHOST
};
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 03fbad03..08516b75 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -21,9 +21,7 @@
#include "Pickups.h"
#include "Physical.h"
-#ifdef WALLCLIMB_CHEAT
bool gGravityCheat;
-#endif
CPhysical::CPhysical(void)
@@ -357,7 +355,7 @@ CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
return numSpheres;
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ProcessControl(void)
{
@@ -425,7 +423,7 @@ CPhysical::GetSpeed(const CVector &r)
return m_vecMoveSpeed + m_vecMoveFriction + CrossProduct(m_vecTurnFriction + m_vecTurnSpeed, r);
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ApplyMoveSpeed(void)
{
@@ -435,13 +433,13 @@ CPhysical::ApplyMoveSpeed(void)
GetMatrix().Translate(m_vecMoveSpeed * CTimer::GetTimeStep());
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ApplyTurnSpeed(void)
{
if(bIsFrozen){
m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
- }else{
+ }else if(!m_vecTurnSpeed.IsZero()){
// Move the coordinate axes by their speed
// Note that this denormalizes the matrix
CVector turnvec = m_vecTurnSpeed*CTimer::GetTimeStep();
@@ -451,29 +449,36 @@ CPhysical::ApplyTurnSpeed(void)
}
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ApplyMoveForce(float jx, float jy, float jz)
{
m_vecMoveSpeed += CVector(jx, jy, jz)*(1.0f/m_fMass);
+ m_vecTurnSpeed.x = clamp(m_vecTurnSpeed.x, -4.0f, 4.0f);
+ m_vecTurnSpeed.y = clamp(m_vecTurnSpeed.y, -4.0f, 4.0f);
+ m_vecTurnSpeed.z = clamp(m_vecTurnSpeed.z, -4.0f, 4.0f);
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ApplyTurnForce(float jx, float jy, float jz, float px, float py, float pz)
{
CVector com = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
CVector turnimpulse = CrossProduct(CVector(px, py, pz)-com, CVector(jx, jy, jz));
m_vecTurnSpeed += turnimpulse*(1.0f/m_fTurnMass);
+ m_vecTurnSpeed.x = clamp(m_vecTurnSpeed.x, -4.0f, 4.0f);
+ m_vecTurnSpeed.y = clamp(m_vecTurnSpeed.y, -4.0f, 4.0f);
+ m_vecTurnSpeed.z = clamp(m_vecTurnSpeed.z, -4.0f, 4.0f);
}
+//--LCS: done
void
CPhysical::ApplyFrictionMoveForce(float jx, float jy, float jz)
{
m_vecMoveFriction += CVector(jx, jy, jz)*(1.0f/m_fMass);
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ApplyFrictionTurnForce(float jx, float jy, float jz, float px, float py, float pz)
{
@@ -482,7 +487,7 @@ CPhysical::ApplyFrictionTurnForce(float jx, float jy, float jz, float px, float
m_vecTurnFriction += turnimpulse*(1.0f/m_fTurnMass);
}
-// --MIAMI: Proof-read once
+//--LCS: done
bool
CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias)
{
@@ -496,16 +501,16 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &
return true;
}
-// --MIAMI: Proof-read once
+//--LCS: done
bool
-CPhysical::ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir)
+CPhysical::ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir, float &impulse)
{
float compression = 1.0f - springRatio;
if(compression > 0.0f){
if(DotProduct(springDir, forceDir) > 0.0f)
forceDir *= -1.0f;
float step = Min(CTimer::GetTimeStep(), 3.0f);
- float impulse = GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
+ impulse = GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
if(bIsHeavy)
impulse *= 0.75f;
ApplyMoveForce(forceDir*impulse);
@@ -514,36 +519,53 @@ CPhysical::ApplySpringCollisionAlt(float springConst, CVector &springDir, CVecto
return true;
}
-// --MIAMI: Proof-read once
+float DAMPING_LIMIT_OF_SPRING_FORCE = 0.999f;
+float DAMPING_LIMIT_IN_FRAME= 0.25f;
+
+//--LCS: done
// What exactly is speed?
bool
-CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed)
+CPhysical::ApplySpringDampening(float damping, float dampingLimit, CVector &springDir, CVector &point, CVector &speed)
{
float speedA = DotProduct(speed, springDir);
float speedB = DotProduct(GetSpeed(point), springDir);
float step = Min(CTimer::GetTimeStep(), 3.0f);
- float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f;
+ damping *= step;
if(bIsHeavy)
- impulse *= 2.0f;
+ damping *= 2.0f;
+ damping = clamp(damping, -DAMPING_LIMIT_IN_FRAME, DAMPING_LIMIT_IN_FRAME);
// what is this?
- float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
- a = Min(a, 1.0f);
- float b = Abs(impulse / (speedB * m_fMass));
- if(a < b)
- impulse *= a/b;
+ float fSpeed = -speedA * damping;
+ if(fSpeed > 0.0f && fSpeed+speedB > 0.0f){
+ if(speedB < 0.0f)
+ fSpeed = -speedB;
+ else
+ fSpeed = 0.0f;
+ }else if(fSpeed < 0.0f && fSpeed+speedB < 0.0f){
+ if(speedB > 0.0f)
+ fSpeed = -speedB;
+ else
+ fSpeed = 0.0f;
+ }
+
+ CVector com = Multiply3x3(m_matrix, m_vecCentreOfMass);
+ float impulse = fSpeed*GetMass(point-com, springDir);
+ float limit = Abs(dampingLimit)*DAMPING_LIMIT_OF_SPRING_FORCE;
+ if(impulse > limit)
+ impulse = limit;
ApplyMoveForce(springDir*impulse);
ApplyTurnForce(springDir*impulse, point);
return true;
}
+//--LCS: done
void
CPhysical::ApplyGravity(void)
{
if (!bAffectedByGravity)
return;
-#ifdef WALLCLIMB_CHEAT
if (gGravityCheat && this == FindPlayerVehicle()) {
static CVector gravityUp(0.0f, 0.0f, 1.0f), surfaceUp(0.0f, 0.0f, 1.0f);
CVector belowCar = GetPosition() - 2.0f*GetUp();
@@ -562,10 +584,10 @@ CPhysical::ApplyGravity(void)
m_vecMoveSpeed -= GRAVITY * CTimer::GetTimeStep() * gravityUp;
return;
}
-#endif
m_vecMoveSpeed.z -= GRAVITY * CTimer::GetTimeStep();
}
+//--LCS: done
void
CPhysical::ApplyFriction(void)
{
@@ -575,7 +597,7 @@ CPhysical::ApplyFriction(void)
m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f);
}
-// --MIAMI: Proof-read once
+//--LCS: done
void
CPhysical::ApplyAirResistance(void)
{
@@ -583,8 +605,8 @@ CPhysical::ApplyAirResistance(void)
float f = Pow(m_fAirResistance, CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= f;
- }else if(GetStatus() != STATUS_GHOST){
- float f = Pow(1.0f/Abs(1.0f + m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr()), CTimer::GetTimeStep());
+ }else{
+ float f = Pow(1.0f - m_fAirResistance*m_vecMoveSpeed.Magnitude(), CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= 0.99f;
}
@@ -693,6 +715,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
int16 model = B->GetModelIndex();
if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
+ CParticleObject::AddObject(POBJECT_FIRE_HYDRANT_STEAM, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
Bobj->bHasBeenDamaged = true;
}else if(model == MI_PARKINGMETER || model == MI_PARKINGMETER2){
CPickups::CreateSomeMoney(GetPosition(), CGeneral::GetRandomNumber()%100);
@@ -2308,3 +2331,44 @@ CPhysical::ProcessCollision(void)
m_fElasticity = savedElasticity;
RemoveAndAdd();
}
+
+
+
+// TEMP old VC code until bikes are done
+bool
+CPhysical::ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir)
+{
+ float compression = 1.0f - springRatio;
+ if(compression > 0.0f){
+ if(DotProduct(springDir, forceDir) > 0.0f)
+ forceDir *= -1.0f;
+ float step = Min(CTimer::GetTimeStep(), 3.0f);
+ float impulse = GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
+ if(bIsHeavy)
+ impulse *= 0.75f;
+ ApplyMoveForce(forceDir*impulse);
+ ApplyTurnForce(forceDir*impulse, point);
+ }
+ return true;
+}
+bool
+CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed)
+{
+ float speedA = DotProduct(speed, springDir);
+ float speedB = DotProduct(GetSpeed(point), springDir);
+ float step = Min(CTimer::GetTimeStep(), 3.0f);
+ float impulse = -damping * (speedA + speedB)/2.0f * m_fMass * step * 0.53f;
+ if(bIsHeavy)
+ impulse *= 2.0f;
+
+ // what is this?
+ float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
+ a = Min(a, 1.0f);
+ float b = Abs(impulse / (speedB * m_fMass));
+ if(a < b)
+ impulse *= a/b;
+
+ ApplyMoveForce(springDir*impulse);
+ ApplyTurnForce(springDir*impulse, point);
+ return true;
+}
diff --git a/src/entities/Physical.h b/src/entities/Physical.h
index 926b9762..290c267c 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -158,8 +158,8 @@ public:
void ApplyFrictionTurnForce(const CVector &j, const CVector &p) { ApplyFrictionTurnForce(j.x, j.y, j.z, p.x, p.y, p.z); }
// springRatio: 1.0 fully extended, 0.0 fully compressed
bool ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias);
- bool ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir);
- bool ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed);
+ bool ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir, float &impulse);
+ bool ApplySpringDampening(float damping, float dampingLimit, CVector &springDir, CVector &point, CVector &speed);
void ApplyGravity(void);
void ApplyFriction(void);
void ApplyAirResistance(void);
@@ -174,4 +174,8 @@ public:
bool ProcessCollisionSectorList(CPtrList *lists);
bool CheckCollision(void);
bool CheckCollision_SimpleCar(void);
+
+ // TEMP
+ bool ApplySpringCollisionAlt(float springConst, CVector &springDir, CVector &point, float springRatio, float bias, CVector &forceDir);
+ bool ApplySpringDampening(float damping, CVector &springDir, CVector &point, CVector &speed);
};