fixes for CPhysical and friends

This commit is contained in:
aap 2020-05-22 14:34:44 +02:00
parent 73ff01e35b
commit 21071edbfe
9 changed files with 132 additions and 176 deletions

View File

@ -10,7 +10,7 @@ public:
TOTAL_HIGHEST_SCORES = 16 TOTAL_HIGHEST_SCORES = 16
}; };
static int32 DaysPassed; static int32 DaysPassed;
static int32 HeadsPopped; static int32 HeadsPopped;
static int32 CommercialPassed; static int32 CommercialPassed;
static int32 IndustrialPassed; static int32 IndustrialPassed;
static int32 SuburbanPassed; static int32 SuburbanPassed;
@ -52,14 +52,14 @@ public:
static int32 LongestFlightInDodo; static int32 LongestFlightInDodo;
static int32 TimeTakenDefuseMission; static int32 TimeTakenDefuseMission;
static int32 TotalNumberKillFrenzies; static int32 TotalNumberKillFrenzies;
static int32 TotalNumberMissions; static int32 TotalNumberMissions;
static int32 RoundsFiredByPlayer; static int32 RoundsFiredByPlayer;
static int32 KgsOfExplosivesUsed; static int32 KgsOfExplosivesUsed;
static int32 InstantHitsFiredByPlayer; static int32 InstantHitsFiredByPlayer;
static int32 InstantHitsHitByPlayer; static int32 InstantHitsHitByPlayer;
static int32 BestTimeBombDefusal; static int32 BestTimeBombDefusal;
static int32 mmRain; static int32 mmRain;
static int32 CarsCrushed; static int32 CarsCrushed;
static int32 FastestTimes[TOTAL_FASTEST_TIMES]; static int32 FastestTimes[TOTAL_FASTEST_TIMES];
static int32 HighestScores[TOTAL_HIGHEST_SCORES]; static int32 HighestScores[TOTAL_HIGHEST_SCORES];

View File

@ -56,40 +56,40 @@ int
CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) CSurfaceTable::GetAdhesionGroup(uint8 surfaceType)
{ {
switch(surfaceType){ switch(surfaceType){
case SURFACE_0: return ADHESIVE_ROAD; case SURFACE_DEFAULT: return ADHESIVE_ROAD;
case SURFACE_1: return ADHESIVE_ROAD; case SURFACE_TARMAC: return ADHESIVE_ROAD;
case SURFACE_2: return ADHESIVE_LOOSE; case SURFACE_GRASS: return ADHESIVE_LOOSE;
case SURFACE_3: return ADHESIVE_LOOSE; case SURFACE_DIRT: return ADHESIVE_LOOSE;
case SURFACE_4: return ADHESIVE_HARD; case SURFACE_DIRTTRACK: return ADHESIVE_HARD;
case SURFACE_5: return ADHESIVE_ROAD; case SURFACE_PAVEMENT: return ADHESIVE_ROAD;
case SURFACE_6: return ADHESIVE_HARD; case SURFACE_METAL6: return ADHESIVE_HARD;
case SURFACE_7: return ADHESIVE_HARD; case SURFACE_GLASS: return ADHESIVE_HARD;
case SURFACE_8: return ADHESIVE_HARD; case SURFACE_SCAFFOLD: return ADHESIVE_HARD;
case SURFACE_9: return ADHESIVE_HARD; case SURFACE_METAL_DOOR: return ADHESIVE_HARD;
case SURFACE_10: return ADHESIVE_HARD; case SURFACE_BILLBOARD: return ADHESIVE_HARD;
case SURFACE_11: return ADHESIVE_HARD; case SURFACE_STEEL: return ADHESIVE_HARD;
case SURFACE_12: return ADHESIVE_HARD; case SURFACE_METAL_POLE: return ADHESIVE_HARD;
case SURFACE_13: return ADHESIVE_HARD; case SURFACE_STREET_LIGHT: return ADHESIVE_HARD;
case SURFACE_14: return ADHESIVE_HARD; case SURFACE_METAL14: return ADHESIVE_HARD;
case SURFACE_15: return ADHESIVE_HARD; case SURFACE_METAL15: return ADHESIVE_HARD;
case SURFACE_16: return ADHESIVE_HARD; case SURFACE_METAL_FENCE: return ADHESIVE_HARD;
case SURFACE_17: return ADHESIVE_RUBBER; case SURFACE_FLESH: return ADHESIVE_RUBBER;
case SURFACE_18: return ADHESIVE_LOOSE; case SURFACE_SAND: return ADHESIVE_LOOSE;
case SURFACE_19: return ADHESIVE_WET; case SURFACE_PUDDLE: return ADHESIVE_WET;
case SURFACE_20: return ADHESIVE_ROAD; case SURFACE_WOOD: return ADHESIVE_ROAD;
case SURFACE_21: return ADHESIVE_ROAD; case SURFACE_WOOD_BOX: return ADHESIVE_ROAD;
case SURFACE_22: return ADHESIVE_ROAD; case SURFACE_WOOD_PLANK: return ADHESIVE_ROAD;
case SURFACE_23: return ADHESIVE_RUBBER; case SURFACE_TIRE: return ADHESIVE_RUBBER;
case SURFACE_24: return ADHESIVE_HARD; case SURFACE_HARD24: return ADHESIVE_HARD;
case SURFACE_25: return ADHESIVE_LOOSE; case SURFACE_HEDGE: return ADHESIVE_LOOSE;
case SURFACE_26: return ADHESIVE_LOOSE; case SURFACE_STONE: return ADHESIVE_LOOSE;
case SURFACE_27: return ADHESIVE_HARD; case SURFACE_METAL27: return ADHESIVE_HARD;
case SURFACE_28: return ADHESIVE_HARD; case SURFACE_METAL28: return ADHESIVE_HARD;
case SURFACE_29: return ADHESIVE_RUBBER; case SURFACE_RUBBER29: return ADHESIVE_RUBBER;
case SURFACE_30: return ADHESIVE_LOOSE; case SURFACE_LOOSE30: return ADHESIVE_LOOSE;
case SURFACE_31: return ADHESIVE_HARD; case SURFACE_BOLLARD: return ADHESIVE_HARD;
case SURFACE_32: return ADHESIVE_HARD; case SURFACE_GATE: return ADHESIVE_HARD;
default: return ADHESIVE_ROAD; default: return ADHESIVE_ROAD;
} }
} }
@ -97,38 +97,38 @@ float
CSurfaceTable::GetWetMultiplier(uint8 surfaceType) CSurfaceTable::GetWetMultiplier(uint8 surfaceType)
{ {
switch(surfaceType){ switch(surfaceType){
case SURFACE_0: case SURFACE_DEFAULT:
case SURFACE_1: case SURFACE_TARMAC:
case SURFACE_4: case SURFACE_DIRTTRACK:
case SURFACE_5: case SURFACE_PAVEMENT:
case SURFACE_8: case SURFACE_SCAFFOLD:
case SURFACE_20: case SURFACE_WOOD:
case SURFACE_21: case SURFACE_WOOD_BOX:
case SURFACE_22: case SURFACE_WOOD_PLANK:
case SURFACE_25: case SURFACE_HEDGE:
case SURFACE_30: case SURFACE_LOOSE30:
case SURFACE_31: case SURFACE_BOLLARD:
return 1.0f - CWeather::WetRoads*0.25f; return 1.0f - CWeather::WetRoads*0.25f;
case SURFACE_2: case SURFACE_GRASS:
case SURFACE_6: case SURFACE_METAL6:
case SURFACE_7: case SURFACE_GLASS:
case SURFACE_9: case SURFACE_METAL_DOOR:
case SURFACE_10: case SURFACE_BILLBOARD:
case SURFACE_11: case SURFACE_STEEL:
case SURFACE_12: case SURFACE_METAL_POLE:
case SURFACE_13: case SURFACE_STREET_LIGHT:
case SURFACE_14: case SURFACE_METAL14:
case SURFACE_15: case SURFACE_METAL15:
case SURFACE_16: case SURFACE_METAL_FENCE:
case SURFACE_17: case SURFACE_FLESH:
case SURFACE_23: case SURFACE_TIRE:
case SURFACE_24: case SURFACE_HARD24:
case SURFACE_26: case SURFACE_STONE:
case SURFACE_27: case SURFACE_METAL27:
case SURFACE_28: case SURFACE_METAL28:
case SURFACE_29: case SURFACE_RUBBER29:
case SURFACE_32: case SURFACE_GATE:
return 1.0f - CWeather::WetRoads*0.4f; return 1.0f - CWeather::WetRoads*0.4f;
default: default:

View File

@ -1,47 +1,6 @@
#pragma once #pragma once
// TODO: check this
enum
{
SURFACE_0,
SURFACE_1,
SURFACE_2,
SURFACE_3,
SURFACE_4,
SURFACE_5,
SURFACE_6,
SURFACE_7,
SURFACE_8,
SURFACE_9,
SURFACE_10,
SURFACE_11,
SURFACE_12,
SURFACE_13,
SURFACE_14,
SURFACE_15,
SURFACE_16,
SURFACE_17,
SURFACE_18,
SURFACE_19,
SURFACE_20,
SURFACE_21,
SURFACE_22,
SURFACE_23,
SURFACE_24,
SURFACE_25,
SURFACE_26,
SURFACE_27,
SURFACE_28,
SURFACE_29,
SURFACE_30,
SURFACE_31,
SURFACE_32,
NUMSURFACETYPES
};
// From nick
// TODO: check and use this
enum eSurfaceType enum eSurfaceType
{ {
SURFACE_DEFAULT, SURFACE_DEFAULT,

View File

@ -58,7 +58,7 @@ public:
friend bool GenericSave(int file); friend bool GenericSave(int file);
#ifdef FIX_BUGS #ifdef FIX_BUGS
static float GetDefaultTimeStep(void) { return 5.0f / 3.0f; } static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; }
static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); } static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); }
#endif #endif
}; };

View File

@ -45,9 +45,9 @@ CPhysical::CPhysical(void)
bUsesCollision = true; bUsesCollision = true;
m_audioEntityId = -5; m_audioEntityId = -5;
unk1 = 100.0f; m_phys_unused1 = 100.0f;
m_vecCentreOfMass = CVector(0.0f, 0.0f, 0.0f); m_vecCentreOfMass = CVector(0.0f, 0.0f, 0.0f);
field_EC = 0; m_phys_unused2 = 0;
bIsHeavy = false; bIsHeavy = false;
bAffectedByGravity = true; bAffectedByGravity = true;
@ -527,26 +527,26 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
bool ispedcontactA = false; bool ispedcontactA = false;
bool ispedcontactB = false; bool ispedcontactB = false;
float timestepA; float massFactorA;
if(B->bPedPhysics){ if(B->bPedPhysics){
timestepA = 10.0f; massFactorA = 10.0f;
if(B->IsPed() && ((CPed*)B)->m_pCurrentPhysSurface == A) if(B->IsPed() && ((CPed*)B)->m_pCurrentPhysSurface == A)
ispedcontactA = true; ispedcontactA = true;
}else }else
timestepA = A->bIsHeavy ? 2.0f : 1.0f; massFactorA = A->bIsHeavy ? 2.0f : 1.0f;
float timestepB; float massFactorB;
if(A->bPedPhysics){ if(A->bPedPhysics){
if(A->IsPed() && ((CPed*)A)->IsPlayer() && B->IsVehicle() && if(A->IsPed() && ((CPed*)A)->IsPlayer() && B->IsVehicle() &&
(B->GetStatus() == STATUS_ABANDONED || B->GetStatus() == STATUS_WRECKED || A->bHasHitWall)) (B->GetStatus() == STATUS_ABANDONED || B->GetStatus() == STATUS_WRECKED || A->bHasHitWall))
timestepB = 2200.0f / B->m_fMass; massFactorB = 2200.0f / B->m_fMass;
else else
timestepB = 10.0f; massFactorB = 10.0f;
if(A->IsPed() && ((CPed*)A)->m_pCurrentPhysSurface == B) if(A->IsPed() && ((CPed*)A)->m_pCurrentPhysSurface == B)
ispedcontactB = true; ispedcontactB = true;
}else }else
timestepB = B->bIsHeavy ? 2.0f : 1.0f; massFactorB = B->bIsHeavy ? 2.0f : 1.0f;
float speedA, speedB; float speedA, speedB;
if(B->IsStatic()){ if(B->IsStatic()){
@ -646,14 +646,17 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
// positive if B is moving towards A // positive if B is moving towards A
// not interested in how much B moves into A apparently? // not interested in how much B moves into A apparently?
// only interested in cases where A collided into B // only interested in cases where A collided into B
speedB = Max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal)); speedB = DotProduct(B->m_vecMoveSpeed, colpoint.normal);
float speedSum = Max(0.0f, DotProduct(B->m_vecMoveSpeed, colpoint.normal));
// A has moved into B // A has moved into B
if(speedA < speedB){ if(speedA < speedSum){
if(!A->bHasHitWall) if(A->bHasHitWall)
speedB -= (speedA - speedB) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eA = speedSum;
impulseA = (speedB-speedA) * A->m_fMass * timestepA; else
eA = speedSum - (speedA - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA-speedA) * A->m_fMass * massFactorA;
if(!A->bInfiniteMass) if(!A->bInfiniteMass)
A->ApplyMoveForce(colpoint.normal*(impulseA/timestepA)); A->ApplyMoveForce(colpoint.normal*(impulseA/massFactorA));
return true; return true;
} }
}else if(A->bPedPhysics){ }else if(A->bPedPhysics){
@ -661,9 +664,9 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal); speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal);
float a = A->m_fMass*timestepA; float mA = A->m_fMass*massFactorA;
float b = B->GetMassTime(pointposB, colpoint.normal, timestepB); float mB = B->GetMassTweak(pointposB, colpoint.normal, massFactorB);
float speedSum = (b*speedB + a*speedA)/(a + b); float speedSum = (mB*speedB + mA*speedA)/(mA + mB);
if(speedA < speedSum){ if(speedA < speedSum){
if(A->bHasHitWall) if(A->bHasHitWall)
eA = speedSum; eA = speedSum;
@ -673,10 +676,10 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
eB = speedSum; eB = speedSum;
else else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA - speedA) * a; impulseA = (eA - speedA) * mA;
impulseB = -(eB - speedB) * b; impulseB = -(eB - speedB) * mB;
CVector fA = colpoint.normal*(impulseA/timestepA); CVector fA = colpoint.normal*(impulseA/massFactorA);
CVector fB = colpoint.normal*(-impulseB/timestepB); CVector fB = colpoint.normal*(-impulseB/massFactorB);
if(!A->bInfiniteMass){ if(!A->bInfiniteMass){
if(fA.z < 0.0f) fA.z = 0.0f; if(fA.z < 0.0f) fA.z = 0.0f;
if(ispedcontactB){ if(ispedcontactB){
@ -696,9 +699,9 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal); speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal);
speedB = DotProduct(B->m_vecMoveSpeed, colpoint.normal); speedB = DotProduct(B->m_vecMoveSpeed, colpoint.normal);
float a = A->GetMassTime(pointposA, colpoint.normal, timestepA); float mA = A->GetMassTweak(pointposA, colpoint.normal, massFactorA);
float b = B->m_fMass*timestepB; float mB = B->m_fMass*massFactorB;
float speedSum = (b*speedB + a*speedA)/(a + b); float speedSum = (mB*speedB + mA*speedA)/(mA + mB);
if(speedA < speedSum){ if(speedA < speedSum){
if(A->bHasHitWall) if(A->bHasHitWall)
eA = speedSum; eA = speedSum;
@ -708,10 +711,10 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
eB = speedSum; eB = speedSum;
else else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA - speedA) * a; impulseA = (eA - speedA) * mA;
impulseB = -(eB - speedB) * b; impulseB = -(eB - speedB) * mB;
CVector fA = colpoint.normal*(impulseA/timestepA); CVector fA = colpoint.normal*(impulseA/massFactorA);
CVector fB = colpoint.normal*(-impulseB/timestepB); CVector fB = colpoint.normal*(-impulseB/massFactorB);
if(!A->bInfiniteMass && !ispedcontactA){ if(!A->bInfiniteMass && !ispedcontactA){
if(fA.z < 0.0f) fA.z = 0.0f; if(fA.z < 0.0f) fA.z = 0.0f;
A->ApplyMoveForce(fA); A->ApplyMoveForce(fA);
@ -736,9 +739,9 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
CVector pointposB = colpoint.point - B->GetPosition(); CVector pointposB = colpoint.point - B->GetPosition();
speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal); speedA = DotProduct(A->GetSpeed(pointposA), colpoint.normal);
speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal); speedB = DotProduct(B->GetSpeed(pointposB), colpoint.normal);
float a = A->GetMassTime(pointposA, colpoint.normal, timestepA); float mA = A->GetMassTweak(pointposA, colpoint.normal, massFactorA);
float b = B->GetMassTime(pointposB, colpoint.normal, timestepB); float mB = B->GetMassTweak(pointposB, colpoint.normal, massFactorB);
float speedSum = (b*speedB + a*speedA)/(a + b); float speedSum = (mB*speedB + mA*speedA)/(mA + mB);
if(speedA < speedSum){ if(speedA < speedSum){
if(A->bHasHitWall) if(A->bHasHitWall)
eA = speedSum; eA = speedSum;
@ -748,10 +751,10 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
eB = speedSum; eB = speedSum;
else else
eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f; eB = speedSum - (speedB - speedSum) * (A->m_fElasticity+B->m_fElasticity)/2.0f;
impulseA = (eA - speedA) * a; impulseA = (eA - speedA) * mA;
impulseB = -(eB - speedB) * b; impulseB = -(eB - speedB) * mB;
CVector fA = colpoint.normal*(impulseA/timestepA); CVector fA = colpoint.normal*(impulseA/massFactorA);
CVector fB = colpoint.normal*(-impulseB/timestepB); CVector fB = colpoint.normal*(-impulseB/massFactorB);
if(A->IsVehicle() && !A->bHasHitWall){ if(A->IsVehicle() && !A->bHasHitWall){
fA.x *= 1.4f; fA.x *= 1.4f;
fA.y *= 1.4f; fA.y *= 1.4f;
@ -767,7 +770,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(B->IsVehicle() && !B->bHasHitWall){ if(B->IsVehicle() && !B->bHasHitWall){
fB.x *= 1.4f; fB.x *= 1.4f;
fB.y *= 1.4f; fB.y *= 1.4f;
if(colpoint.normal.z < 0.7f) if(-colpoint.normal.z < 0.7f)
fB.z *= 0.3f; fB.z *= 0.3f;
if(B->GetStatus() == STATUS_PLAYER) if(B->GetStatus() == STATUS_PLAYER)
pointposB *= 0.8f; pointposB *= 0.8f;
@ -813,7 +816,7 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
speed = GetSpeed(pointpos); speed = GetSpeed(pointpos);
normalSpeed = DotProduct(speed, colpoint.normal); normalSpeed = DotProduct(speed, colpoint.normal);
if(normalSpeed < 0.0f){ if(normalSpeed < 0.0f){
float minspeed = 0.0104f * CTimer::GetTimeStep(); float minspeed = 1.3f*GRAVITY * CTimer::GetTimeStep();
#ifdef GTA3_1_1_PATCH #ifdef GTA3_1_1_PATCH
if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED))) && if ((IsObject() || IsVehicle() && (GetUp().z < -0.3f || ((CVehicle*)this)->IsBike() && (GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED))) &&
#else #else
@ -1015,7 +1018,7 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint)
ApplyFrictionTurnForce(frictionDir*fImpulse, pointpos); ApplyFrictionTurnForce(frictionDir*fImpulse, pointpos);
if(fOtherSpeed > 0.1f && if(fOtherSpeed > 0.1f &&
colpoint.surfaceB != SURFACE_2 && colpoint.surfaceB != SURFACE_4 && colpoint.surfaceB != SURFACE_GRASS && colpoint.surfaceB != SURFACE_DIRTTRACK &&
CSurfaceTable::GetAdhesionGroup(colpoint.surfaceA) == ADHESIVE_HARD){ CSurfaceTable::GetAdhesionGroup(colpoint.surfaceA) == ADHESIVE_HARD){
CVector v = frictionDir * fOtherSpeed * 0.25f; CVector v = frictionDir * fOtherSpeed * 0.25f;
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
@ -1064,7 +1067,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
canshift = true; canshift = true;
else else
canshift = A->IsPed() && canshift = A->IsPed() &&
B->IsObject() && B->bInfiniteMass && !Bobj->bHasBeenDamaged; B->IsObject() && B->bIsStatic && !Bobj->bHasBeenDamaged;
if(B == A || if(B == A ||
B->m_scanCode == CWorld::GetCurrentScanCode() || B->m_scanCode == CWorld::GetCurrentScanCode() ||
!B->bUsesCollision || !B->bUsesCollision ||
@ -1084,7 +1087,6 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
B->GetUp().z < 0.66f && B->GetUp().z < 0.66f &&
IsStreetLight(B->GetModelIndex())) IsStreetLight(B->GetModelIndex()))
skipShift = true; skipShift = true;
// TODO: maybe flip some ifs here
else if(A->IsObject() && B->IsVehicle()){ else if(A->IsObject() && B->IsVehicle()){
CObject *Aobj = (CObject*)A; CObject *Aobj = (CObject*)A;
if(Aobj->ObjectCreatedBy != TEMP_OBJECT && if(Aobj->ObjectCreatedBy != TEMP_OBJECT &&
@ -1699,16 +1701,16 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
} }
if(B->IsPed() && A->IsVehicle() && if(B->IsPed() && A->IsVehicle() &&
(!Bped->IsPlayer() || B->bHasHitWall && A->m_vecMoveSpeed.MagnitudeSqr() > 0.0025f)) (!Bped->IsPlayer() || B->bHasHitWall && A->m_vecMoveSpeed.MagnitudeSqr() > SQR(0.05f)))
Bped->KillPedWithCar((CVehicle*)A, maxImpulseB); Bped->KillPedWithCar((CVehicle*)A, maxImpulseB);
else if(B->GetModelIndex() == MI_TRAIN && A->IsPed() && else if(B->GetModelIndex() == MI_TRAIN && A->IsPed() &&
(!Aped->IsPlayer() || A->bHasHitWall)) (!Aped->IsPlayer() || A->bHasHitWall))
Aped->KillPedWithCar((CVehicle*)B, maxImpulseA*2.0f); Aped->KillPedWithCar((CVehicle*)B, maxImpulseA*2.0f);
else if(B->IsObject() && B->bUsesCollision && A->IsVehicle()){ else if(B->IsObject() && B->bUsesCollision && A->IsVehicle()){
// BUG? not impulseA?
if(Bobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f) if(Bobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f)
Bobj->ObjectDamage(maxImpulseB); Bobj->ObjectDamage(maxImpulseB);
}else if(A->IsObject() && A->bUsesCollision && B->IsVehicle()){ }else if(A->IsObject() && A->bUsesCollision && B->IsVehicle()){
// BUG? not impulseA?
if(Aobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f) if(Aobj->m_nCollisionDamageEffect && maxImpulseB > 20.0f)
Aobj->ObjectDamage(maxImpulseB); Aobj->ObjectDamage(maxImpulseB);
} }
@ -1774,7 +1776,7 @@ CPhysical::ProcessShift(void)
m_bIsVehicleBeingShifted = true; m_bIsVehicleBeingShifted = true;
CEntryInfoNode *node; CEntryInfoNode *node;
bool hasshifted = false; // whatever that means... bool hasshifted = false;
for(node = m_entryInfoList.first; node; node = node->next) for(node = m_entryInfoList.first; node; node = node->next)
hasshifted |= ProcessShiftSectorList(node->sector->m_lists); hasshifted |= ProcessShiftSectorList(node->sector->m_lists);
m_bIsVehicleBeingShifted = false; m_bIsVehicleBeingShifted = false;
@ -1831,7 +1833,7 @@ CPhysical::ProcessCollision(void)
int8 n = 1; // The number of steps we divide the time step into int8 n = 1; // The number of steps we divide the time step into
float step = 0.0f; // divided time step float step = 0.0f; // divided time step
float distSq = GetDistanceSq(); float distSq = m_vecMoveSpeed.MagnitudeSqr() * sq(CTimer::GetTimeStep());
if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){ if(IsPed() && (distSq >= sq(0.2f) || ped->IsPlayer())){
if(ped->IsPlayer()) if(ped->IsPlayer())
@ -1920,8 +1922,11 @@ CPhysical::ProcessCollision(void)
bSkipLineCol = false; bSkipLineCol = false;
if(!m_vecMoveSpeed.IsZero() || if(!m_vecMoveSpeed.IsZero() ||
!m_vecTurnSpeed.IsZero() || !m_vecTurnSpeed.IsZero() ||
#ifdef GTA_TRAIN
bHitByTrain || bHitByTrain ||
GetStatus() == STATUS_PLAYER || IsPed() && ped->IsPlayer()){ #endif
GetStatus() == STATUS_PLAYER ||
IsPed() && ped->IsPlayer()){
if(IsVehicle()) if(IsVehicle())
((CVehicle*)this)->bVehicleColProcessed = true; ((CVehicle*)this)->bVehicleColProcessed = true;
if(CheckCollision()){ if(CheckCollision()){

View File

@ -18,7 +18,7 @@ public:
// The not properly indented fields haven't been checked properly yet // The not properly indented fields haven't been checked properly yet
int32 m_audioEntityId; int32 m_audioEntityId;
float unk1; float m_phys_unused1;
CTreadable *m_treadable[2]; // car and ped CTreadable *m_treadable[2]; // car and ped
uint32 m_nLastTimeCollided; uint32 m_nLastTimeCollided;
CVector m_vecMoveSpeed; // velocity CVector m_vecMoveSpeed; // velocity
@ -37,7 +37,7 @@ public:
CEntryInfoList m_entryInfoList; CEntryInfoList m_entryInfoList;
CPtrNode *m_movingListNode; CPtrNode *m_movingListNode;
char field_EC; int8 m_phys_unused2;
uint8 m_nStaticFrames; uint8 m_nStaticFrames;
uint8 m_nCollisionRecords; uint8 m_nCollisionRecords;
bool m_bIsVehicleBeingShifted; bool m_bIsVehicleBeingShifted;
@ -86,7 +86,6 @@ public:
void RemoveRefsToEntity(CEntity *ent); void RemoveRefsToEntity(CEntity *ent);
static void PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos); static void PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos);
float GetDistanceSq(void) { return m_vecMoveSpeed.MagnitudeSqr() * sq(CTimer::GetTimeStep()); }
// get speed of point p relative to entity center // get speed of point p relative to entity center
CVector GetSpeed(const CVector &r); CVector GetSpeed(const CVector &r);
CVector GetSpeed(void) { return GetSpeed(CVector(0.0f, 0.0f, 0.0f)); } CVector GetSpeed(void) { return GetSpeed(CVector(0.0f, 0.0f, 0.0f)); }
@ -94,7 +93,7 @@ public:
return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/m_fTurnMass + return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/m_fTurnMass +
1.0f/m_fMass); 1.0f/m_fMass);
} }
float GetMassTime(const CVector &pos, const CVector &dir, float t) { float GetMassTweak(const CVector &pos, const CVector &dir, float t) {
return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/(m_fTurnMass*t) + return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/(m_fTurnMass*t) +
1.0f/(m_fMass*t)); 1.0f/(m_fMass*t));
} }

View File

@ -55,14 +55,7 @@ public:
uint8 m_nCollisionDamageEffect; uint8 m_nCollisionDamageEffect;
uint8 m_nSpecialCollisionResponseCases; uint8 m_nSpecialCollisionResponseCases;
bool m_bCameraToAvoidThisObject; bool m_bCameraToAvoidThisObject;
uint32 m_obj_unused1;
// this batch is unused
int8 field_17B;
int8 field_17C;
int8 field_17D;
int8 field_17E;
int8 field_17F;
uint32 m_nEndOfLifeTime; uint32 m_nEndOfLifeTime;
int16 m_nRefModelIndex; int16 m_nRefModelIndex;
CEntity *m_pCurSurface; CEntity *m_pCurSurface;

View File

@ -122,7 +122,7 @@ public:
static float GetSpriteSize(void) { return m_fCurrentSpriteSize; } static float GetSpriteSize(void) { return m_fCurrentSpriteSize; }
static int GetShadowStrength(void) { return m_nCurrentShadowStrength; } static int GetShadowStrength(void) { return m_nCurrentShadowStrength; }
static int GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; } static int GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; }
static int GetLightOnGroundBrightness(void) { return m_fCurrentLightsOnGroundBrightness; } static float GetLightOnGroundBrightness(void) { return m_fCurrentLightsOnGroundBrightness; }
static float GetFarClip(void) { return m_fCurrentFarClip; } static float GetFarClip(void) { return m_fCurrentFarClip; }
static float GetFogStart(void) { return m_fCurrentFogStart; } static float GetFogStart(void) { return m_fCurrentFogStart; }

View File

@ -79,7 +79,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner)
bIsInWater = true; bIsInWater = true;
unk1 = 0.0f; m_phys_unused1 = 0.0f;
m_bIsAnchored = true; m_bIsAnchored = true;
m_fOrientation = INVALID_ORIENTATION; m_fOrientation = INVALID_ORIENTATION;
bTouchingWater = true; bTouchingWater = true;