some fixes for CPed

This commit is contained in:
majestic 2021-05-17 15:18:46 -07:00 committed by Sergeanur
parent 5bcdb933a7
commit 42e655b4cc

View File

@ -4600,13 +4600,97 @@ CPed::ExitCar(void)
CVector CVector
CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component) CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component)
{ {
CVector vehDoorPos = GetPositionToOpenCarDoor(veh, component, 1.0f); CVector doorPos;
CVector vehDoorOffset;
CVehicleModelInfo* vehModel = veh->GetModelInfo();
/* if (veh->IsBike()) {
// Unused CBike* bike = (CBike*)veh;
vehDoorPosWithoutOffset = veh->GetMatrix() * localVehDoorPos;
*/ if (component == CAR_WINDSCREEN) {
return vehDoorPos; 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 void
@ -5058,7 +5142,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
break; break;
} }
} else { } else {
draggedOutOffset = vecPedDraggedOutCarAnimOffset; draggedOutOffset = CVector(vecPedDraggedOutCarAnimOffset.x, vecPedDraggedOutCarAnimOffset.y, 0.0f);
} }
if (ped->m_vehDoor == CAR_DOOR_RF || ped->m_vehDoor == CAR_DOOR_RR) if (ped->m_vehDoor == CAR_DOOR_RF || ped->m_vehDoor == CAR_DOOR_RR)
draggedOutOffset.x = -draggedOutOffset.x; draggedOutOffset.x = -draggedOutOffset.x;
@ -5069,7 +5153,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
ped->SetPosition(posAfterBeingDragged); 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(); ped->PositionPedOutOfCollision();
} }
@ -5684,7 +5768,12 @@ CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset)
doorPos = vehModel->GetFrontSeatPosn(); doorPos = vehModel->GetFrontSeatPosn();
if (component == CAR_WINDSCREEN) { if (component == CAR_WINDSCREEN) {
#ifdef FIX_BUGS
return bike->GetMatrix() * (doorPos +
CVector(-vecPedBikeKickAnimOffset.x, vecPedBikeKickAnimOffset.y, -vecPedBikeKickAnimOffset.z));
#else
return bike->GetMatrix() * (doorPos + vecPedBikeKickAnimOffset); return bike->GetMatrix() * (doorPos + vecPedBikeKickAnimOffset);
#endif
} else { } else {
switch (bike->m_bikeAnimType) { switch (bike->m_bikeAnimType) {
case ASSOCGRP_BIKE_VESPA: case ASSOCGRP_BIKE_VESPA: