1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-24 17:55:29 +00:00

little changes; one more function of CAutomobile

This commit is contained in:
aap 2019-07-08 17:07:34 +02:00
parent 12af85ca3d
commit edf5ac2626
9 changed files with 138 additions and 103 deletions

View file

@ -469,7 +469,7 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
CMatrix ped_matrix; CMatrix ped_matrix;
pp->matrix.DecompressIntoFullMatrix(ped_matrix); pp->matrix.DecompressIntoFullMatrix(ped_matrix);
ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation); ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
*ped->GetMatrix().GetPosition() *= (1.0f - interpolation); ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
ped->GetMatrix() += CMatrix(interpolation) * ped_matrix; ped->GetMatrix() += CMatrix(interpolation) * ped_matrix;
if (pp->vehicle_index) { if (pp->vehicle_index) {
ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1); ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1);
@ -666,7 +666,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
CMatrix vehicle_matrix; CMatrix vehicle_matrix;
vp->matrix.DecompressIntoFullMatrix(vehicle_matrix); vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation); vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
*vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation); vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix; vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix;
vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
vehicle->m_fHealth = 4 * vp->health; vehicle->m_fHealth = 4 * vp->health;
@ -847,7 +847,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
{ {
tGeneralPacket* pg = (tGeneralPacket*)&ptr[offset]; tGeneralPacket* pg = (tGeneralPacket*)&ptr[offset];
TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split); TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split);
*TheCamera.GetMatrix().GetPosition() *= split; TheCamera.GetMatrix().GetPosition() *= split;
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos; TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition();
@ -979,34 +979,34 @@ void CReplay::ProcessReplayCamera(void)
switch (CameraMode) { switch (CameraMode) {
case REPLAYCAMMODE_TOPDOWN: case REPLAYCAMMODE_TOPDOWN:
{ {
*TheCamera.GetMatrix().GetPosition() = CVector(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f); TheCamera.GetMatrix().GetPosition() = CVector(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f);
*TheCamera.GetMatrix().GetForward() = CVector(0.0f, 0.0f, -1.0f); TheCamera.GetMatrix().GetForward() = CVector(0.0f, 0.0f, -1.0f);
*TheCamera.GetMatrix().GetUp() = CVector(0.0f, 1.0f, 0.0f); TheCamera.GetMatrix().GetUp() = CVector(0.0f, 1.0f, 0.0f);
*TheCamera.GetMatrix().GetRight() = CVector(1.0f, 0.0f, 0.0f); TheCamera.GetMatrix().GetRight() = CVector(1.0f, 0.0f, 0.0f);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
pm->at = *(RwV3d*)TheCamera.GetMatrix().GetForward(); pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
pm->up = *(RwV3d*)TheCamera.GetMatrix().GetUp(); pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
pm->right = *(RwV3d*)TheCamera.GetMatrix().GetRight(); pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
break; break;
} }
case REPLAYCAMMODE_FIXED: case REPLAYCAMMODE_FIXED:
{ {
*TheCamera.GetMatrix().GetPosition() = CVector(CameraFixedX, CameraFixedY, CameraFixedZ); TheCamera.GetMatrix().GetPosition() = CVector(CameraFixedX, CameraFixedY, CameraFixedZ);
CVector forward(CameraFocusX - CameraFixedX, CameraFocusY - CameraFixedY, CameraFocusZ - CameraFixedZ); CVector forward(CameraFocusX - CameraFixedX, CameraFocusY - CameraFixedY, CameraFocusZ - CameraFixedZ);
forward.Normalise(); forward.Normalise();
CVector right = CrossProduct(CVector(0.0f, 0.0f, 1.0f), forward); CVector right = CrossProduct(CVector(0.0f, 0.0f, 1.0f), forward);
right.Normalise(); right.Normalise();
CVector up = CrossProduct(forward, right); CVector up = CrossProduct(forward, right);
up.Normalise(); up.Normalise();
*TheCamera.GetMatrix().GetForward() = forward; TheCamera.GetMatrix().GetForward() = forward;
*TheCamera.GetMatrix().GetUp() = up; TheCamera.GetMatrix().GetUp() = up;
*TheCamera.GetMatrix().GetRight() = right; TheCamera.GetMatrix().GetRight() = right;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
pm->at = *(RwV3d*)TheCamera.GetMatrix().GetForward(); pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
pm->up = *(RwV3d*)TheCamera.GetMatrix().GetUp(); pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
pm->right = *(RwV3d*)TheCamera.GetMatrix().GetRight(); pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
break; break;
} }
default: default:
@ -1189,7 +1189,7 @@ void CReplay::RestoreStuffFromMem(void)
CMatrix tmp1; CMatrix tmp1;
tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), false); tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), false);
CMatrix tmp2(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_LF]), false); CMatrix tmp2(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_LF]), false);
*tmp1.GetPosition() += CVector(tmp2.GetPosition()->x + 0.1f, 0.0f, tmp2.GetPosition()->z); tmp1.GetPosition() += CVector(tmp2.GetPosition().x + 0.1f, 0.0f, tmp2.GetPosition().z);
tmp1.UpdateRW(); tmp1.UpdateRW();
} }
if (vehicle->IsCar()){ if (vehicle->IsCar()){
@ -1525,15 +1525,15 @@ void CReplay::ProcessLookAroundCam(void)
right.Normalise(); right.Normalise();
CVector up = CrossProduct(forward, right); CVector up = CrossProduct(forward, right);
up.Normalise(); up.Normalise();
*TheCamera.GetMatrix().GetForward() = forward; TheCamera.GetMatrix().GetForward() = forward;
*TheCamera.GetMatrix().GetUp() = up; TheCamera.GetMatrix().GetUp() = up;
*TheCamera.GetMatrix().GetRight() = right; TheCamera.GetMatrix().GetRight() = right;
*TheCamera.GetMatrix().GetPosition() = camera_pt; TheCamera.GetMatrix().GetPosition() = camera_pt;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
pm->at = *(RwV3d*)TheCamera.GetMatrix().GetForward(); pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
pm->up = *(RwV3d*)TheCamera.GetMatrix().GetUp(); pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
pm->right = *(RwV3d*)TheCamera.GetMatrix().GetRight(); pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
TheCamera.CalculateDerivedValues(); TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera))); RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));

View file

@ -10,10 +10,10 @@ public:
CPlaceable(void); CPlaceable(void);
virtual ~CPlaceable(void); virtual ~CPlaceable(void);
CVector &GetPosition(void) { return *m_matrix.GetPosition(); } CVector &GetPosition(void) { return m_matrix.GetPosition(); }
CVector &GetRight(void) { return *m_matrix.GetRight(); } CVector &GetRight(void) { return m_matrix.GetRight(); }
CVector &GetForward(void) { return *m_matrix.GetForward(); } CVector &GetForward(void) { return m_matrix.GetForward(); }
CVector &GetUp(void) { return *m_matrix.GetUp(); } CVector &GetUp(void) { return m_matrix.GetUp(); }
CMatrix &GetMatrix(void) { return m_matrix; } CMatrix &GetMatrix(void) { return m_matrix; }
void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); } void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); }
void SetHeading(float angle); void SetHeading(float angle);

View file

@ -632,7 +632,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true; lightOn = true;
else else
lightFlickering = true; lightFlickering = true;
if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed) & 3) if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3)
lightOn = true; lightOn = true;
break; break;
case LIGHT_FLICKER_NIGHT: case LIGHT_FLICKER_NIGHT:
@ -641,7 +641,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true; lightOn = true;
else else
lightFlickering = true; lightFlickering = true;
if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed) & 3) if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed) & 3)
lightOn = true; lightOn = true;
} }
break; break;
@ -680,7 +680,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true; lightOn = true;
else else
lightFlickering = true; lightFlickering = true;
if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed*8) & 3) if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3)
lightOn = true; lightOn = true;
} }
break; break;
@ -693,7 +693,7 @@ CEntity::ProcessLightsForEntity(void)
lightOn = true; lightOn = true;
else else
lightFlickering = true; lightFlickering = true;
if((CTimer::GetTimeInMilliseconds()>>1 ^ m_randomSeed*8) & 3) if((CTimer::GetTimeInMilliseconds()>>11 ^ m_randomSeed*8) & 3)
lightOn = true; lightOn = true;
} }
} }
@ -815,8 +815,8 @@ CEntity::ModifyMatrixForTreeInWind(void)
strength = 0.005f; strength = 0.005f;
} }
mat.GetUp()->x = strength * flutter; mat.GetUp().x = strength * flutter;
mat.GetUp()->y = mat.GetUp()->x; mat.GetUp().y = mat.GetUp().x;
mat.UpdateRW(); mat.UpdateRW();
UpdateRwFrame(); UpdateRwFrame();
@ -847,7 +847,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
else else
strength = 0.66f; strength = 0.66f;
t = ((int)(GetMatrix().GetPosition()->x + GetMatrix().GetPosition()->y) << 10) + 16*CTimer::GetTimeInMilliseconds(); t = ((int)(GetMatrix().GetPosition().x + GetMatrix().GetPosition().y) << 10) + 16*CTimer::GetTimeInMilliseconds();
f = (t & 0x7FF)/(float)0x800; f = (t & 0x7FF)/(float)0x800;
flutter = f * BannerWindTabel[(t>>11)+1 & 0x1F] + flutter = f * BannerWindTabel[(t>>11)+1 & 0x1F] +
(1.0f - f) * BannerWindTabel[(t>>11) & 0x1F]; (1.0f - f) * BannerWindTabel[(t>>11) & 0x1F];

View file

@ -1883,7 +1883,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && m_vecMoveSpeed.z == 0.0f && if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
!ped->m_ped_flagA2 && !ped->m_ped_flagA2 &&
ped->bIsStanding) ped->bIsStanding)
savedMatrix.GetPosition()->z = GetPosition().z; savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix; GetMatrix() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep); CTimer::SetTimeStep(savedTimeStep);
return; return;
@ -1891,7 +1891,7 @@ CPhysical::ProcessCollision(void)
if(IsPed() && m_vecMoveSpeed.z == 0.0f && if(IsPed() && m_vecMoveSpeed.z == 0.0f &&
!ped->m_ped_flagA2 && !ped->m_ped_flagA2 &&
ped->bIsStanding) ped->bIsStanding)
savedMatrix.GetPosition()->z = GetPosition().z; savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix; GetMatrix() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep); CTimer::SetTimeStep(savedTimeStep);
if(IsVehicle()){ if(IsVehicle()){

View file

@ -78,10 +78,10 @@ public:
return *this; return *this;
} }
CVector *GetPosition(void){ return (CVector*)&m_matrix.pos; } CVector &GetPosition(void){ return *(CVector*)&m_matrix.pos; }
CVector *GetRight(void) { return (CVector*)&m_matrix.right; } CVector &GetRight(void) { return *(CVector*)&m_matrix.right; }
CVector *GetForward(void) { return (CVector*)&m_matrix.up; } CVector &GetForward(void) { return *(CVector*)&m_matrix.up; }
CVector *GetUp(void) { return (CVector*)&m_matrix.at; } CVector &GetUp(void) { return *(CVector*)&m_matrix.at; }
void SetScale(float s){ void SetScale(float s){
m_matrix.right.x = s; m_matrix.right.x = s;
m_matrix.right.y = 0.0f; m_matrix.right.y = 0.0f;
@ -190,9 +190,9 @@ public:
m_matrix.pos.z = 0.0f; m_matrix.pos.z = 0.0f;
} }
void Reorthogonalise(void){ void Reorthogonalise(void){
CVector &r = *GetRight(); CVector &r = GetRight();
CVector &f = *GetForward(); CVector &f = GetForward();
CVector &u = *GetUp(); CVector &u = GetUp();
u = CrossProduct(r, f); u = CrossProduct(r, f);
u.Normalise(); u.Normalise();
r = CrossProduct(f, u); r = CrossProduct(f, u);
@ -327,24 +327,24 @@ class CCompressedMatrixNotAligned
public: public:
void CompressFromFullMatrix(CMatrix &other) void CompressFromFullMatrix(CMatrix &other)
{ {
m_rightX = 127.0f * other.GetRight()->x; m_rightX = 127.0f * other.GetRight().x;
m_rightY = 127.0f * other.GetRight()->y; m_rightY = 127.0f * other.GetRight().y;
m_rightZ = 127.0f * other.GetRight()->z; m_rightZ = 127.0f * other.GetRight().z;
m_upX = 127.0f * other.GetForward()->x; m_upX = 127.0f * other.GetForward().x;
m_upY = 127.0f * other.GetForward()->y; m_upY = 127.0f * other.GetForward().y;
m_upZ = 127.0f * other.GetForward()->z; m_upZ = 127.0f * other.GetForward().z;
m_vecPos = *other.GetPosition(); m_vecPos = other.GetPosition();
} }
void DecompressIntoFullMatrix(CMatrix &other) void DecompressIntoFullMatrix(CMatrix &other)
{ {
other.GetRight()->x = m_rightX / 127.0f; other.GetRight().x = m_rightX / 127.0f;
other.GetRight()->y = m_rightY / 127.0f; other.GetRight().y = m_rightY / 127.0f;
other.GetRight()->z = m_rightZ / 127.0f; other.GetRight().z = m_rightZ / 127.0f;
other.GetForward()->x = m_upX / 127.0f; other.GetForward().x = m_upX / 127.0f;
other.GetForward()->y = m_upY / 127.0f; other.GetForward().y = m_upY / 127.0f;
other.GetForward()->z = m_upZ / 127.0f; other.GetForward().z = m_upZ / 127.0f;
*other.GetUp() = CrossProduct(*other.GetRight(), *other.GetForward()); other.GetUp() = CrossProduct(other.GetRight(), other.GetForward());
*other.GetPosition() = m_vecPos; other.GetPosition() = m_vecPos;
other.Reorthogonalise(); other.Reorthogonalise();
} }
}; };

View file

@ -63,7 +63,7 @@ CPed::~CPed(void)
CWorld::Remove(this); CWorld::Remove(this);
CRadar::ClearBlipForEntity(BLIP_CHAR, CPools::GetPedPool()->GetIndex(this)); CRadar::ClearBlipForEntity(BLIP_CHAR, CPools::GetPedPool()->GetIndex(this));
if (bInVehicle && m_pMyVehicle){ if (bInVehicle && m_pMyVehicle){
uint8 door_flag = GetVehEnterExitFlag(m_vehEnterType); uint8 door_flag = GetVehDoorFlag(m_vehEnterType);
if (m_pMyVehicle->pDriver == this) if (m_pMyVehicle->pDriver == this)
m_pMyVehicle->pDriver = nil; m_pMyVehicle->pDriver = nil;
else { else {
@ -309,7 +309,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_fRotationCur = 0.0f; m_fRotationCur = 0.0f;
m_headingRate = 15.0f; m_headingRate = 15.0f;
m_fRotationDest = 0.0f; m_fRotationDest = 0.0f;
m_vehEnterType = VEHICLE_ENTER_FRONT_LEFT; m_vehEnterType = CAR_DOOR_LF;
m_walkAroundType = 0; m_walkAroundType = 0;
m_pCurrentPhysSurface = nil; m_pCurrentPhysSurface = nil;
m_vecOffsetFromPhysSurface = CVector(0.0f, 0.0f, 0.0f); m_vecOffsetFromPhysSurface = CVector(0.0f, 0.0f, 0.0f);
@ -1334,7 +1334,7 @@ CPed::BeingDraggedFromCar(void)
if (animAssoc) if (animAssoc)
animAssoc->blendDelta = -1000.0f; animAssoc->blendDelta = -1000.0f;
if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) { if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
if (m_ped_flagF10) { if (m_ped_flagF10) {
enterAnim = ANIM_CAR_QJACKED; enterAnim = ANIM_CAR_QJACKED;
} else if (m_pMyVehicle->bLowVehicle) { } else if (m_pMyVehicle->bLowVehicle) {
@ -1342,7 +1342,7 @@ CPed::BeingDraggedFromCar(void)
} else { } else {
enterAnim = ANIM_CAR_JACKED_LHS; enterAnim = ANIM_CAR_JACKED_LHS;
} }
} else if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) { } else if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
if (m_pMyVehicle->bLowVehicle) if (m_pMyVehicle->bLowVehicle)
enterAnim = ANIM_CAR_LJACKED_RHS; enterAnim = ANIM_CAR_LJACKED_RHS;
else else
@ -1396,7 +1396,7 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
ped->m_pSeekTarget = nil; ped->m_pSeekTarget = nil;
vehicle = ped->m_pMyVehicle; vehicle = ped->m_pMyVehicle;
vehicle->m_nGettingOutFlags &= ~GetVehEnterExitFlag(ped->m_vehEnterType); vehicle->m_nGettingOutFlags &= ~GetVehDoorFlag(ped->m_vehEnterType);
if (vehicle->pDriver == ped) { if (vehicle->pDriver == ped) {
vehicle->RemoveDriver(); vehicle->RemoveDriver();
@ -1448,7 +1448,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
float seatOffset; float seatOffset;
vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(veh->m_modelIndex); vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(veh->m_modelIndex);
if (veh->bIsVan && (enterType == VEHICLE_ENTER_REAR_LEFT || enterType == VEHICLE_ENTER_REAR_RIGHT)) { if (veh->bIsVan && (enterType == CAR_DOOR_LR || enterType == CAR_DOOR_RR)) {
seatOffset = 0.0f; seatOffset = 0.0f;
vehDoorOffset = offsetToOpenVanDoor; vehDoorOffset = offsetToOpenVanDoor;
} else { } else {
@ -1461,7 +1461,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
} }
switch (enterType) { switch (enterType) {
case VEHICLE_ENTER_FRONT_RIGHT: case CAR_DOOR_RF:
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER]; vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
else else
@ -1471,13 +1471,13 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
vehDoorOffset.x = -vehDoorOffset.x; vehDoorOffset.x = -vehDoorOffset.x;
break; break;
case VEHICLE_ENTER_REAR_RIGHT: case CAR_DOOR_RR:
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS]; vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS];
vehDoorPos.x += seatOffset; vehDoorPos.x += seatOffset;
vehDoorOffset.x = -vehDoorOffset.x; vehDoorOffset.x = -vehDoorOffset.x;
break; break;
case VEHICLE_ENTER_FRONT_LEFT: case CAR_DOOR_LF:
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER]; vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
else else
@ -1486,7 +1486,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
vehDoorPos.x = -(vehDoorPos.x + seatOffset); vehDoorPos.x = -(vehDoorPos.x + seatOffset);
break; break;
case VEHICLE_ENTER_REAR_LEFT: case CAR_DOOR_LR:
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS]; vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS];
vehDoorPos.x = -(vehDoorPos.x + seatOffset); vehDoorPos.x = -(vehDoorPos.x + seatOffset);
break; break;
@ -1584,7 +1584,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (veh->GetUp().z <= -0.8f) if (veh->GetUp().z <= -0.8f)
vehIsUpsideDown = true; vehIsUpsideDown = true;
if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) { if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
if (vehIsUpsideDown) { if (vehIsUpsideDown) {
m_fRotationDest = -PI + veh->GetForward().Heading(); m_fRotationDest = -PI + veh->GetForward().Heading();
} else if (veh->bIsBus) { } else if (veh->bIsBus) {
@ -1592,7 +1592,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
} else { } else {
m_fRotationDest = veh->GetForward().Heading(); m_fRotationDest = veh->GetForward().Heading();
} }
} else if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) { } else if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
if (vehIsUpsideDown) { if (vehIsUpsideDown) {
m_fRotationDest = veh->GetForward().Heading(); m_fRotationDest = veh->GetForward().Heading();
} else if (veh->bIsBus) { } else if (veh->bIsBus) {
@ -1763,7 +1763,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
CMatrix vehDoorMat(veh->GetMatrix()); CMatrix vehDoorMat(veh->GetMatrix());
GetLocalPositionToOpenCarDoor(&output, veh, m_vehEnterType, 0.0f); GetLocalPositionToOpenCarDoor(&output, veh, m_vehEnterType, 0.0f);
*vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output); vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output);
GetMatrix() = vehDoorMat; GetMatrix() = vehDoorMat;
} }
@ -2696,7 +2696,7 @@ CPed::QuitEnteringCar(void)
if (veh->m_nNumGettingIn != 0) if (veh->m_nNumGettingIn != 0)
veh->m_nNumGettingIn--; veh->m_nNumGettingIn--;
veh->m_nGettingInFlags = GetVehEnterExitFlag(m_vehEnterType); veh->m_nGettingInFlags = GetVehDoorFlag(m_vehEnterType);
} }
bUsesCollision = true; bUsesCollision = true;

