summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormajestic <majesticcoding@gmail.com>2021-05-18 00:18:46 +0200
committerSergeanur <s.anureev@yandex.ua>2021-06-24 20:44:40 +0200
commitf34365dfc0fe2e92ffdc89bfc06e44984e3a0e69 (patch)
tree6096ed1bff9a294696e91114313374743d636be4
parentUse bool8 in audio code (diff)
downloadre3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.tar
re3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.tar.gz
re3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.tar.bz2
re3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.tar.lz
re3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.tar.xz
re3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.tar.zst
re3-f34365dfc0fe2e92ffdc89bfc06e44984e3a0e69.zip
-rw-r--r--src/peds/PedAI.cpp105
1 files changed, 97 insertions, 8 deletions
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index 42ca1a72..040fffd9 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -4645,13 +4645,97 @@ CPed::ExitCar(void)
CVector
CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component)
{
- CVector vehDoorPos = GetPositionToOpenCarDoor(veh, component, 1.0f);
+ CVector doorPos;
+ CVector vehDoorOffset;
+ CVehicleModelInfo* vehModel = veh->GetModelInfo();
-/*
- // Unused
- vehDoorPosWithoutOffset = veh->GetMatrix() * localVehDoorPos;
-*/
- return vehDoorPos;
+ if (veh->IsBike()) {
+ CBike* bike = (CBike*)veh;
+
+ if (component == CAR_WINDSCREEN) {
+ doorPos = vehModel->GetFrontSeatPosn();
+ return bike->GetMatrix() * (doorPos +
+ CVector(-vecPedBikeKickAnimOffset.x, vecPedBikeKickAnimOffset.y, -vecPedBikeKickAnimOffset.z));
+ } else {
+ switch (bike->m_bikeAnimType) {
+ case ASSOCGRP_BIKE_VESPA:
+ vehDoorOffset = vecPedVespaBikeJumpRhsAnimOffset;
+ break;
+ case ASSOCGRP_BIKE_HARLEY:
+ vehDoorOffset = vecPedHarleyBikeJumpRhsAnimOffset;
+ break;
+ case ASSOCGRP_BIKE_DIRT:
+ vehDoorOffset = vecPedDirtBikeJumpRhsAnimOffset;
+ break;
+ default:
+ vehDoorOffset = vecPedStdBikeJumpRhsAnimOffset;
+ break;
+ }
+ }
+
+ doorPos = vehModel->GetFrontSeatPosn();
+ if (component == CAR_DOOR_LR || component == CAR_DOOR_RR) {
+ doorPos = vehModel->m_positions[CAR_POS_BACKSEAT];
+ }
+
+ if (component == CAR_DOOR_LR || component == CAR_DOOR_LF) {
+ vehDoorOffset.x *= -1.f;
+ }
+
+ CVector correctedPos;
+ bike->GetCorrectedWorldDoorPosition(correctedPos, vehDoorOffset, doorPos);
+ return correctedPos;
+ } else {
+ float seatOffset;
+ if (veh->bIsVan && (component == CAR_DOOR_LR || component == CAR_DOOR_RR)) {
+ seatOffset = 0.0f;
+ vehDoorOffset = vecPedVanRearDoorAnimOffset;
+ } else {
+ seatOffset = veh->pHandling->fSeatOffsetDistance;
+ if (veh->bLowVehicle) {
+ vehDoorOffset = vecPedCarDoorLoAnimOffset;
+ } else {
+ vehDoorOffset = vecPedCarDoorAnimOffset;
+ }
+ }
+
+ switch (component) {
+ case CAR_DOOR_RF:
+ doorPos = vehModel->GetFrontSeatPosn();
+ doorPos.x += seatOffset;
+ vehDoorOffset.x = -vehDoorOffset.x;
+ break;
+
+ case CAR_DOOR_RR:
+ doorPos = vehModel->m_positions[CAR_POS_BACKSEAT];
+ doorPos.x += seatOffset;
+ vehDoorOffset.x = -vehDoorOffset.x;
+ break;
+
+ case CAR_DOOR_LF:
+ doorPos = vehModel->GetFrontSeatPosn();
+ doorPos.x += seatOffset;
+ doorPos.x = -doorPos.x;
+ break;
+
+ case CAR_DOOR_LR:
+ doorPos = vehModel->m_positions[CAR_POS_BACKSEAT];
+ doorPos.x += seatOffset;
+ doorPos.x = -doorPos.x;
+ break;
+
+ default:
+ doorPos = vehModel->GetFrontSeatPosn();
+ vehDoorOffset = CVector(0.0f, 0.0f, 0.0f);
+ break;
+ }
+
+ CVector diffVec = doorPos - vehDoorOffset;
+ return Multiply3x3(veh->GetMatrix(), diffVec) + veh->GetPosition();
+
+ //unused
+ //doorPos = Multiply3x3(veh->GetMatrix(), doorPos) + veh->GetMatrix();
+ }
}
void
@@ -5103,7 +5187,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
break;
}
} else {
- draggedOutOffset = vecPedDraggedOutCarAnimOffset;
+ draggedOutOffset = CVector(vecPedDraggedOutCarAnimOffset.x, vecPedDraggedOutCarAnimOffset.y, 0.0f);
}
if (ped->m_vehDoor == CAR_DOOR_RF || ped->m_vehDoor == CAR_DOOR_RR)
draggedOutOffset.x = -draggedOutOffset.x;
@@ -5114,7 +5198,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
ped->SetPosition(posAfterBeingDragged);
- if (ped->m_pMyVehicle && !ped->m_pMyVehicle->IsBike() && !ped->m_pMyVehicle->IsRoomForPedToLeaveCar(ped->m_vehDoor, &vecPedDraggedOutCarAnimOffset)) {
+ if (ped->m_pMyVehicle && !ped->m_pMyVehicle->IsBike() && !ped->m_pMyVehicle->IsRoomForPedToLeaveCar(ped->m_vehDoor, &draggedOutOffset)) {
ped->PositionPedOutOfCollision();
}
@@ -5729,7 +5813,12 @@ CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset)
doorPos = vehModel->GetFrontSeatPosn();
if (component == CAR_WINDSCREEN) {
+#ifdef FIX_BUGS
+ return bike->GetMatrix() * (doorPos +
+ CVector(-vecPedBikeKickAnimOffset.x, vecPedBikeKickAnimOffset.y, -vecPedBikeKickAnimOffset.z));
+#else
return bike->GetMatrix() * (doorPos + vecPedBikeKickAnimOffset);
+#endif
} else {
switch (bike->m_bikeAnimType) {
case ASSOCGRP_BIKE_VESPA: