CPhysical

This commit is contained in:
aap 2020-05-22 14:27:16 +02:00
parent 380f7bc417
commit a53ca58e56
18 changed files with 558 additions and 294 deletions

2
librw

@ -1 +1 @@
Subproject commit 3971dda001cba9c7dc67e86bc0b54a2c7568578f
Subproject commit 661feeabf4a4f0a8b0bee23b53ba557a14352d00

View File

@ -50,6 +50,7 @@ public:
int32 m_nExplosionsSinceLastReward;
int32 field_268;
int32 field_272;
int32 m_nHavocCaused; // TODO: check offset
bool m_bInfiniteSprint;
bool m_bFastReload;
bool m_bFireproof;

View File

@ -57,6 +57,7 @@ int32 CStats::mmRain;
int32 CStats::CarsCrushed;
int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES];
int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES];
int32 CStats::PropertyDestroyed;
int32 CStats::Sprayings;
float CStats::AutoPaintingBudget;

View File

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

View File

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

View File

@ -1,47 +1,6 @@
#pragma once
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
// TODO: check this
enum eSurfaceType
{
SURFACE_DEFAULT,
@ -77,8 +36,6 @@ enum eSurfaceType
SURFACE_LOOSE30,
SURFACE_BOLLARD,
SURFACE_GATE,
// These are illegal
SURFACE_SAND33,
SURFACE_ROAD34,
};
@ -89,6 +46,7 @@ enum
ADHESIVE_HARD,
ADHESIVE_ROAD,
ADHESIVE_LOOSE,
ADHESIVE_SAND,
ADHESIVE_WET,
NUMADHESIVEGROUPS

View File

@ -30,6 +30,7 @@ enum eEntityStatus : uint8
STATUS_PLANE,
STATUS_PLAYER_REMOTE,
STATUS_PLAYER_DISABLED,
STATUS_12, // TODO: what is this? used in CPhysical::ApplyAirResistance
};
class CEntity : public CPlaceable

File diff suppressed because it is too large Load Diff

View File

@ -18,8 +18,7 @@ public:
// The not properly indented fields haven't been checked properly yet
int32 m_audioEntityId;
float unk1;
CTreadable *m_treadable[2]; // car and ped
float m_phys_unused1;
uint32 m_nLastTimeCollided;
CVector m_vecMoveSpeed; // velocity
CVector m_vecTurnSpeed; // angular velocity
@ -37,16 +36,15 @@ public:
CEntryInfoList m_entryInfoList;
CPtrNode *m_movingListNode;
char field_EC;
int8 m_phys_unused2;
uint8 m_nStaticFrames;
uint8 m_nCollisionRecords;
bool m_bIsVehicleBeingShifted;
CEntity *m_aCollisionRecords[PHYSICAL_MAX_COLLISIONRECORDS];
float m_fDistanceTravelled;
// damaged piece
float m_fDamageImpulse; // fCollisionPower
float m_fDamageImpulse;
CEntity *m_pDamageEntity;
CVector m_vecDamageNormal;
int16 m_nDamagePieceType;
@ -54,12 +52,17 @@ public:
uint8 bIsHeavy : 1;
uint8 bAffectedByGravity : 1;
uint8 bInfiniteMass : 1;
uint8 m_phy_flagA08 : 1;
uint8 bIsInWater : 1;
uint8 m_phy_flagA10 : 1; // unused
uint8 m_phy_flagA20 : 1; // unused
uint8 bHitByTrain : 1;
uint8 bSkipLineCol : 1;
uint8 bIsFrozen : 1;
uint8 bDontLoadCollision : 1;
uint8 m_bIsVehicleBeingShifted : 1; // wrong name - also used on but never set for peds
uint8 bJustCheckCollision : 1; // just see if there is a collision
uint8 m_nSurfaceTouched;
int8 m_nZoneLevel;
@ -86,7 +89,6 @@ public:
void RemoveRefsToEntity(CEntity *ent);
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
CVector GetSpeed(const CVector &r);
CVector GetSpeed(void) { return GetSpeed(CVector(0.0f, 0.0f, 0.0f)); }
@ -94,7 +96,7 @@ public:
return 1.0f / (CrossProduct(pos, dir).MagnitudeSqr()/m_fTurnMass +
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) +
1.0f/(m_fMass*t));
}
@ -156,11 +158,13 @@ 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);
void ApplyGravity(void);
void ApplyFriction(void);
void ApplyAirResistance(void);
bool ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, float &impulseB);
bool ApplyCollision(CColPoint &colpoint, float &impulse);
bool ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CVector &moveSpeed, CVector &turnSpeed);
bool ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint);
bool ApplyFriction(float adhesiveLimit, CColPoint &colpoint);

View File

@ -399,6 +399,18 @@ IsLightThatNeedsRepositioning(int16 id)
id == MI_STREETLAMP2;
}
inline bool
IsLightObject(int16 id)
{
return id == MI_TRAFFICLIGHTS_MIAMI ||
id == MI_MLAMPPOST ||
id == MI_SINGLESTREETLIGHTS1 ||
id == MI_SINGLESTREETLIGHTS2 ||
id == MI_SINGLESTREETLIGHTS3 ||
id == MI_DOUBLESTREETLIGHTS ||
id == MI_TRAFFICLIGHTS_TWOVERTICAL;
}
inline bool
IsBodyPart(int16 id)
{
@ -455,7 +467,8 @@ inline bool
IsExplosiveThingModel(int16 id)
{
return id == MI_EXPLODINGBARREL ||
id == MI_PETROLPUMP;
id == MI_PETROLPUMP ||
id == MI_PETROLPUMP2;
}
inline bool

View File

@ -330,6 +330,8 @@ CObject::Init(void)
m_colour1 = 0;
m_colour2 = 0;
m_nBonusValue = 0;
bIsWeapon = false;
// TODO(MIAMI): some new field here
m_pCollidingEntity = nil;
CColPoint point;
CEntity* outEntity = nil;
@ -342,7 +344,9 @@ CObject::Init(void)
if (GetModelIndex() == MI_BUOY)
bTouchingWater = true;
// TODO(Miami): Second flag set initialization
if(CModelInfo::GetModelInfo(GetModelIndex())->GetModelType() == MITYPE_WEAPON)
bIsWeapon = true;
bIsStreetLight = IsLightObject(GetModelIndex());
m_area = AREA_EVERYWHERE;
}

View File

@ -59,26 +59,23 @@ public:
CMatrix m_objectMatrix;
float m_fUprootLimit;
int8 ObjectCreatedBy;
int8 bIsPickup : 1;
int8 bPickupObjWithMessage : 1;
int8 bOutOfStock : 1;
int8 bGlassCracked : 1;
int8 bGlassBroken : 1;
int8 bHasBeenDamaged : 1;
int8 bUseVehicleColours : 1;
uint8 bIsPickup : 1;
uint8 obj_flag_02 : 1;
uint8 bPickupObjWithMessage : 1;
uint8 bOutOfStock : 1;
uint8 bGlassCracked : 1;
uint8 bGlassBroken : 1;
uint8 bHasBeenDamaged : 1;
uint8 bUseVehicleColours : 1;
uint8 bIsWeapon : 1;
uint8 bIsStreetLight : 1;
int8 m_nBonusValue;
float m_fCollisionDamageMultiplier;
uint8 m_nCollisionDamageEffect;
uint8 m_nSpecialCollisionResponseCases;
bool m_bCameraToAvoidThisObject;
// this batch is unused
int8 field_17B;
int8 field_17C;
int8 field_17D;
int8 field_17E;
int8 field_17F;
int8 m_nBeachballBounces;
uint32 m_obj_unused1;
uint32 m_nEndOfLifeTime;
int16 m_nRefModelIndex;
CEntity *m_pCurSurface;
@ -86,8 +83,6 @@ public:
int8 m_colour1, m_colour2;
static int16 nNoTempObjects;
// static int16 nBodyCastHealth;
static float fDistToNearestTree;
static void *operator new(size_t);

View File

@ -59,6 +59,7 @@
#include "Floater.h"
#include "Streaming.h"
#include "PedAttractor.h"
#include "Debug.h"
#define CAN_SEE_ENTITY_ANGLE_THRESHOLD DEGTORAD(60.0f)

View File

@ -466,7 +466,7 @@ public:
//uint32 b158_1
//uint32 b158_2
//uint32 b158_4
uint32 b158_4 : 1;
//uint32 b158_8
//uint32 b158_10
//uint32 b158_20

View File

@ -155,7 +155,7 @@ public:
static float GetSpriteSize(void) { return m_fCurrentSpriteSize; }
static int GetShadowStrength(void) { return m_nCurrentShadowStrength; }
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 GetFogStart(void) { return m_fCurrentFogStart; }

View File

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

View File

@ -127,6 +127,9 @@ CVehicle::CVehicle(uint8 CreatedBy)
AutoPilot.m_bStayInCurrentLevel = false;
AutoPilot.m_bIgnorePathfinding = false;
AutoPilot.m_nSwitchDistance = 20;
// TODO(MIAMI)
bRestingOnPhysical = false;
}
CVehicle::~CVehicle()

View File

@ -189,7 +189,7 @@ public:
uint8 bIsDrowning : 1; // is vehicle occupants taking damage in water (i.e. vehicle is dead in water)
//uint8 bTyresDontBurst : 1; // If this is set the tyres are invincible
uint8 bCreatedAsPoliceVehicle : 1;// True if this guy was created as a police vehicle (enforcer, policecar, miamivice car etc)
//uint8 bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed
uint8 bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed
uint8 bParking : 1;
//uint8 bCanPark : 1;