View file

@ -76,13 +76,6 @@ enum eObjective : uint32 {
OBJECTIVE_35 OBJECTIVE_35
}; };
enum eVehEnter : uint16 {
VEHICLE_ENTER_FRONT_RIGHT = 11,
VEHICLE_ENTER_REAR_RIGHT = 12,
VEHICLE_ENTER_FRONT_LEFT = 15,
VEHICLE_ENTER_REAR_LEFT = 16,
};
enum { enum {
RANDOM_CHAR = 1, RANDOM_CHAR = 1,
MISSION_CHAR, MISSION_CHAR,
@ -321,7 +314,7 @@ public:
float m_fRotationCur; float m_fRotationCur;
float m_fRotationDest; float m_fRotationDest;
float m_headingRate; float m_headingRate;
eVehEnter m_vehEnterType; uint16 m_vehEnterType;
uint16 m_walkAroundType; uint16 m_walkAroundType;
CEntity *m_pCurrentPhysSurface; CEntity *m_pCurrentPhysSurface;
CVector m_vecOffsetFromPhysSurface; CVector m_vecOffsetFromPhysSurface;
@ -526,20 +519,6 @@ public:
CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; } CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; }
CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; } CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; }
RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; } RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; }
static uint8 GetVehEnterExitFlag(eVehEnter vehEnter) {
switch (vehEnter) {
case VEHICLE_ENTER_FRONT_RIGHT:
return 4;
case VEHICLE_ENTER_REAR_RIGHT:
return 8;
case VEHICLE_ENTER_FRONT_LEFT:
return 1;
case VEHICLE_ENTER_REAR_LEFT:
return 2;
default:
return 0;
}
}
PedState GetPedState(void) { return m_nPedState; } PedState GetPedState(void) { return m_nPedState; }
void SetPedState(PedState state) { m_nPedState = state; } void SetPedState(PedState state) { m_nPedState = state; }

View file

@ -1,6 +1,7 @@
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include "VisibilityPlugins.h" #include "VisibilityPlugins.h"
#include "SurfaceTable.h"
#include "HandlingMgr.h" #include "HandlingMgr.h"
#include "Automobile.h" #include "Automobile.h"
@ -55,7 +56,7 @@ CAutomobile::SetComponentRotation(int32 component, CVector rotation)
mat.SetRotateX(DEGTORAD(rotation.x)); mat.SetRotateX(DEGTORAD(rotation.x));
mat.SetRotateY(DEGTORAD(rotation.y)); mat.SetRotateY(DEGTORAD(rotation.y));
mat.SetRotateZ(DEGTORAD(rotation.z)); mat.SetRotateZ(DEGTORAD(rotation.z));
*mat.GetPosition() += pos; mat.GetPosition() += pos;
mat.UpdateRW(); mat.UpdateRW();
} }
@ -106,7 +107,38 @@ CAutomobile::RemoveRefsToVehicle(CEntity *ent)
} }
WRAPPER void CAutomobile::BlowUpCar(CEntity *ent) { EAXJMP(0x53BC60); } WRAPPER void CAutomobile::BlowUpCar(CEntity *ent) { EAXJMP(0x53BC60); }
WRAPPER bool CAutomobile::SetUpWheelColModel(CColModel *colModel) { EAXJMP(0x53BF70); }
bool
CAutomobile::SetUpWheelColModel(CColModel *colModel)
{
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex());
CColModel *vehColModel = mi->GetColModel();
colModel->boundingSphere = vehColModel->boundingSphere;
colModel->boundingBox = vehColModel->boundingBox;
CMatrix mat;
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF]));
colModel->spheres[0].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_LF);
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LB]));
colModel->spheres[1].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_LR);
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF]));
colModel->spheres[2].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RF);
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RB]));
colModel->spheres[3].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RR);
if(m_aCarNodes[CAR_WHEEL_LM] != nil && m_aCarNodes[CAR_WHEEL_RM] != nil){
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LM]));
colModel->spheres[4].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RF);
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RM]));
colModel->spheres[5].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RR);
colModel->numSpheres = 6;
}else
colModel->numSpheres = 4;
return true;
}
WRAPPER void CAutomobile::BurstTyre(uint8 tyre) { EAXJMP(0x53C0E0); } WRAPPER void CAutomobile::BurstTyre(uint8 tyre) { EAXJMP(0x53C0E0); }
WRAPPER bool CAutomobile::IsRoomForPedToLeaveCar(uint32, CVector *) { EAXJMP(0x53C5B0); } WRAPPER bool CAutomobile::IsRoomForPedToLeaveCar(uint32, CVector *) { EAXJMP(0x53C5B0); }
@ -285,7 +317,7 @@ public:
bool IsDoorMissing_(eDoors door) { return CAutomobile::IsDoorMissing(door); } bool IsDoorMissing_(eDoors door) { return CAutomobile::IsDoorMissing(door); }
void RemoveRefsToVehicle_(CEntity *ent) { CAutomobile::RemoveRefsToVehicle(ent); } void RemoveRefsToVehicle_(CEntity *ent) { CAutomobile::RemoveRefsToVehicle(ent); }
void BlowUpCar_(CEntity *ent) { CAutomobile::BlowUpCar(ent); } void BlowUpCar_(CEntity *ent) { CAutomobile::BlowUpCar(ent); }
bool SetUpWheelColModel_(CColModel *colModel) { CAutomobile::SetUpWheelColModel(colModel); } bool SetUpWheelColModel_(CColModel *colModel) { return CAutomobile::SetUpWheelColModel(colModel); }
void BurstTyre_(uint8 tyre) { CAutomobile::BurstTyre(tyre); } void BurstTyre_(uint8 tyre) { CAutomobile::BurstTyre(tyre); }
bool IsRoomForPedToLeaveCar_(uint32 door, CVector *pos) { return CAutomobile::IsRoomForPedToLeaveCar(door, pos); } bool IsRoomForPedToLeaveCar_(uint32 door, CVector *pos) { return CAutomobile::IsRoomForPedToLeaveCar(door, pos); }
float GetHeightAboveRoad_(void) { return CAutomobile::GetHeightAboveRoad(); } float GetHeightAboveRoad_(void) { return CAutomobile::GetHeightAboveRoad(); }
@ -303,6 +335,7 @@ STARTPATCHES
InjectHook(0x52EFD0, &CAutomobile_::IsDoorClosed_, PATCH_JUMP); InjectHook(0x52EFD0, &CAutomobile_::IsDoorClosed_, PATCH_JUMP);
InjectHook(0x52F000, &CAutomobile_::IsDoorMissing_, PATCH_JUMP); InjectHook(0x52F000, &CAutomobile_::IsDoorMissing_, PATCH_JUMP);
InjectHook(0x53BF40, &CAutomobile_::RemoveRefsToVehicle_, PATCH_JUMP); InjectHook(0x53BF40, &CAutomobile_::RemoveRefsToVehicle_, PATCH_JUMP);
InjectHook(0x53BF70, &CAutomobile_::SetUpWheelColModel_, PATCH_JUMP);
InjectHook(0x437690, &CAutomobile_::GetHeightAboveRoad_, PATCH_JUMP); InjectHook(0x437690, &CAutomobile_::GetHeightAboveRoad_, PATCH_JUMP);
InjectHook(0x5301A0, &CAutomobile::SetPanelDamage, PATCH_JUMP); InjectHook(0x5301A0, &CAutomobile::SetPanelDamage, PATCH_JUMP);
InjectHook(0x530120, &CAutomobile::SetBumperDamage, PATCH_JUMP); InjectHook(0x530120, &CAutomobile::SetBumperDamage, PATCH_JUMP);

