mirror of
https://github.com/GTAmodding/re3.git
synced 2025-10-08 15:21:13 +00:00
Fix build without FIX_BUGS, divide to 0 fixes
This commit is contained in:
parent
4097c20bdd
commit
57201187de
6 changed files with 53 additions and 13 deletions
|
@ -783,9 +783,13 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
|
|||
if(B->GetStatus() == STATUS_PLAYER)
|
||||
pointposB *= 0.8f;
|
||||
if(CWorld::bNoMoreCollisionTorque){
|
||||
// BUG: the game actually uses A here, but this can't be right
|
||||
#ifdef FIX_BUGS
|
||||
B->ApplyFrictionMoveForce(fB*-0.3f);
|
||||
B->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
|
||||
#else
|
||||
A->ApplyFrictionMoveForce(fB*-0.3f);
|
||||
A->ApplyFrictionTurnForce(fB*-0.3f, pointposB);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if(!A->bInfiniteMass){
|
||||
|
@ -881,7 +885,13 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
|||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||
|
||||
#ifdef FIX_BUGS // division by 0
|
||||
frictionDir = vOtherSpeedA;
|
||||
frictionDir.Normalise();
|
||||
#else
|
||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||
#endif
|
||||
|
||||
speedSum = (B->m_fMass*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(B->m_fMass + A->m_fMass);
|
||||
if(fOtherSpeedA > speedSum){
|
||||
impulseA = (speedSum - fOtherSpeedA) * A->m_fMass;
|
||||
|
@ -911,7 +921,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
|||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||
|
||||
#ifdef FIX_BUGS // division by 0
|
||||
frictionDir = vOtherSpeedA;
|
||||
frictionDir.Normalise();
|
||||
#else
|
||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||
#endif
|
||||
float massB = B->GetMass(pointposB, frictionDir);
|
||||
speedSum = (massB*fOtherSpeedB + A->m_fMass*fOtherSpeedA)/(massB + A->m_fMass);
|
||||
if(fOtherSpeedA > speedSum){
|
||||
|
@ -939,7 +954,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
|||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||
|
||||
#ifdef FIX_BUGS // division by 0
|
||||
frictionDir = vOtherSpeedA;
|
||||
frictionDir.Normalise();
|
||||
#else
|
||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||
#endif
|
||||
float massA = A->GetMass(pointposA, frictionDir);
|
||||
speedSum = (B->m_fMass*fOtherSpeedB + massA*fOtherSpeedA)/(B->m_fMass + massA);
|
||||
if(fOtherSpeedA > speedSum){
|
||||
|
@ -967,7 +987,12 @@ CPhysical::ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint)
|
|||
fOtherSpeedA = vOtherSpeedA.Magnitude();
|
||||
fOtherSpeedB = vOtherSpeedB.Magnitude();
|
||||
|
||||
#ifdef FIX_BUGS // division by 0
|
||||
frictionDir = vOtherSpeedA;
|
||||
frictionDir.Normalise();
|
||||
#else
|
||||
frictionDir = vOtherSpeedA * (1.0f/fOtherSpeedA);
|
||||
#endif
|
||||
float massA = A->GetMass(pointposA, frictionDir);
|
||||
float massB = B->GetMass(pointposB, frictionDir);
|
||||
speedSum = (massB*fOtherSpeedB + massA*fOtherSpeedA)/(massB + massA);
|
||||
|
@ -1004,7 +1029,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
|
|||
|
||||
fOtherSpeed = vOtherSpeed.Magnitude();
|
||||
if(fOtherSpeed > 0.0f){
|
||||
#ifdef FIX_BUGS // division by 0
|
||||
frictionDir = vOtherSpeed;
|
||||
frictionDir.Normalise();
|
||||
#else
|
||||
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
|
||||
#endif
|
||||
// not really impulse but speed
|
||||
// maybe use ApplyFrictionMoveForce instead?
|
||||
fImpulse = -fOtherSpeed;
|
||||
|
@ -1022,7 +1052,12 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
|
|||
|
||||
fOtherSpeed = vOtherSpeed.Magnitude();
|
||||
if(fOtherSpeed > 0.0f){
|
||||
#ifdef FIX_BUGS // division by 0
|
||||
frictionDir = vOtherSpeed;
|
||||
frictionDir.Normalise();
|
||||
#else
|
||||
frictionDir = vOtherSpeed * (1.0f/fOtherSpeed);
|
||||
#endif
|
||||
fImpulse = -fOtherSpeed * m_fMass;
|
||||
impulseLimit = adhesiveLimit*CTimer::GetTimeStep() * 1.5;
|
||||
if(fImpulse < -impulseLimit) fImpulse = -impulseLimit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue