summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-07-08 17:07:34 +0200
committeraap <aap@papnet.eu>2019-07-08 17:07:34 +0200
commitedf5ac2626ce17b74037281aa3c9730902b4b1d4 (patch)
treedd3a4838a06a887af9e01d43d70d4c6a9307e24c /src/vehicles
parentcleaned up patching of virtual functions; started CAutomobile (diff)
downloadre3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.tar
re3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.tar.gz
re3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.tar.bz2
re3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.tar.lz
re3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.tar.xz
re3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.tar.zst
re3-edf5ac2626ce17b74037281aa3c9730902b4b1d4.zip
Diffstat (limited to '')
-rw-r--r--src/vehicles/Automobile.cpp39
-rw-r--r--src/vehicles/Vehicle.h23
2 files changed, 59 insertions, 3 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 23fa8ba0..c06c958c 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "VisibilityPlugins.h"
+#include "SurfaceTable.h"
#include "HandlingMgr.h"
#include "Automobile.h"
@@ -55,7 +56,7 @@ CAutomobile::SetComponentRotation(int32 component, CVector rotation)
mat.SetRotateX(DEGTORAD(rotation.x));
mat.SetRotateY(DEGTORAD(rotation.y));
mat.SetRotateZ(DEGTORAD(rotation.z));
- *mat.GetPosition() += pos;
+ mat.GetPosition() += pos;
mat.UpdateRW();
}
@@ -106,7 +107,38 @@ CAutomobile::RemoveRefsToVehicle(CEntity *ent)
}
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 bool CAutomobile::IsRoomForPedToLeaveCar(uint32, CVector *) { EAXJMP(0x53C5B0); }
@@ -285,7 +317,7 @@ public:
bool IsDoorMissing_(eDoors door) { return CAutomobile::IsDoorMissing(door); }
void RemoveRefsToVehicle_(CEntity *ent) { CAutomobile::RemoveRefsToVehicle(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); }
bool IsRoomForPedToLeaveCar_(uint32 door, CVector *pos) { return CAutomobile::IsRoomForPedToLeaveCar(door, pos); }
float GetHeightAboveRoad_(void) { return CAutomobile::GetHeightAboveRoad(); }
@@ -303,6 +335,7 @@ STARTPATCHES
InjectHook(0x52EFD0, &CAutomobile_::IsDoorClosed_, PATCH_JUMP);
InjectHook(0x52F000, &CAutomobile_::IsDoorMissing_, PATCH_JUMP);
InjectHook(0x53BF40, &CAutomobile_::RemoveRefsToVehicle_, PATCH_JUMP);
+ InjectHook(0x53BF70, &CAutomobile_::SetUpWheelColModel_, PATCH_JUMP);
InjectHook(0x437690, &CAutomobile_::GetHeightAboveRoad_, PATCH_JUMP);
InjectHook(0x5301A0, &CAutomobile::SetPanelDamage, PATCH_JUMP);
InjectHook(0x530120, &CAutomobile::SetBumperDamage, PATCH_JUMP);
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 0f9003db..1e70d171 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -88,6 +88,14 @@ enum eLights
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
{
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_nAlarmState) == 0x1A0, "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;
+ }
+}