View file

@ -88,6 +88,14 @@ enum eLights
VEHLIGHT_REAR_RIGHT, VEHLIGHT_REAR_RIGHT,
}; };
enum
{
CAR_PIECE_WHEEL_LF = 13,
CAR_PIECE_WHEEL_LR,
CAR_PIECE_WHEEL_RF,
CAR_PIECE_WHEEL_RR,
};
class CVehicle : public CPhysical class CVehicle : public CPhysical
{ {
public: public:
@ -250,3 +258,18 @@ static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error");
static_assert(offsetof(CVehicle, m_pCurSurface) == 0x1E0, "CVehicle: error"); static_assert(offsetof(CVehicle, m_pCurSurface) == 0x1E0, "CVehicle: error");
static_assert(offsetof(CVehicle, m_nAlarmState) == 0x1A0, "CVehicle: error"); static_assert(offsetof(CVehicle, m_nAlarmState) == 0x1A0, "CVehicle: error");
static_assert(offsetof(CVehicle, m_nLastWeaponDamage) == 0x228, "CVehicle: error"); static_assert(offsetof(CVehicle, m_nLastWeaponDamage) == 0x228, "CVehicle: error");
inline uint8 GetVehDoorFlag(int32 carnode) {
switch (carnode) {
case CAR_DOOR_LF:
return 1;
case CAR_DOOR_LR:
return 2;
case CAR_DOOR_RF:
return 4;
case CAR_DOOR_RR:
return 8;
default:
return 0;
}
}