Trace NANS in vector.x

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2025-01-14 23:16:36 +02:00
parent 2db1ddf5b7
commit 47a42a876d
59 changed files with 562 additions and 407 deletions

View File

@ -140,6 +140,7 @@
"svd": "cpp",
"print": "cpp",
"strstream": "cpp",
"regex": "cpp"
"regex": "cpp",
"__availability": "cpp"
}
}

View File

@ -96,9 +96,10 @@ OBJS_O3 =
# ../vendor/librw/src/base.o \
# ../src/renderer/Shadows.o
OBJS_NO_FAST_MATH = \
../src/core/Cam.o \
../src/core/Camera.o
OBJS_NO_FAST_MATH =
# \
# ../src/core/Cam.o \
# ../src/core/Camera.o
KOS_CPPFLAGS += -mfsrra -mfsca -fbuiltin #-ffast-math -ffp-contract=fast \
@ -111,7 +112,7 @@ endif
DEPS = $(OBJS:.o=.d) $(OBJS_TEXCONV:.o:.d)
CXXFLAGS += $(if $(WITH_32MB),-O3,-Os) \
CXXFLAGS += $(if $(WITH_32MB),-O3,-O0) \
$(if $(WITH_IDE),-DWITH_IDE) \
$(if $(WITH_PROF),-DWITH_PROF=\"$(WITH_PROF)\") \
-MMD -MP -ffunction-sections -fdata-sections \

View File

@ -140,7 +140,7 @@ CAnimBlendNode::GetCurrentTranslation(CVector &trans, float weight)
float blend = association->GetBlendAmount(weight);
if(blend > 0.0f){
auto kfAdt = sequence->GetDeltaTime(frameA);
float t = (kfAdt - remainingTime)/kfAdt;
float t = kfAdt == 0.0f ? 0.0f : (kfAdt - remainingTime)/kfAdt;
if(sequence->type & CAnimBlendSequence::KF_TRANS){
auto kfAt = sequence->GetTranslation(frameA);
auto kfBt = sequence->GetTranslation(frameB);

View File

@ -93,17 +93,17 @@ void CBridge::Update()
// Move bridge part
if (liftHeight != OldLift)
{
pLiftPart->GetMatrix().GetPosition().z = DefaultZLiftPart + liftHeight;
pLiftPart->GetMatrix().UpdateRW();
pLiftPart->GetMatrix()->GetPosition().z = DefaultZLiftPart + liftHeight;
pLiftPart->GetMatrix()->UpdateRW();
pLiftPart->UpdateRwFrame();
if (pLiftRoad)
{
pLiftRoad->GetMatrix().GetPosition().z = DefaultZLiftRoad + liftHeight;
pLiftRoad->GetMatrix().UpdateRW();
pLiftRoad->GetMatrix()->GetPosition().z = DefaultZLiftRoad + liftHeight;
pLiftRoad->GetMatrix()->UpdateRW();
pLiftRoad->UpdateRwFrame();
}
pWeight->GetMatrix().GetPosition().z = DefaultZLiftWeight - liftHeight;
pWeight->GetMatrix().UpdateRW();
pWeight->GetMatrix()->GetPosition().z = DefaultZLiftWeight - liftHeight;
pWeight->GetMatrix()->UpdateRW();
pWeight->UpdateRwFrame();
OldLift = liftHeight;

View File

@ -2040,7 +2040,7 @@ void CCarCtrl::DragCarToPoint(CVehicle* pVehicle, CVector* pPoint)
pVehicle->GetForward() = CVector(-cosZ * pVehicle->GetRight().y, cosZ * pVehicle->GetRight().x, sinZ);
pVehicle->GetUp() = CrossProduct(pVehicle->GetRight(), pVehicle->GetForward());
pVehicle->SetPosition((CVector(midPos.x, midPos.y, actualBehindZ) + CVector(posTarget.x, posTarget.y, actualAheadZ)) / 2);
pVehicle->GetMatrix().GetPosition().z += pVehicle->GetHeightAboveRoad();
pVehicle->GetMatrix()->GetPosition().z += pVehicle->GetHeightAboveRoad();
}
float CCarCtrl::FindSpeedMultiplier(float angleChange, float minAngle, float maxAngle, float coef)

View File

@ -1195,7 +1195,7 @@ bool CGarage::IsEntityEntirelyInside(CEntity * pEntity)
return false;
CColModel* pColModel = pEntity->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pEntity->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x - radius < m_fX1 || pos.x + radius > m_fX2 ||
pos.y - radius < m_fY1 || pos.y + radius > m_fY2)
@ -1212,7 +1212,7 @@ bool CGarage::IsEntityEntirelyInside3D(CEntity * pEntity, float fMargin)
return false;
CColModel* pColModel = pEntity->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pEntity->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius < m_fX1 - fMargin || pos.x - radius > m_fX2 + fMargin ||
pos.y + radius < m_fY1 - fMargin || pos.y - radius > m_fY2 + fMargin ||
@ -1229,7 +1229,7 @@ bool CGarage::IsEntityEntirelyOutside(CEntity * pEntity, float fMargin)
return false;
CColModel* pColModel = pEntity->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pEntity->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius > m_fX1 - fMargin && pos.x - radius < m_fX2 + fMargin &&
pos.y + radius > m_fY1 - fMargin && pos.y - radius < m_fY2 + fMargin)
@ -1261,7 +1261,7 @@ bool CGarage::IsEntityTouching3D(CEntity * pEntity)
return false;
CColModel* pColModel = pEntity->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pEntity->GetMatrix().r() * pColModel->spheres[i].center;
radius = pColModel->spheres[i].radius;
if (pos.x + radius > m_fX1 && pos.x - radius < m_fX2 &&
pos.y + radius > m_fY1 && pos.y - radius < m_fY2 &&
@ -1275,7 +1275,7 @@ bool CGarage::EntityHasASphereWayOutsideGarage(CEntity * pEntity, float fMargin)
{
CColModel* pColModel = pEntity->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pEntity->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius + fMargin < m_fX1 || pos.x - radius - fMargin > m_fX2 ||
pos.y + radius + fMargin < m_fY1 || pos.y - radius - fMargin > m_fY2 ||
@ -1296,7 +1296,7 @@ bool CGarage::IsAnyOtherCarTouchingGarage(CVehicle * pException)
continue;
CColModel* pColModel = pVehicle->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pVehicle->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius > m_fX1 && pos.x - radius < m_fX2 &&
pos.y + radius > m_fY1 && pos.y - radius < m_fY2 &&
@ -1318,7 +1318,7 @@ bool CGarage::IsAnyOtherPedTouchingGarage(CPed * pException)
continue;
CColModel* pColModel = pException->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pPed->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pPed->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius > m_fX1 && pos.x - radius < m_fX2 &&
pos.y + radius > m_fY1 && pos.y - radius < m_fY2 &&
@ -1340,7 +1340,7 @@ bool CGarage::IsAnyCarBlockingDoor()
continue;
CColModel* pColModel = pVehicle->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pVehicle->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius < m_fX1 || pos.x - radius > m_fX2 ||
pos.y + radius < m_fY1 || pos.y - radius > m_fY2 ||
@ -1481,17 +1481,17 @@ void CGarage::UpdateDoorsHeight()
{
RefreshDoorPointers(false);
if (m_pDoor1) {
m_pDoor1->GetMatrix().GetPosition().z = m_fDoorPos + m_fDoor1Z;
m_pDoor1->GetMatrix()->GetPosition().z = m_fDoorPos + m_fDoor1Z;
if (m_bRotatedDoor)
BuildRotatedDoorMatrix(m_pDoor1, m_fDoorPos / m_fDoorHeight);
m_pDoor1->GetMatrix().UpdateRW();
m_pDoor1->GetMatrix()->UpdateRW();
m_pDoor1->UpdateRwFrame();
}
if (m_pDoor2) {
m_pDoor2->GetMatrix().GetPosition().z = m_fDoorPos + m_fDoor2Z;
m_pDoor2->GetMatrix()->GetPosition().z = m_fDoorPos + m_fDoor2Z;
if (m_bRotatedDoor)
BuildRotatedDoorMatrix(m_pDoor2, m_fDoorPos / m_fDoorHeight);
m_pDoor2->GetMatrix().UpdateRW();
m_pDoor2->GetMatrix()->UpdateRW();
m_pDoor2->UpdateRwFrame();
}
}
@ -1507,26 +1507,26 @@ void CGarage::BuildRotatedDoorMatrix(CEntity * pDoor, float fPosition)
void CGarage::UpdateCrusherAngle()
{
RefreshDoorPointers(false);
m_pDoor2->GetMatrix().SetRotateXOnly(TWOPI - m_fDoorPos);
m_pDoor2->GetMatrix().UpdateRW();
m_pDoor2->GetMatrix()->SetRotateXOnly(TWOPI - m_fDoorPos);
m_pDoor2->GetMatrix()->UpdateRW();
m_pDoor2->UpdateRwFrame();
}
void CGarage::UpdateCrusherShake(float X, float Y)
{
RefreshDoorPointers(false);
m_pDoor1->GetMatrix().GetPosition().x += X;
m_pDoor1->GetMatrix().GetPosition().y += Y;
m_pDoor1->GetMatrix().UpdateRW();
m_pDoor1->GetMatrix()->GetPosition().x += X;
m_pDoor1->GetMatrix()->GetPosition().y += Y;
m_pDoor1->GetMatrix()->UpdateRW();
m_pDoor1->UpdateRwFrame();
m_pDoor1->GetMatrix().GetPosition().x -= X;
m_pDoor1->GetMatrix().GetPosition().y -= Y;
m_pDoor2->GetMatrix().GetPosition().x += X;
m_pDoor2->GetMatrix().GetPosition().y += Y;
m_pDoor2->GetMatrix().UpdateRW();
m_pDoor1->GetMatrix()->GetPosition().x -= X;
m_pDoor1->GetMatrix()->GetPosition().y -= Y;
m_pDoor2->GetMatrix()->GetPosition().x += X;
m_pDoor2->GetMatrix()->GetPosition().y += Y;
m_pDoor2->GetMatrix()->UpdateRW();
m_pDoor2->UpdateRwFrame();
m_pDoor2->GetMatrix().GetPosition().x -= X;
m_pDoor2->GetMatrix().GetPosition().y -= Y;
m_pDoor2->GetMatrix()->GetPosition().x -= X;
m_pDoor2->GetMatrix()->GetPosition().y -= Y;
}
void CGarage::RefreshDoorPointers(bool bCreate)
@ -2065,7 +2065,7 @@ void CGarage::TidyUpGarageClose()
if (m_eGarageState != GS_FULLYCLOSED) {
CColModel* pColModel = pVehicle->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pVehicle->GetMatrix().r() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (pos.x + radius < m_fX1 || pos.x - radius > m_fX2 ||
pos.y + radius < m_fY1 || pos.y - radius > m_fY2 ||
@ -2158,12 +2158,12 @@ void CGarage::CenterCarInGarage(CVehicle* pVehicle)
float offsetZ = pos.z - pos.z;
float distance = CVector(offsetX, offsetY, offsetZ).Magnitude();
if (distance < RESPRAY_CENTERING_COEFFICIENT) {
pVehicle->GetMatrix().GetPosition().x = GetGarageCenterX();
pVehicle->GetMatrix().GetPosition().y = GetGarageCenterY();
pVehicle->GetMatrix()->GetPosition().x = GetGarageCenterX();
pVehicle->GetMatrix()->GetPosition().y = GetGarageCenterY();
}
else {
pVehicle->GetMatrix().GetPosition().x += offsetX * RESPRAY_CENTERING_COEFFICIENT / distance;
pVehicle->GetMatrix().GetPosition().y += offsetY * RESPRAY_CENTERING_COEFFICIENT / distance;
pVehicle->GetMatrix()->GetPosition().x += offsetX * RESPRAY_CENTERING_COEFFICIENT / distance;
pVehicle->GetMatrix()->GetPosition().y += offsetY * RESPRAY_CENTERING_COEFFICIENT / distance;
}
if (!IsEntityEntirelyInside3D(pVehicle, 0.1f))
pVehicle->SetPosition(pos);
@ -2277,21 +2277,21 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
default:
aGarages[i].RefreshDoorPointers(true);
if (aGarages[i].m_pDoor1) {
aGarages[i].m_pDoor1->GetMatrix().GetPosition().z = aGarages[i].m_fDoor1Z;
aGarages[i].m_pDoor1->GetMatrix()->GetPosition().z = aGarages[i].m_fDoor1Z;
if (aGarages[i].m_pDoor1->IsObject())
((CObject*)aGarages[i].m_pDoor1)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor1Z;
if (aGarages[i].m_bRotatedDoor)
aGarages[i].BuildRotatedDoorMatrix(aGarages[i].m_pDoor1, 0.0f);
aGarages[i].m_pDoor1->GetMatrix().UpdateRW();
aGarages[i].m_pDoor1->GetMatrix()->UpdateRW();
aGarages[i].m_pDoor1->UpdateRwFrame();
}
if (aGarages[i].m_pDoor2) {
aGarages[i].m_pDoor2->GetMatrix().GetPosition().z = aGarages[i].m_fDoor2Z;
aGarages[i].m_pDoor2->GetMatrix()->GetPosition().z = aGarages[i].m_fDoor2Z;
if (aGarages[i].m_pDoor2->IsObject())
((CObject*)aGarages[i].m_pDoor2)->m_objectMatrix.GetPosition().z = aGarages[i].m_fDoor2Z;
if (aGarages[i].m_bRotatedDoor)
aGarages[i].BuildRotatedDoorMatrix(aGarages[i].m_pDoor2, 0.0f);
aGarages[i].m_pDoor2->GetMatrix().UpdateRW();
aGarages[i].m_pDoor2->GetMatrix()->UpdateRW();
aGarages[i].m_pDoor2->UpdateRwFrame();
}
}
@ -2422,29 +2422,29 @@ void CGarages::Load(uint8* buf, uint32 size)
SkipSaveBuf(buf, 2);
ReadSaveBuf(&aGarages[i].m_nTargetModelIndex, buf);
SkipSaveBuf(buf, 4 + 4);
ReadSaveBuf(&aGarages[i].m_bDoor1PoolIndex, buf);
ReadSaveBuf(&aGarages[i].m_bDoor2PoolIndex, buf);
ReadSaveBuf(&aGarages[i].m_bDoor1IsDummy, buf);
ReadSaveBuf(&aGarages[i].m_bDoor2IsDummy, buf);
ReadSaveBuf(&aGarages[i].m_bRecreateDoorOnNextRefresh, buf);
ReadSaveBuf(&aGarages[i].m_bRotatedDoor, buf);
ReadSaveBuf(&aGarages[i].m_bDoor1PoolIndex, buf);
ReadSaveBuf(&aGarages[i].m_bDoor2PoolIndex, buf);
ReadSaveBuf(&aGarages[i].m_bDoor1IsDummy, buf);
ReadSaveBuf(&aGarages[i].m_bDoor2IsDummy, buf);
ReadSaveBuf(&aGarages[i].m_bRecreateDoorOnNextRefresh, buf);
ReadSaveBuf(&aGarages[i].m_bRotatedDoor, buf);
ReadSaveBuf(&aGarages[i].m_bCameraFollowsPlayer, buf);
SkipSaveBuf(buf, 1);
ReadSaveBuf(&aGarages[i].m_fX1, buf);
ReadSaveBuf(&aGarages[i].m_fX2, buf);
ReadSaveBuf(&aGarages[i].m_fY1, buf);
ReadSaveBuf(&aGarages[i].m_fY2, buf);
ReadSaveBuf(&aGarages[i].m_fZ1, buf);
ReadSaveBuf(&aGarages[i].m_fZ2, buf);
ReadSaveBuf(&aGarages[i].m_fDoorPos, buf);
ReadSaveBuf(&aGarages[i].m_fDoorHeight, buf);
ReadSaveBuf(&aGarages[i].m_fDoor1X, buf);
ReadSaveBuf(&aGarages[i].m_fDoor1Y, buf);
ReadSaveBuf(&aGarages[i].m_fDoor2X, buf);
ReadSaveBuf(&aGarages[i].m_fDoor2Y, buf);
ReadSaveBuf(&aGarages[i].m_fDoor1Z, buf);
ReadSaveBuf(&aGarages[i].m_fDoor2Z, buf);
ReadSaveBuf(&aGarages[i].m_nTimeToStartAction, buf);
ReadSaveBuf(&aGarages[i].m_fX1, buf);
ReadSaveBuf(&aGarages[i].m_fX2, buf);
ReadSaveBuf(&aGarages[i].m_fY1, buf);
ReadSaveBuf(&aGarages[i].m_fY2, buf);
ReadSaveBuf(&aGarages[i].m_fZ1, buf);
ReadSaveBuf(&aGarages[i].m_fZ2, buf);
ReadSaveBuf(&aGarages[i].m_fDoorPos, buf);
ReadSaveBuf(&aGarages[i].m_fDoorHeight, buf);
ReadSaveBuf(&aGarages[i].m_fDoor1X, buf);
ReadSaveBuf(&aGarages[i].m_fDoor1Y, buf);
ReadSaveBuf(&aGarages[i].m_fDoor2X, buf);
ReadSaveBuf(&aGarages[i].m_fDoor2Y, buf);
ReadSaveBuf(&aGarages[i].m_fDoor1Z, buf);
ReadSaveBuf(&aGarages[i].m_fDoor2Z, buf);
ReadSaveBuf(&aGarages[i].m_nTimeToStartAction, buf);
ReadSaveBuf(&aGarages[i].m_bCollectedCarsState, buf);
SkipSaveBuf(buf, 3 + 4 + 4);
SkipSaveBuf(buf, sizeof(aGarages[i].m_sStoredCar));

View File

@ -201,8 +201,8 @@ CPedPath::AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *p
const float fBoundMaxY = boundingBox.max.y + 0.3f;
const float fBoundMinY = boundingBox.min.y - 0.3f;
const float fBoundMaxX = boundingBox.max.x + 0.3f;
const float fDistanceX = pPosition->x - pEntity->GetMatrix().GetPosition().x;
const float fDistanceY = pPosition->y - pEntity->GetMatrix().GetPosition().y;
const float fDistanceX = pPosition->x - pEntity->GetMatrix()->GetPosition().x;
const float fDistanceY = pPosition->y - pEntity->GetMatrix()->GetPosition().y;
const float fBoundRadius = pEntity->GetBoundRadius();
CVector vecBoundCentre;
pEntity->GetBoundCentre(vecBoundCentre);
@ -216,8 +216,8 @@ CPedPath::AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *p
if (!pathNodes[x][y].bBlockade) {
const float pointY = y * 0.7f + fDistanceY;
CVector2D point(pointX, pointY);
if (fBoundMaxX > Abs(DotProduct2D(point, pEntity->GetMatrix().GetRight()))) {
float fDotProduct = DotProduct2D(point, pEntity->GetMatrix().GetForward());
if (fBoundMaxX > Abs(DotProduct2D(point, pEntity->GetMatrix()->GetRight()))) {
float fDotProduct = DotProduct2D(point, pEntity->GetMatrix()->GetForward());
if (fBoundMaxY > fDotProduct && fBoundMinY < fDotProduct)
pathNodes[x][y].bBlockade = true;
}
@ -334,7 +334,7 @@ CPathFind::CalcNodeCoors(int16 x, int16 y, int16 z, int32 id, CVector *out)
pos.x = x / 16.0f;
pos.y = y / 16.0f;
pos.z = z / 16.0f;
*out = m_mapObjects[id]->GetMatrix() * pos;
*out = m_mapObjects[id]->GetMatrix().r() * pos;
}
bool

View File

@ -107,7 +107,7 @@ CPhoneInfo::Update(void)
} else {
m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f;
}
m_aPhones[phoneId].m_pEntity->GetMatrix().UpdateRW();
m_aPhones[phoneId].m_pEntity->GetMatrix()->UpdateRW();
m_aPhones[phoneId].m_pEntity->UpdateRwFrame();
if (notInCar && !bPickingUpPhone && player->IsPedInControl()) {
CVector2D distToPhone = playerPos - m_aPhones[phoneId].m_vecPos;
@ -146,7 +146,7 @@ CPhoneInfo::Update(void)
} else {
m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f;
}
m_aPhones[phoneId].m_pEntity->GetMatrix().UpdateRW();
m_aPhones[phoneId].m_pEntity->GetMatrix()->UpdateRW();
m_aPhones[phoneId].m_pEntity->UpdateRwFrame();
break;
default:

View File

@ -88,7 +88,7 @@ CPickup::GiveUsAPickUpObject(int32 handle)
object->ObjectCreatedBy = MISSION_OBJECT;
object->SetPosition(m_vecPos);
object->SetOrientation(0.0f, 0.0f, -HALFPI);
object->GetMatrix().UpdateRW();
object->GetMatrix()->UpdateRW();
object->UpdateRwFrame();
object->bAffectedByGravity = false;
@ -300,9 +300,9 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
case PICKUP_NAUTICAL_MINE_INACTIVE:
{
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
m_pObject->GetMatrix().GetPosition().z = waterLevel + 0.6f;
m_pObject->GetMatrix()->GetPosition().z = waterLevel + 0.6f;
m_pObject->GetMatrix().UpdateRW();
m_pObject->GetMatrix()->UpdateRW();
m_pObject->UpdateRwFrame();
bool touched = false;
@ -324,9 +324,9 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
case PICKUP_NAUTICAL_MINE_ARMED:
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
m_pObject->GetMatrix().GetPosition().z = waterLevel + 0.6f;
m_pObject->GetMatrix()->GetPosition().z = waterLevel + 0.6f;
m_pObject->GetMatrix().UpdateRW();
m_pObject->GetMatrix()->UpdateRW();
m_pObject->UpdateRwFrame();
// no break here
case PICKUP_MINE_ARMED:
@ -356,18 +356,18 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
case PICKUP_FLOATINGPACKAGE:
m_pObject->m_vecMoveSpeed.z -= 0.01f * CTimer::GetTimeStep();
m_pObject->GetMatrix().GetPosition() += m_pObject->GetMoveSpeed() * CTimer::GetTimeStep();
m_pObject->GetMatrix()->GetPosition() += m_pObject->GetMoveSpeed() * CTimer::GetTimeStep();
m_pObject->GetMatrix().UpdateRW();
m_pObject->GetMatrix()->UpdateRW();
m_pObject->UpdateRwFrame();
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false) && waterLevel >= m_pObject->GetPosition().z)
m_eType = PICKUP_FLOATINGPACKAGE_FLOATING;
break;
case PICKUP_FLOATINGPACKAGE_FLOATING:
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
m_pObject->GetMatrix().GetPosition().z = waterLevel;
m_pObject->GetMatrix()->GetPosition().z = waterLevel;
m_pObject->GetMatrix().UpdateRW();
m_pObject->GetMatrix()->UpdateRW();
m_pObject->UpdateRwFrame();
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 2.0f)) {
Remove();
@ -760,15 +760,15 @@ CPickups::DoPickUpEffects(CEntity *entity)
float s = Sin(angle) * aWeaponScale[colorId];
// we know from SA they were setting each field manually like this
entity->GetMatrix().rx = c;
entity->GetMatrix().ry = s;
entity->GetMatrix().rz = 0.0f;
entity->GetMatrix().fx = -s;
entity->GetMatrix().fy = c;
entity->GetMatrix().fz = 0.0f;
entity->GetMatrix().ux = 0.0f;
entity->GetMatrix().uy = 0.0f;
entity->GetMatrix().uz = aWeaponScale[colorId];
entity->GetMatrix()->rx = c;
entity->GetMatrix()->ry = s;
entity->GetMatrix()->rz = 0.0f;
entity->GetMatrix()->fx = -s;
entity->GetMatrix()->fy = c;
entity->GetMatrix()->fz = 0.0f;
entity->GetMatrix()->ux = 0.0f;
entity->GetMatrix()->uy = 0.0f;
entity->GetMatrix()->uz = aWeaponScale[colorId];
}
}
@ -788,7 +788,7 @@ CPickups::DoMineEffects(CEntity *entity)
CCoronas::RegisterCorona((uintptr)entity, red, 0, 0, 255, pos, 0.6f, 60.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
}
entity->GetMatrix().SetRotateZOnly((float)(CTimer::GetTimeInMilliseconds() & 0x3FF) * DEGTORAD(360.0f / 0x400));
entity->GetMatrix()->SetRotateZOnly((float)(CTimer::GetTimeInMilliseconds() & 0x3FF) * DEGTORAD(360.0f / 0x400));
}
void
@ -807,7 +807,7 @@ CPickups::DoMoneyEffects(CEntity *entity)
CCoronas::RegisterCorona((uintptr)entity, 0, green, 0, 255, pos, 0.4f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
}
entity->GetMatrix().SetRotateZOnly((float)(CTimer::GetTimeInMilliseconds() & 0x7FF) * DEGTORAD(360.0f / 0x800));
entity->GetMatrix()->SetRotateZOnly((float)(CTimer::GetTimeInMilliseconds() & 0x7FF) * DEGTORAD(360.0f / 0x800));
}
void
@ -826,7 +826,7 @@ CPickups::DoCollectableEffects(CEntity *entity)
CCoronas::RegisterCorona((uintptr)entity, color, color, color, 255, pos, 0.6f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
}
entity->GetMatrix().SetRotateZOnly((float)(CTimer::GetTimeInMilliseconds() & 0xFFF) * DEGTORAD(360.0f / 0x1000));
entity->GetMatrix()->SetRotateZOnly((float)(CTimer::GetTimeInMilliseconds() & 0xFFF) * DEGTORAD(360.0f / 0x1000));
}
void
@ -1193,7 +1193,7 @@ CPacManPickups::GeneratePMPickUps(CVector pos, float scrambleMult, int16 count,
obj->ObjectCreatedBy = MISSION_OBJECT;
obj->SetPosition(aPMPickUps[i].m_vecPosn);
obj->SetOrientation(0.0f, 0.0f, -HALFPI);
obj->GetMatrix().UpdateRW();
obj->GetMatrix()->UpdateRW();
obj->UpdateRwFrame();
obj->bAffectedByGravity = false;
@ -1344,7 +1344,7 @@ CPacManPickups::GeneratePMPickUpsForRace(int32 race)
obj->SetPosition(aPMPickUps[i].m_vecPosn);
obj->SetOrientation(0.0f, 0.0f, -HALFPI);
obj->GetMatrix().UpdateRW();
obj->GetMatrix()->UpdateRW();
obj->UpdateRwFrame();
obj->bAffectedByGravity = false;
@ -1392,8 +1392,8 @@ CPacManPickups::Render()
case PACMAN_RACE:
if (CSprite::CalcScreenCoors(aPMPickUps[i].m_vecPosn, &pos, &w, &h, true) && pos.z < 100.0f) {
if (aPMPickUps[i].m_pObject != nil) {
aPMPickUps[i].m_pObject->GetMatrix().SetRotateZOnly((CTimer::GetTimeInMilliseconds() % 1024) * TWOPI / 1024.0f);
aPMPickUps[i].m_pObject->GetMatrix().UpdateRW();
aPMPickUps[i].m_pObject->GetMatrix()->SetRotateZOnly((CTimer::GetTimeInMilliseconds() % 1024) * TWOPI / 1024.0f);
aPMPickUps[i].m_pObject->GetMatrix()->UpdateRW();
aPMPickUps[i].m_pObject->UpdateRwFrame();
}
float fsin = Sin((CTimer::GetTimeInMilliseconds() % 1024) * 6.28f / 1024.0f); // yes, it is 6.28f when it was TWOPI just now...

View File

@ -269,20 +269,20 @@ void CRecordDataForChase::SaveOrRetrieveCarPositions(void)
for (int i = 0; i < NUM_CHASE_CARS; i++) {
if (i != CurrentCar && CTimer::GetFrameCounter()) {
RestoreInfoForCar(pChaseCars[i], &pBaseMemForCar[i][CTimer::GetFrameCounter() / 2], false);
pChaseCars[i]->GetMatrix().UpdateRW();
pChaseCars[i]->GetMatrix()->UpdateRW();
pChaseCars[i]->UpdateRwFrame();
}
}
if (Status == STATE_PLAYBACK_BEFORE_RECORDING && CTimer::GetFrameCounter()) {
RestoreInfoForCar(pChaseCars[CurrentCar], &pBaseMemForCar[CurrentCar][CTimer::GetFrameCounter() / 2], false);
pChaseCars[CurrentCar]->GetMatrix().UpdateRW();
pChaseCars[CurrentCar]->GetMatrix()->UpdateRW();
pChaseCars[CurrentCar]->UpdateRwFrame();
}
if (CPad::GetPad(0)->GetLeftShockJustDown() && CPad::GetPad(0)->GetRightShockJustDown()) {
if (!CPad::GetPad(0)->GetRightShockJustDown()) {
pChaseCars[CurrentCar]->SetPosition(NewCoorsForRecordedCars[PositionChanges].pos);
pChaseCars[CurrentCar]->SetMoveSpeed(0.0f, 0.0f, 0.0f);
pChaseCars[CurrentCar]->GetMatrix().SetRotateZOnly(DEGTORAD(NewCoorsForRecordedCars[PositionChanges].angle));
pChaseCars[CurrentCar]->GetMatrix()->SetRotateZOnly(DEGTORAD(NewCoorsForRecordedCars[PositionChanges].angle));
++PositionChanges;
}
if (Status == STATE_PLAYBACK_BEFORE_RECORDING) {
@ -312,14 +312,14 @@ void CRecordDataForChase::SaveOrRetrieveCarPositions(void)
pChaseCars[i]->GetRight() += (tmp.GetRight() - pChaseCars[i]->GetRight()) * dp;
pChaseCars[i]->GetForward() += (tmp.GetForward() - pChaseCars[i]->GetForward()) * dp;
pChaseCars[i]->GetUp() += (tmp.GetUp() - pChaseCars[i]->GetUp()) * dp;
pChaseCars[i]->GetMatrix().GetPosition() += (tmp.GetPosition() - pChaseCars[i]->GetPosition()) * dp;
pChaseCars[i]->GetMatrix()->GetPosition() += (tmp.GetPosition() - pChaseCars[i]->GetPosition()) * dp;
}
else{
RestoreInfoForCar(pChaseCars[i], &pBaseMemForCar[i][CHASE_SCENE_FRAMES_IN_RECORDING - 1], true);
if (i == 0)
pChaseCars[i]->GetMatrix().GetPosition().z += 0.2f;
pChaseCars[i]->GetMatrix()->GetPosition().z += 0.2f;
}
pChaseCars[i]->GetMatrix().UpdateRW();
pChaseCars[i]->GetMatrix()->UpdateRW();
pChaseCars[i]->UpdateRwFrame();
pChaseCars[i]->RemoveAndAdd();
}
@ -357,7 +357,7 @@ void CRecordDataForChase::RestoreInfoForMatrix(CMatrix& matrix, CCarStateEachFra
void CRecordDataForChase::RestoreInfoForCar(CAutomobile* pCar, CCarStateEachFrame* pState, bool stop)
{
CVector oldPos = pCar->GetPosition();
RestoreInfoForMatrix(pCar->GetMatrix(), pState);
RestoreInfoForMatrix(pCar->GetMatrix().r(), pState);
pCar->SetMoveSpeed(CVector(pState->velX, pState->velY, pState->velZ) / INT16_MAX / 0.5f);
pCar->SetTurnSpeed(0.0f, 0.0f, 0.0f);
pCar->m_fSteerAngle = pState->wheel / 20.0f;
@ -412,7 +412,7 @@ void CRecordDataForChase::GiveUsACar(int32 mi, CVector pos, float angle, CAutomo
CAutomobile* pCar = new CAutomobile(mi, MISSION_VEHICLE);
pCar->SetPosition(pos);
pCar->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
pCar->GetMatrix().SetRotateZOnly(DEGTORAD(angle));
pCar->GetMatrix()->SetRotateZOnly(DEGTORAD(angle));
pCar->pDriver = nil;
pCar->m_currentColour1 = colour1;
pCar->m_currentColour2 = colour2;

View File

@ -17,7 +17,7 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin
z = car->GetDistanceFromCentreOfMassToBaseOfModel() + CWorld::FindGroundZFor3DCoord(x, y, z + 2.0f, &found);
car->GetMatrix().SetRotateZOnly(rot);
car->GetMatrix()->SetRotateZOnly(rot);
car->SetPosition(x, y, z);
car->SetStatus(STATUS_PLAYER_REMOTE);
car->bIsLocked = true;

View File

@ -505,8 +505,8 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
ped->m_fRotationDest = pp->heading * PI / 128.0f;
CMatrix ped_matrix;
pp->matrix.DecompressIntoFullMatrix(ped_matrix);
ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
ped->GetMatrix() = ped->GetMatrix().r() * CMatrix(1.0f - interpolation);
ped->GetMatrix()->GetPosition() *= (1.0f - interpolation);
ped->GetMatrix() += CMatrix(interpolation) * ped_matrix;
if (pp->vehicle_index) {
ped->m_pMyVehicle = CPools::GetVehiclePool()->GetSlot(pp->vehicle_index - 1);
@ -730,8 +730,8 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
}
CMatrix vehicle_matrix;
vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
vehicle->GetMatrix() = vehicle->GetMatrix().r() * CMatrix(1.0f - interpolation);
vehicle->GetMatrix()->GetPosition() *= (1.0f - interpolation);
vehicle->GetMatrix() += CMatrix(interpolation) * vehicle_matrix;
vehicle->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
vehicle->m_fHealth = 4 * vp->health;
@ -884,7 +884,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
else {
CPed* new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, ph->mi);
new_p->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
new_p->GetMatrix().SetUnity();
new_p->GetMatrix()->SetUnity();
CWorld::Add(new_p);
}
}
@ -910,7 +910,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
{
tGeneralPacket* pg = (tGeneralPacket*)&ptr[offset];
TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split);
TheCamera.GetMatrix().GetPosition() *= split;
TheCamera.GetMatrix()->GetPosition() *= split;
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = TheCamera.GetPosition();
@ -1046,27 +1046,27 @@ void CReplay::ProcessReplayCamera(void)
}
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);
forward.Normalise();
CVector right = CrossProduct(CVector(0.0f, 0.0f, 1.0f), forward);
right.Normalise();
CVector up = CrossProduct(forward, right);
up.Normalise();
TheCamera.GetMatrix().GetForward() = forward;
TheCamera.GetMatrix().GetUp() = up;
TheCamera.GetMatrix().GetRight() = right;
TheCamera.GetMatrix()->GetForward() = forward;
TheCamera.GetMatrix()->GetUp() = up;
TheCamera.GetMatrix()->GetRight() = right;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = TheCamera.GetMatrix().GetPosition();
pm->at = TheCamera.GetMatrix().GetForward();
pm->up = TheCamera.GetMatrix().GetUp();
pm->right = TheCamera.GetMatrix().GetRight();
pm->pos = TheCamera.GetMatrix()->GetPosition();
pm->at = TheCamera.GetMatrix()->GetForward();
pm->up = TheCamera.GetMatrix()->GetUp();
pm->right = TheCamera.GetMatrix()->GetRight();
break;
}
default:
break;
}
TheCamera.m_vecGameCamPos = TheCamera.GetMatrix().GetPosition();
TheCamera.m_vecGameCamPos = TheCamera.GetMatrix()->GetPosition();
TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
@ -1275,7 +1275,7 @@ void CReplay::RestoreStuffFromMem(void)
if ((mi == MI_AIRTRAIN || mi == MI_DEADDODO) && vehicle->m_rwObject){
CVehicleModelInfo* info = (CVehicleModelInfo*)CModelInfo::GetModelInfo(mi);
if (RwObjectGetType(vehicle->m_rwObject) == rpATOMIC){
vehicle->GetMatrix().Detach();
vehicle->GetMatrix()->Detach();
if (vehicle->m_rwObject){
if (RwObjectGetType(vehicle->m_rwObject) == rpATOMIC){
RwFrame* frame = RpAtomicGetFrame((RpAtomic*)vehicle->m_rwObject);
@ -1289,7 +1289,7 @@ void CReplay::RestoreStuffFromMem(void)
int model_id = info->m_wheelId;
if (model_id != -1){
if ((vehicle->m_rwObject = CModelInfo::GetModelInfo(model_id)->CreateInstance())){
vehicle->GetMatrix().AttachRW(RwFrameGetMatrix(RpClumpGetFrame((RpClump*)vehicle->m_rwObject)), false);
vehicle->GetMatrix()->AttachRW(RwFrameGetMatrix(RpClumpGetFrame((RpClump*)vehicle->m_rwObject)), false);
}
}
}
@ -1307,9 +1307,9 @@ void CReplay::RestoreStuffFromMem(void)
object->m_rwObject = nil;
object->m_modelIndex = -1;
object->SetModelIndex(mi);
object->GetMatrix().m_attachment = nil;
object->GetMatrix()->m_attachment = nil;
if (RwObjectGetType(object->m_rwObject) == rpATOMIC)
object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)object->m_rwObject)), false);
object->GetMatrix()->AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)object->m_rwObject)), false);
}
i = CPools::GetDummyPool()->GetSize();
while (--i >= 0) {
@ -1322,9 +1322,9 @@ void CReplay::RestoreStuffFromMem(void)
dummy->m_rwObject = nil;
dummy->m_modelIndex = -1;
dummy->SetModelIndex(mi);
dummy->GetMatrix().m_attachment = nil;
dummy->GetMatrix()->m_attachment = nil;
if (RwObjectGetType(dummy->m_rwObject) == rpATOMIC)
dummy->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)dummy->m_rwObject)), false);
dummy->GetMatrix()->AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)dummy->m_rwObject)), false);
}
CTimer::SetTimeInMilliseconds(Time1);
CTimer::SetTimeInMillisecondsNonClipped(Time2);

View File

@ -55,7 +55,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
float fRadius = pVehicle->GetBoundRadius() / pPoliceColModel->boundingSphere.radius;
for (int32 i = 0; i < 2; i++) {
const int32 roadBlockIndex = i + 2 * roadBlockType;
CVector posForZ = pVehicle->GetMatrix() * (fRadius * vecRoadBlockOffets[roadBlockIndex]);
CVector posForZ = pVehicle->GetMatrix().r() * (fRadius * vecRoadBlockOffets[roadBlockIndex]);
int32 modelInfoId = MI_COP;
eCopType copType = COP_STREET;
switch (pVehicle->GetModelIndex())
@ -151,7 +151,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
offsetMatrix.GetPosition() = CVector(0.0f, i * fModelRadius - fOffset, 0.6f);
else
offsetMatrix.GetPosition() = CVector(i * fModelRadius - fOffset, 0.0f, 0.6f);
CMatrix vehicleMatrix = mapObject->GetMatrix() * offsetMatrix;
CMatrix vehicleMatrix = mapObject->GetMatrix().r() * offsetMatrix;
float fModelRadius = CModelInfo::GetColModel(vehicleId)->boundingSphere.radius - 0.25f;
int16 colliding = 0;
CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false);
@ -163,7 +163,7 @@ CRoadBlocks::GenerateRoadBlocks(void)
pVehicle->SetMatrix(vehicleMatrix);
pVehicle->PlaceOnRoadProperly();
pVehicle->SetIsStatic(false);
pVehicle->GetMatrix().UpdateRW();
pVehicle->GetMatrix()->UpdateRW();
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
CCarCtrl::JoinCarWithRoadSystem(pVehicle);
pVehicle->bIsLocked = false;

View File

@ -2676,7 +2676,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pos.z += pObj->GetDistanceFromCentreOfMassToBaseOfModel();
pObj->SetPosition(pos);
pObj->SetOrientation(0.0f, 0.0f, 0.0f);
pObj->GetMatrix().UpdateRW();
pObj->GetMatrix()->UpdateRW();
pObj->UpdateRwFrame();
CTheScripts::ClearSpaceForMissionEntity(pos, pObj);
CWorld::Add(pObj);

View File

@ -531,7 +531,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
script_assert(pObject);
CWorld::Remove(pObject);
pObject->SetHeading(DEGTORAD(*(float*)&ScriptParams[1]));
pObject->GetMatrix().UpdateRW();
pObject->GetMatrix()->UpdateRW();
pObject->UpdateRwFrame();
CWorld::Add(pObject);
return 0;

View File

@ -1257,7 +1257,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pObj->SetPosition(pos);
pObj->SetOrientation(0.0f, 0.0f, 0.0f);
pObj->GetMatrix().UpdateRW();
pObj->GetMatrix()->UpdateRW();
pObj->UpdateRwFrame();
CTheScripts::ClearSpaceForMissionEntity(pos, pObj);
CWorld::Add(pObj);

View File

@ -502,7 +502,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
return 0;
}
pObject->SetHeading(DEGTORAD(newHeading));
pObject->GetMatrix().UpdateRW();
pObject->GetMatrix()->UpdateRW();
pObject->UpdateRwFrame();
UpdateCompareFlag(newHeading == headingTarget); // using direct comparasion here is fine
return 0;

View File

@ -622,7 +622,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
script_assert(pObject);
CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix());
CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix().r());
return 0;
}
case COMMAND_SET_MUSIC_DOES_FADE:
@ -857,7 +857,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
DEGTORAD(*(float*)&ScriptParams[1]),
DEGTORAD(*(float*)&ScriptParams[2]),
DEGTORAD(*(float*)&ScriptParams[3]));
pObject->GetMatrix().UpdateRW();
pObject->GetMatrix()->UpdateRW();
pObject->UpdateRwFrame();
CWorld::Add(pObject);
return 0;

View File

@ -52,23 +52,23 @@ CTrafficLights::DisplayActualLight(CEntity *ent)
case CAR_LIGHTS_GREEN:
r = 0;
g = 255;
pos1 = ent->GetMatrix() * CVector(x, yMax, zMin);
pos2 = ent->GetMatrix() * CVector(x, yMin, zMin);
pos1 = ent->GetMatrix().r() * CVector(x, yMax, zMin);
pos2 = ent->GetMatrix().r() * CVector(x, yMin, zMin);
id = 0;
break;
case CAR_LIGHTS_YELLOW:
r = 255;
g = 128;
pos1 = ent->GetMatrix() * CVector(x, yMax, (zMin+zMax)/2.0f);
pos2 = ent->GetMatrix() * CVector(x, yMin, (zMin+zMax)/2.0f);
pos1 = ent->GetMatrix().r() * CVector(x, yMax, (zMin+zMax)/2.0f);
pos2 = ent->GetMatrix().r() * CVector(x, yMin, (zMin+zMax)/2.0f);
id = 1;
break;
case CAR_LIGHTS_RED:
default:
r = 255;
g = 0;
pos1 = ent->GetMatrix() * CVector(x, yMax, zMax);
pos2 = ent->GetMatrix() * CVector(x, yMin, zMax);
pos1 = ent->GetMatrix().r() * CVector(x, yMax, zMax);
pos2 = ent->GetMatrix().r() * CVector(x, yMin, zMax);
id = 2;
break;
}

View File

@ -297,9 +297,9 @@ CAnimViewer::Update(void)
}
#ifdef FIX_BUGS
// so we don't end up in the water
pTarget->GetMatrix().GetPosition().z = 10.0f;
pTarget->GetMatrix()->GetPosition().z = 10.0f;
#else
pTarget->GetMatrix().GetPosition().z = 0.0f;
pTarget->GetMatrix()->GetPosition().z = 0.0f;
#endif

View File

@ -1667,7 +1667,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
((CPed*)TheCamera.pTargetEntity)->m_fRotationCur = Heading;
((CPed*)TheCamera.pTargetEntity)->m_fRotationDest = Heading;
TheCamera.pTargetEntity->SetHeading(Heading);
TheCamera.pTargetEntity->GetMatrix().UpdateRW();
TheCamera.pTargetEntity->GetMatrix()->UpdateRW();
}
}
@ -2858,7 +2858,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
m_vecBufferedPlayerBodyOffset.z =
TheCamera.m_fGaitSwayBuffer * m_vecBufferedPlayerBodyOffset.z +
(1.0f-TheCamera.m_fGaitSwayBuffer) * HeadPos.z;
HeadPos = (CamTargetEntity->GetMatrix() * m_vecBufferedPlayerBodyOffset);
HeadPos = (CamTargetEntity->GetMatrix().r() * m_vecBufferedPlayerBodyOffset);
}else{
float HeadDelta = (HeadPos - InitialHeadPos).Magnitude2D();
CVector Fwd = CamTargetEntity->GetForward();
@ -2915,7 +2915,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
((CPed*)TheCamera.pTargetEntity)->m_fRotationCur = Heading;
((CPed*)TheCamera.pTargetEntity)->m_fRotationDest = Heading;
TheCamera.pTargetEntity->SetHeading(Heading);
TheCamera.pTargetEntity->GetMatrix().UpdateRW();
TheCamera.pTargetEntity->GetMatrix()->UpdateRW();
if(Mode == MODE_SNIPER_RUNABOUT){
// no mouse wheel FOV buffering here like in normal sniper mode
@ -3683,7 +3683,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float)
((CPed*)TheCamera.pTargetEntity)->m_fRotationCur = Heading;
((CPed*)TheCamera.pTargetEntity)->m_fRotationDest = Heading;
TheCamera.pTargetEntity->SetHeading(Heading);
TheCamera.pTargetEntity->GetMatrix().UpdateRW();
TheCamera.pTargetEntity->GetMatrix()->UpdateRW();
}
}
#endif

View File

@ -213,7 +213,7 @@ CCamera::Init(void)
m_iModeToGoTo = CCam::MODE_FOLLOWPED;
m_bJust_Switched = false;
m_bUseTransitionBeta = false;
GetMatrix().SetScale(1.0f);
GetMatrix()->SetScale(1.0f);
m_bTargetJustBeenOnTrain = false;
m_bInitialNoNodeStaticsSet = false;
m_uiLongestTimeInMill = 5000;
@ -654,19 +654,19 @@ CCamera::Process(void)
}
}
GetMatrix().GetRight() = CrossProduct(CamUp, CamFront); // actually Left
GetMatrix().GetForward() = CamFront;
GetMatrix().GetUp() = CamUp;
GetMatrix().GetPosition() = CamSource;
GetMatrix()->GetRight() = CrossProduct(CamUp, CamFront); // actually Left
GetMatrix()->GetForward() = CamFront;
GetMatrix()->GetUp() = CamUp;
GetMatrix()->GetPosition() = CamSource;
// Process Shake
float shakeStrength = m_fCamShakeForce - 0.28f*(CTimer::GetTimeInMilliseconds()-m_uiCamShakeStart)/1000.0f;
shakeStrength = Clamp(shakeStrength, 0.0f, 2.0f);
int shakeRand = CGeneral::GetRandomNumber();
float shakeOffset = shakeStrength*0.1f;
GetMatrix().GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7);
GetMatrix().GetPosition().y += shakeOffset * (((shakeRand & 0xF0) >> 4) - 7);
GetMatrix().GetPosition().z += shakeOffset * (((shakeRand & 0xF00) >> 8) - 7);
GetMatrix()->GetPosition().x += shakeOffset * ((shakeRand & 0xF) - 7);
GetMatrix()->GetPosition().y += shakeOffset * (((shakeRand & 0xF0) >> 4) - 7);
GetMatrix()->GetPosition().z += shakeOffset * (((shakeRand & 0xF00) >> 8) - 7);
if(shakeOffset > 0.0f && m_BlurType != MOTION_BLUR_SNIPER)
SetMotionBlurAlpha(Min((int)(shakeStrength*255.0f) + 25, 150));
@ -683,10 +683,10 @@ CCamera::Process(void)
CVector Front = Cams[2].Front;
CVector Up = Cams[2].Up;
GetMatrix().GetRight() = CrossProduct(Up, Front);
GetMatrix().GetForward() = Front;
GetMatrix().GetUp() = Up;
GetMatrix().GetPosition() = Source;
GetMatrix()->GetRight() = CrossProduct(Up, Front);
GetMatrix()->GetForward() = Front;
GetMatrix()->GetUp() = Up;
GetMatrix()->GetPosition() = Source;
CDraw::SetFOV(Cams[2].FOV);
m_vecGameCamPos = Cams[ActiveCam].Source;

View File

@ -1177,8 +1177,8 @@ CFileLoader::LoadMLOInstance(int id, const char *line)
RwMatrixRotate(matrix, &rot, -RADTODEG(rad), rwCOMBINEPOSTCONCAT);
RwMatrixTranslate(matrix, &pos, rwCOMBINEPOSTCONCAT);
inst->GetMatrix() = CMatrix(matrix);
inst->GetMatrix().UpdateRW();
inst->GetMatrix().r() = CMatrix(matrix);
inst->GetMatrix()->UpdateRW();
inst->m_modelIndex = modelIndex;
RwMatrixDestroy(matrix);
@ -1580,7 +1580,7 @@ CFileLoader::LoadObjectInstance(const char *line)
}else
entity = new CBuilding;
entity->SetModelIndexNoCreate(id);
entity->GetMatrix() = CMatrix(xform);
entity->GetMatrix().r() = CMatrix(xform);
entity->m_level = CTheZones::GetLevelFromPosition(&entity->GetPosition());
if(mi->IsSimple()){
if(mi->m_isBigBuilding)
@ -1594,7 +1594,7 @@ CFileLoader::LoadObjectInstance(const char *line)
}else{
entity = new CDummyObject;
entity->SetModelIndexNoCreate(id);
entity->GetMatrix() = CMatrix(xform);
entity->GetMatrix().r() = CMatrix(xform);
CWorld::Add(entity);
if(IsGlass(entity->GetModelIndex()))
entity->bIsVisible = false;

View File

@ -106,7 +106,7 @@ CFire::ProcessFire(void)
if (veh && veh->IsVehicle() && veh->IsCar()) {
CVehicleModelInfo *mi = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(veh->GetModelIndex()));
CVector ModelInfo = mi->m_positions[CAR_POS_HEADLIGHTS];
ModelInfo = m_pEntity->GetMatrix() * ModelInfo;
ModelInfo = m_pEntity->GetMatrix().r() * ModelInfo;
firePos.x = ModelInfo.x;
firePos.y = ModelInfo.y;

View File

@ -4,7 +4,7 @@
CPlaceable::CPlaceable(void)
{
m_matrix.SetScale(1.0f);
m_matrixPlaceable.SetScale(1.0f);
}
CPlaceable::~CPlaceable(void)
@ -14,9 +14,9 @@ CPlaceable::~CPlaceable(void)
void
CPlaceable::SetHeading(float angle)
{
CVector pos = GetMatrix().GetPosition();
m_matrix.SetRotateZ(angle);
GetMatrix().Translate(pos);
CVector pos = GetMatrix()->GetPosition();
m_matrixPlaceable.SetRotateZ(angle);
GetMatrix()->Translate(pos);
}
bool

View File

@ -1,9 +1,40 @@
#pragma once
class CPlaceable
extern void stacktrace();
struct CMatrixRef {
CMatrix& ref;
CMatrixRef(CMatrix &f): ref(f) { }
// operator ->
CMatrix* operator->() { return &ref; }
CMatrix& r() { return ref; }
operator const CMatrix&() { return ref; }
CMatrixRef& operator=(const CMatrixRef &m) {
ref = m.ref;
return *this;
}
CMatrixRef& operator=(const CMatrix &m) {
ref = m;
return *this;
}
~CMatrixRef() {
if (std::isnan(ref.px)) {
fprintf(stderr, "ref.px is NaN\n");
stacktrace();
}
}
};
class CPlaceable
{
protected:
CMatrix m_matrix;
CMatrix m_matrixPlaceable;
public:
// disable allocation
@ -11,24 +42,47 @@ public:
CPlaceable(void);
virtual ~CPlaceable(void);
const CVector &GetPosition(void) { return m_matrix.GetPosition(); }
const CVector &GetPosition(void) { return m_matrixPlaceable.GetPosition(); }
void SetPosition(float x, float y, float z) {
m_matrix.GetPosition().x = x;
m_matrix.GetPosition().y = y;
m_matrix.GetPosition().z = z;
if (std::isnan(x)) {
fprintf(stderr, "x is NaN\n");
stacktrace();
}
m_matrixPlaceable.GetPosition().x = x;
m_matrixPlaceable.GetPosition().y = y;
m_matrixPlaceable.GetPosition().z = z;
}
void SetPosition(const CVector &pos) {
if (std::isnan(pos.x)) {
fprintf(stderr, "pos.x is NaN\n");
stacktrace();
}
m_matrixPlaceable.GetPosition() = pos;
}
CVector &GetRight(void) { return m_matrixPlaceable.GetRight(); }
CVector &GetForward(void) { return m_matrixPlaceable.GetForward(); }
CVector &GetUp(void) { return m_matrixPlaceable.GetUp(); }
CMatrixRef GetMatrix(void) { return CMatrixRef(m_matrixPlaceable); }
void SetMatrix(const CMatrix &newMatrix) {
m_matrixPlaceable = newMatrix;
if (std::isnan(newMatrix.px)) {
fprintf(stderr, "newMatrix.px is NaN\n");
stacktrace();
}
}
void SetTransform(RwMatrix *m) {
m_matrixPlaceable = CMatrix(m, false);
if (std::isnan(m_matrixPlaceable.px)) {
fprintf(stderr, "newMatrix.px is NaN\n");
stacktrace();
}
}
void SetPosition(const CVector &pos) { m_matrix.GetPosition() = pos; }
CVector &GetRight(void) { return m_matrix.GetRight(); }
CVector &GetForward(void) { return m_matrix.GetForward(); }
CVector &GetUp(void) { return m_matrix.GetUp(); }
CMatrix &GetMatrix(void) { return m_matrix; }
void SetMatrix(CMatrix &newMatrix) { m_matrix = newMatrix; }
void SetTransform(RwMatrix *m) { m_matrix = CMatrix(m, false); }
void SetHeading(float angle);
void SetOrientation(float x, float y, float z){
CVector pos = m_matrix.GetPosition();
m_matrix.SetRotate(x, y, z);
m_matrix.Translate(pos);
CVector pos = m_matrixPlaceable.GetPosition();
m_matrixPlaceable.SetRotate(x, y, z);
m_matrixPlaceable.Translate(pos);
}
bool IsWithinArea(float x1, float y1, float x2, float y2);
bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2);

View File

@ -349,7 +349,7 @@ INITSAVEBUF
CopyToBuf(buf, pObject->m_modelIndex);
int32 ref = GetObjectRef(pObject);
CopyToBuf(buf, ref);
tmp.CompressFromFullMatrix(pObject->GetMatrix());
tmp.CompressFromFullMatrix(pObject->GetMatrix().r());
CopyToBuf(buf, tmp);
CopyToBuf(buf, pObject->m_fUprootLimit);
tmp.CompressFromFullMatrix(pObject->m_objectMatrix);
@ -391,7 +391,7 @@ INITSAVEBUF
CObject* pBufferObject = (CObject*)obuf;
CCompressedMatrix tmp;
CopyFromBuf(buf, tmp);
tmp.DecompressIntoFullMatrix(pBufferObject->GetMatrix());
tmp.DecompressIntoFullMatrix(pBufferObject->GetMatrix().r());
CopyFromBuf(buf, pBufferObject->m_fUprootLimit);
CopyFromBuf(buf, tmp);
tmp.DecompressIntoFullMatrix(pBufferObject->m_objectMatrix);

View File

@ -1445,7 +1445,7 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList &list, float x1, float y1
CColModel *pColModel = pVehicle->GetColModel();
bool bInsideSphere = false;
for(int32 i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
CVector pos = pVehicle->GetMatrix().r() * pColModel->spheres[i].center;
float fRadius = pColModel->spheres[i].radius;
if(pos.x + fRadius > x1 && pos.x - fRadius < x2 && pos.y + fRadius > y1 &&
pos.y - fRadius < y2)
@ -1758,12 +1758,12 @@ CWorld::RepositionOneObject(CEntity *pEntity)
modelId == MI_FISHSTALL02 || modelId == MI_FISHSTALL03 || modelId == MI_FISHSTALL04 ||
modelId == MI_BAGELSTAND2 || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT ||
modelId == MI_PARKTABLE) {
CVector &position = pEntity->GetMatrix().GetPosition();
CVector &position = pEntity->GetMatrix()->GetPosition();
float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z;
position.z = FindGroundZFor3DCoord(position.x, position.y,
position.z + OBJECT_REPOSITION_OFFSET_Z, nil) -
fBoundingBoxMinZ;
pEntity->GetMatrix().UpdateRW();
pEntity->GetMatrix()->UpdateRW();
pEntity->UpdateRwFrame();
} else if(modelId == MI_BUOY) {
float fWaterLevel = 0.0f;
@ -1776,7 +1776,7 @@ CWorld::RepositionOneObject(CEntity *pEntity)
if(!bFound || fWaterLevel > fGroundZ) {
CColModel *pColModel = pEntity->GetColModel();
float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z;
pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
pEntity->GetMatrix()->GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
}
}
}
@ -1840,6 +1840,7 @@ CWorld::RemoveStaticObjects()
void
CWorld::Process(void)
{
CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth=300;
if(!(CTimer::GetFrameCounter() & 63)) CReferences::PruneAllReferencesInWorld();
if(bProcessCutsceneOnly) {
@ -1855,7 +1856,7 @@ CWorld::Process(void)
}
csObj->ProcessControl();
csObj->ProcessCollision();
csObj->GetMatrix().UpdateRW();
csObj->GetMatrix()->UpdateRW();
csObj->UpdateRwFrame();
}
}
@ -1902,7 +1903,7 @@ CWorld::Process(void)
for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity *)node->item;
movingEnt->bIsInSafePosition = true;
movingEnt->GetMatrix().UpdateRW();
movingEnt->GetMatrix()->UpdateRW();
movingEnt->UpdateRwFrame();
}
} else {
@ -1911,7 +1912,7 @@ CWorld::Process(void)
CEntity *movingEnt = (CEntity *)node->item;
if(!movingEnt->bIsInSafePosition) {
movingEnt->ProcessCollision();
movingEnt->GetMatrix().UpdateRW();
movingEnt->GetMatrix()->UpdateRW();
movingEnt->UpdateRwFrame();
}
}
@ -1921,7 +1922,7 @@ CWorld::Process(void)
CEntity *movingEnt = (CEntity *)node->item;
if(!movingEnt->bIsInSafePosition) {
movingEnt->ProcessCollision();
movingEnt->GetMatrix().UpdateRW();
movingEnt->GetMatrix()->UpdateRW();
movingEnt->UpdateRwFrame();
}
}
@ -1931,7 +1932,7 @@ CWorld::Process(void)
if(!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
movingEnt->ProcessCollision();
movingEnt->GetMatrix().UpdateRW();
movingEnt->GetMatrix()->UpdateRW();
movingEnt->UpdateRwFrame();
if(!movingEnt->bIsInSafePosition) { movingEnt->bIsStuck = true; }
}
@ -1941,7 +1942,7 @@ CWorld::Process(void)
CEntity *movingEnt = (CEntity *)node->item;
if(!movingEnt->bIsInSafePosition) {
movingEnt->ProcessShift();
movingEnt->GetMatrix().UpdateRW();
movingEnt->GetMatrix()->UpdateRW();
movingEnt->UpdateRwFrame();
if(!movingEnt->bIsInSafePosition) { movingEnt->bIsStuck = true; }
}
@ -1951,7 +1952,7 @@ CWorld::Process(void)
CPhysical *movingEnt = (CPhysical *)node->item;
if(!movingEnt->bIsInSafePosition) {
movingEnt->ProcessShift();
movingEnt->GetMatrix().UpdateRW();
movingEnt->GetMatrix()->UpdateRW();
movingEnt->UpdateRwFrame();
if(!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
@ -1989,7 +1990,7 @@ CWorld::Process(void)
default: movingPed->SetPedPositionInCar(); break;
}
}
movingPed->GetMatrix().UpdateRW();
movingPed->GetMatrix()->UpdateRW();
movingPed->UpdateRwFrame();
} else {
movingPed->bInVehicle = false;

View File

@ -1496,10 +1496,10 @@ CCullZone::TestEntityVisibilityFromCullZone(CEntity *entity, float extraDist, CE
else
boundMaxZ += extraDist;
CVector vecMin = entity->GetMatrix() * CVector(boundMinX, boundMinY, boundMinZ);
CVector vecMaxX = entity->GetMatrix() * CVector(boundMaxX, boundMinY, boundMinZ);
CVector vecMaxY = entity->GetMatrix() * CVector(boundMinX, boundMaxY, boundMinZ);
CVector vecMaxZ = entity->GetMatrix() * CVector(boundMinX, boundMinY, boundMaxZ);
CVector vecMin = entity->GetMatrix().r() * CVector(boundMinX, boundMinY, boundMinZ);
CVector vecMaxX = entity->GetMatrix().r() * CVector(boundMaxX, boundMinY, boundMinZ);
CVector vecMaxY = entity->GetMatrix().r() * CVector(boundMinX, boundMaxY, boundMinZ);
CVector vecMaxZ = entity->GetMatrix().r() * CVector(boundMinX, boundMinY, boundMaxZ);
CVector dirx = vecMaxX - vecMin;
CVector diry = vecMaxY - vecMin;
CVector dirz = vecMaxZ - vecMin;
@ -1534,7 +1534,7 @@ CCullZone::TestEntityVisibilityFromCullZone(CEntity *entity, float extraDist, CE
// check both xy planes
for(int i = 0; i < NumTestPoints; i++){
CVector testPoint = aTestPoints[i];
CVector mid = entity->GetMatrix() * CVector(midX, midY, midZ);
CVector mid = entity->GetMatrix().r() * CVector(midX, midY, midZ);
mid.z += 0.1f;
if(DoThoroughLineTest(testPoint, mid, entity))
return true;

View File

@ -746,7 +746,7 @@ SpawnCar(int id)
else
v->SetPosition(ThePaths.m_pathNodes[node].GetPosition());
v->GetMatrix().GetPosition().z += 4.0f;
v->GetMatrix()->GetPosition().z += 4.0f;
v->SetOrientation(0.0f, 0.0f, 3.49f);
v->SetStatus(STATUS_ABANDONED);
v->m_nDoorLock = CARLOCK_UNLOCKED;

View File

@ -111,9 +111,9 @@ CEntity::CreateRwObject(void)
if(IsBuilding())
gBuildings++;
if(RwObjectGetType(m_rwObject) == rpATOMIC)
GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic *)m_rwObject)), false);
GetMatrix()->AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic *)m_rwObject)), false);
else if(RwObjectGetType(m_rwObject) == rpCLUMP)
GetMatrix().AttachRW(RwFrameGetMatrix(RpClumpGetFrame((RpClump *)m_rwObject)), false);
GetMatrix()->AttachRW(RwFrameGetMatrix(RpClumpGetFrame((RpClump *)m_rwObject)), false);
mi->AddRef();
}
}
@ -124,9 +124,9 @@ CEntity::AttachToRwObject(RwObject *obj)
m_rwObject = obj;
if(m_rwObject){
if(RwObjectGetType(m_rwObject) == rpATOMIC)
GetMatrix().Attach(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic *)m_rwObject)), false);
GetMatrix()->Attach(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic *)m_rwObject)), false);
else if(RwObjectGetType(m_rwObject) == rpCLUMP)
GetMatrix().Attach(RwFrameGetMatrix(RpClumpGetFrame((RpClump *)m_rwObject)), false);
GetMatrix()->Attach(RwFrameGetMatrix(RpClumpGetFrame((RpClump *)m_rwObject)), false);
CModelInfo::GetModelInfo(m_modelIndex)->AddRef();
}
}
@ -137,7 +137,7 @@ CEntity::DetachFromRwObject(void)
if(m_rwObject)
CModelInfo::GetModelInfo(m_modelIndex)->RemoveRef();
m_rwObject = nil;
GetMatrix().Detach();
GetMatrix()->Detach();
}
#ifdef PED_SKIN
@ -167,7 +167,7 @@ CEntity::DeleteRwObject(void)
{
RwFrame *f;
GetMatrix().Detach();
GetMatrix()->Detach();
if(m_rwObject){
if(RwObjectGetType(m_rwObject) == rpATOMIC){
f = RpAtomicGetFrame((RpAtomic*)m_rwObject);
@ -297,24 +297,24 @@ CEntity::PreRender(void)
case ENTITY_TYPE_OBJECT:
if(GetModelIndex() == MI_COLLECTABLE1){
CPickups::DoCollectableEffects(this);
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
}else if(GetModelIndex() == MI_MONEY){
CPickups::DoMoneyEffects(this);
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
}else if(GetModelIndex() == MI_NAUTICALMINE ||
GetModelIndex() == MI_CARMINE ||
GetModelIndex() == MI_BRIEFCASE){
if(((CObject*)this)->bIsPickup){
CPickups::DoMineEffects(this);
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
}
}else if(IsPickupModel(GetModelIndex())){
if(((CObject*)this)->bIsPickup){
CPickups::DoPickUpEffects(this);
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
}else if(GetModelIndex() == MI_GRENADE){
CMotionBlurStreaks::RegisterStreak((uintptr)this,
@ -619,7 +619,7 @@ CEntity::ModifyMatrixForTreeInWind(void)
if(CTimer::GetIsPaused())
return;
CMatrix mat(GetMatrix().m_attachment);
CMatrix mat(GetMatrix()->m_attachment);
if(CWeather::Wind >= 0.5){
t = m_randomSeed + 16*CTimer::GetTimeInMilliseconds();
@ -672,7 +672,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
else
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;
flutter = f * BannerWindTabel[(t>>11)+1 & 0x1F] +
(1.0f - f) * BannerWindTabel[(t>>11) & 0x1F];
@ -686,7 +686,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
GetRight() = CrossProduct(GetForward(), up);
GetUp() = up;
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
}

View File

@ -159,6 +159,22 @@ CPhysical::RemoveAndAdd(void)
ystart = CWorld::GetSectorIndexY(bounds.top);
yend = CWorld::GetSectorIndexY(bounds.bottom);
ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f);
auto pos = GetBoundCentre();
if (std::isnan(bounds.left)) {
// print m_matrix
// fprintf(stderr, "m_matrix:\n");
// fprintf(stderr, "rx: %f ry: %f rz: %f rw: %f\n", m_matrix.rx, m_matrix.ry, m_matrix.rz, m_matrix.rw);
// fprintf(stderr, "fx: %f fy: %f fz: %f fw: %f\n", m_matrix.fx, m_matrix.fy, m_matrix.fz, m_matrix.fw);
// fprintf(stderr, "ux: %f uy: %f uz: %f uw: %f\n", m_matrix.ux, m_matrix.uy, m_matrix.uz, m_matrix.uw);
// fprintf(stderr, "px: %f py: %f pz: %f pw: %f\n", m_matrix.px, m_matrix.py, m_matrix.pz, m_matrix.pw);
fprintf(stderr, "center x: %f y: %f z: %f, Radious: %f, m_modelIndex: %d (%s) %p\n", pos.x, pos.y, pos.z, GetBoundRadius(), m_modelIndex, CModelInfo::GetModelInfo(m_modelIndex)->GetModelName(), m_matrixPlaceable.m_attachment);
stacktrace();
// fprintf(stderr, "left: %f right: %f top: %f bottom: %f\n", bounds.left, bounds.right, bounds.top, bounds.bottom);
}
// fprintf(stderr, "xstart %d xend %d xmid %d ystart %d yend %d ymid %d\n", xstart, xend, xmid, ystart, yend, ymid);
assert(xstart >= 0);
assert(xend < NUMSECTORS_X);
assert(ystart >= 0);
@ -318,15 +334,15 @@ CPhysical::RemoveRefsToEntity(CEntity *ent)
void
CPhysical::PlacePhysicalRelativeToOtherPhysical(CPhysical *other, CPhysical *phys, CVector localPos)
{
CVector worldPos = other->GetMatrix() * localPos;
CVector worldPos = other->GetMatrix().r() * localPos;
float step = 0.9f * CTimer::GetTimeStep();
CVector pos = other->m_vecMoveSpeed*step + worldPos;
CWorld::Remove(phys);
phys->GetMatrix() = other->GetMatrix();
phys->GetMatrix().r() = other->GetMatrix().r();
phys->SetPosition(pos);
phys->m_vecMoveSpeed = other->m_vecMoveSpeed;
phys->GetMatrix().UpdateRW();
phys->GetMatrix()->UpdateRW();
phys->UpdateRwFrame();
CWorld::Add(phys);
}
@ -419,7 +435,14 @@ CPhysical::GetSpeed(const CVector &r)
void
CPhysical::ApplyMoveSpeed(void)
{
GetMatrix().Translate(m_vecMoveSpeed * CTimer::GetTimeStep());
if (std::isnan(m_vecMoveSpeed.x)) {
fprintf(stderr, "CCutsceneObject::ProcessControl: m_vecMoveSpeed.x is NaN4\n");
}
if (std::isnan(CTimer::GetTimeStep())) {
fprintf(stderr, "CTimer::GetTimeStep() is NaN\n");
}
GetMatrix()->Translate(m_vecMoveSpeed * CTimer::GetTimeStep());
}
void
@ -1149,7 +1172,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
}else if(Aobj->m_pCollidingEntity != B){
CMatrix inv;
CVector size = CModelInfo::GetColModel(A->GetModelIndex())->boundingBox.GetSize();
size = A->GetMatrix() * size;
size = A->GetMatrix().r() * size;
if(size.z < B->GetPosition().z ||
(Invert(B->GetMatrix(), inv) * size).z < 0.0f){
skipShift = true;
@ -1167,7 +1190,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
}else if(Bobj->m_pCollidingEntity != A){
CMatrix inv;
CVector size = CModelInfo::GetColModel(B->GetModelIndex())->boundingBox.GetSize();
size = B->GetMatrix() * size;
size = B->GetMatrix().r() * size;
if(size.z < A->GetPosition().z ||
(Invert(A->GetMatrix(), inv) * size).z < 0.0f)
skipShift = true;
@ -1222,7 +1245,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
float f = Min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
B->GetMatrix().Translate(dir * colpoints[mostColliding].GetDepth() / (1.0f - f));
B->GetMatrix()->Translate(dir * colpoints[mostColliding].GetDepth() / (1.0f - f));
// BUG? how can that ever happen? A is a Ped
if(B->IsVehicle())
B->ProcessEntityCollision(A, colpoints);
@ -1239,7 +1262,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
if(!doShift)
return false;
GetMatrix().Translate(shift);
GetMatrix()->Translate(shift);
if(boat)
ProcessEntityCollision(boat, colpoints);
return true;
@ -1486,7 +1509,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
else{
CMatrix inv;
CVector size = CModelInfo::GetColModel(A->GetModelIndex())->boundingBox.GetSize();
size = A->GetMatrix() * size;
size = A->GetMatrix().r() * size;
if(size.z < B->GetPosition().z ||
(Invert(B->GetMatrix(), inv) * size).z < 0.0f){
skipCollision = true;
@ -1505,7 +1528,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
else{
CMatrix inv;
CVector size = CModelInfo::GetColModel(B->GetModelIndex())->boundingBox.GetSize();
size = B->GetMatrix() * size;
size = B->GetMatrix().r() * size;
if(size.z < A->GetPosition().z ||
(Invert(A->GetMatrix(), inv) * size).z < 0.0f){
skipCollision = true;
@ -1822,7 +1845,7 @@ CPhysical::ProcessShift(void)
CMatrix matrix(GetMatrix());
ApplyMoveSpeed();
ApplyTurnSpeed();
GetMatrix().Reorthogonalise();
GetMatrix()->Reorthogonalise();
CWorld::AdvanceCurrentScanCode();
@ -1838,7 +1861,7 @@ CPhysical::ProcessShift(void)
CWorld::AdvanceCurrentScanCode();
for(node = m_entryInfoList.first; node; node = node->next)
if(ProcessCollisionSectorList(node->sector->m_lists)){
GetMatrix() = matrix;
GetMatrix().r() = matrix;
return;
}
}
@ -1945,7 +1968,7 @@ CPhysical::ProcessCollision(void)
!ped->bWasStanding &&
ped->bIsStanding)
savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
GetMatrix().r() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep);
return;
}
@ -1953,7 +1976,7 @@ CPhysical::ProcessCollision(void)
!ped->bWasStanding &&
ped->bIsStanding)
savedMatrix.GetPosition().z = GetPosition().z;
GetMatrix() = savedMatrix;
GetMatrix().r() = savedMatrix;
CTimer::SetTimeStep(savedTimeStep);
if(IsVehicle()){
CVehicle *veh = (CVehicle*)this;
@ -1975,7 +1998,7 @@ CPhysical::ProcessCollision(void)
ApplyMoveSpeed();
ApplyTurnSpeed();
GetMatrix().Reorthogonalise();
GetMatrix()->Reorthogonalise();
m_bIsVehicleBeingShifted = false;
bSkipLineCol = false;
if(!m_vecMoveSpeed.IsZero() ||

View File

@ -1,5 +1,7 @@
#pragma once
#define float32 float
#include "Lists.h"
#include "Timer.h"
#include "Entity.h"

View File

@ -1,5 +1,5 @@
#include "common.h"
extern void stacktrace();
CMatrix::CMatrix(void)
{
m_attachment = nil;
@ -64,6 +64,10 @@ CMatrix::Update(void)
GetForward() = m_attachment->up;
GetUp() = m_attachment->at;
GetPosition() = m_attachment->pos;
if (std::isnan(m_attachment->pos.x)) {
fprintf(stderr, "m_attachment->pos.x is NaN\n");
stacktrace();
}
}
void
@ -74,6 +78,10 @@ CMatrix::UpdateRW(void)
m_attachment->up = GetForward();
m_attachment->at = GetUp();
m_attachment->pos = GetPosition();
if (std::isnan(m_attachment->pos.x)) {
fprintf(stderr, "2 m_attachment->pos.x is NaN\n");
stacktrace();
}
RwMatrixUpdate(m_attachment);
}
}

View File

@ -13,7 +13,7 @@ CMloModelInfo::ConstructClump()
for (int i = firstInstance; i < lastInstance; i++) {
int modelId = CModelInfo::GetMloInstanceStore().store[i].m_modelIndex;
RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix().m_attachment;
RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix()->m_attachment;
CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId);
if (minfo->m_atomics[0] != nil) {

View File

@ -77,14 +77,14 @@ CCutsceneHead::ProcessControl(void)
int idx = RpHAnimIDGetIndex(hier, BONE_head);
RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
if(RwV3dLength(&mat->pos) > 100.0f){
m_matrix.SetRotateY(PI/2);
m_matrix = CMatrix(mat) * m_matrix;
m_matrixPlaceable.SetRotateY(PI/2);
SetMatrix(CMatrix(mat) * m_matrixPlaceable);
}
}else
#endif
{
m_matrix.SetRotateY(PI/2);
m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
m_matrixPlaceable.SetRotateY(PI/2);
SetMatrix(CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrixPlaceable);
}
assert(RwObjectGetType(m_rwObject) == rpCLUMP);
@ -111,8 +111,8 @@ CCutsceneHead::Render(void)
int idx = RpHAnimIDGetIndex(hier, BONE_head);
RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
if(RwV3dLength(&mat->pos) > 100.0f){
m_matrix.SetRotateY(PI/2);
m_matrix = CMatrix(mat) * m_matrix;
m_matrixPlaceable.SetRotateY(PI/2);
SetMatrix(CMatrix(mat) * m_matrixPlaceable);
}
// This is head...it has no limbs
#ifndef FIX_BUGS
@ -122,8 +122,8 @@ CCutsceneHead::Render(void)
}else
#endif
{
m_matrix.SetRotateY(PI/2);
m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
m_matrixPlaceable.SetRotateY(PI/2);
SetMatrix(CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrixPlaceable);
}
UpdateRwFrame();

View File

@ -42,13 +42,23 @@ CCutsceneObject::SetModelIndex(uint32 id)
void
CCutsceneObject::ProcessControl(void)
{
if (std::isnan(m_vecMoveSpeed.x)) {
fprintf(stderr, "CCutsceneObject::ProcessControl: m_vecMoveSpeed.x is NaN\n");
}
CPhysical::ProcessControl();
if (std::isnan(m_vecMoveSpeed.x)) {
fprintf(stderr, "CCutsceneObject::ProcessControl: m_vecMoveSpeed.x is NaN2\n");
}
if(CTimer::GetTimeStep() < 1/100.0f)
m_vecMoveSpeed *= 100.0f;
else
m_vecMoveSpeed *= 1.0f/CTimer::GetTimeStep();
if (std::isnan(m_vecMoveSpeed.x)) {
fprintf(stderr, "CCutsceneObject::ProcessControl: m_vecMoveSpeed.x is NaN3\n");
}
ApplyMoveSpeed();
#ifdef PED_SKIN

View File

@ -134,8 +134,8 @@ void
CObject::Teleport(CVector vecPos)
{
CWorld::Remove(this);
GetMatrix().GetPosition() = vecPos;
GetMatrix().UpdateRW();
GetMatrix()->GetPosition() = vecPos;
GetMatrix()->UpdateRW();
UpdateRwFrame();
CWorld::Add(this);
}
@ -192,7 +192,7 @@ CObject::ObjectDamage(float amount)
amount = 0.0f;
}
if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) {
const CVector& vecPos = GetMatrix().GetPosition();
const CVector& vecPos = GetMatrix()->GetPosition();
const float fDirectionZ = 0.0002f * amount;
switch (m_nCollisionDamageEffect)
{
@ -351,7 +351,7 @@ CObject::Init(void)
m_pCollidingEntity = nil;
CColPoint point;
CEntity* outEntity = nil;
const CVector& vecPos = GetMatrix().GetPosition();
const CVector& vecPos = GetMatrix()->GetPosition();
if (CWorld::ProcessVerticalLine(vecPos, vecPos.z - 10.0f, point, outEntity, true, false, false, false, false, false, nil))
m_pCurSurface = outEntity;
else

View File

@ -1127,9 +1127,9 @@ SaveOneParticle(CParticleObject *p, uint8 *&buffer)
// CPlaceable
{
ZeroBuf(buffer, 4);
CopyToBuf(buffer, p->GetMatrix().f);
CopyToBuf(buffer, p->GetMatrix()->f);
ZeroBuf(buffer, 4);
CopyToBuf(buffer, p->GetMatrix().m_hasRwMatrix);
CopyToBuf(buffer, p->GetMatrix()->m_hasRwMatrix);
ZeroBuf(buffer, 3);
}

View File

@ -458,7 +458,7 @@ CPed::RunToReportCrime(eCrimeType crimeToReport)
#endif
bRunningToPhone = true;
SetSeek(phone->m_pEntity->GetMatrix() * -phone->m_pEntity->GetForward(), 1.0f); // original: phone.m_vecPos, 0.3f
SetSeek(phone->m_pEntity->GetMatrix().r() * -phone->m_pEntity->GetForward(), 1.0f); // original: phone.m_vecPos, 0.3f
SetMoveState(PEDMOVE_RUN);
bIsRunning = true; // not there in original
m_phoneId = phoneId;

View File

@ -2184,7 +2184,7 @@ CPed::ProcessControl(void)
CVector colMinVec = collidingCol->boundingBox.min;
CVector colMaxVec = collidingCol->boundingBox.max;
CVector vehColCenterDist = collidingVeh->GetMatrix() * ((colMinVec + colMaxVec) * 0.5f) - GetPosition();
CVector vehColCenterDist = collidingVeh->GetMatrix().r() * ((colMinVec + colMaxVec) * 0.5f) - GetPosition();
// TLVC = To look vehicle center
@ -2316,7 +2316,7 @@ CPed::ProcessControl(void)
CVector colMinVec = collidingCol->boundingBox.min;
CVector colMaxVec = collidingCol->boundingBox.max;
CVector vehColCenterDist = collidingVeh->GetMatrix() * ((colMinVec + colMaxVec) * 0.5f) - GetPosition();
CVector vehColCenterDist = collidingVeh->GetMatrix().r() * ((colMinVec + colMaxVec) * 0.5f) - GetPosition();
// TLVC = To look vehicle center
@ -2508,9 +2508,9 @@ CPed::ProcessControl(void)
#endif
if (flyDir > 0 && !bSomeVCflag1) {
GetMatrix().SetTranslateOnly((flyDir == 2 ? obstacleForFlyingOtherDir.point : obstacleForFlying.point));
GetMatrix().GetPosition().z += FEET_OFFSET;
GetMatrix().UpdateRW();
GetMatrix()->SetTranslateOnly((flyDir == 2 ? obstacleForFlyingOtherDir.point : obstacleForFlying.point));
GetMatrix()->GetPosition().z += FEET_OFFSET;
GetMatrix()->UpdateRW();
SetLanding();
bIsStanding = true;
}
@ -2527,7 +2527,7 @@ CPed::ProcessControl(void)
#ifdef FIX_BUGS
if (!IsPlayer())
#endif
GetMatrix().GetPosition() += 0.25f * offsetToCheck;
GetMatrix()->GetPosition() += 0.25f * offsetToCheck;
m_fRotationCur = CGeneral::GetRadianAngleBetweenPoints(offsetToCheck.x, offsetToCheck.y, 0.0f, 0.0f);
m_fRotationCur = CGeneral::LimitRadianAngle(m_fRotationCur);
@ -2619,14 +2619,14 @@ CPed::ProcessControl(void)
if (CWorld::ProcessVerticalLine(offsetToCheck, GetPosition().z - FEET_OFFSET, foundCol, foundEnt, true, true, false, true, false, false, nil)) {
#ifdef VC_PED_PORTS
if (!bSomeVCflag1 || FEET_OFFSET + foundCol.point.z < GetPosition().z) {
GetMatrix().GetPosition().z = FEET_OFFSET + foundCol.point.z;
GetMatrix().UpdateRW();
GetMatrix()->GetPosition().z = FEET_OFFSET + foundCol.point.z;
GetMatrix()->UpdateRW();
if (bSomeVCflag1)
bSomeVCflag1 = false;
}
#else
GetMatrix().GetPosition().z = FEET_OFFSET + foundCol.point.z;
GetMatrix().UpdateRW();
GetMatrix()->GetPosition().z = FEET_OFFSET + foundCol.point.z;
GetMatrix()->UpdateRW();
#endif
SetLanding();
bIsStanding = true;
@ -3107,12 +3107,12 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
bStillOnValidPoly = true;
#ifdef VC_PED_PORTS
if(!bSomeVCflag1 || FEET_OFFSET + intersectionPoint.point.z < GetPosition().z) {
GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
GetMatrix()->GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
if (bSomeVCflag1)
bSomeVCflag1 = false;
}
#else
GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
GetMatrix()->GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
#endif
m_vecMoveSpeed.z = 0.0f;
@ -3185,12 +3185,12 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
}
#ifdef VC_PED_PORTS
if (!bSomeVCflag1 || FEET_OFFSET + intersectionPoint.point.z < GetPosition().z) {
GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
GetMatrix()->GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
if (bSomeVCflag1)
bSomeVCflag1 = false;
}
#else
GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
GetMatrix()->GetPosition().z = FEET_OFFSET + intersectionPoint.point.z;
#endif
m_nSurfaceTouched = intersectionPoint.surfaceB;
if (m_nSurfaceTouched == SURFACE_STEEP_CLIFF) {
@ -3290,7 +3290,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
float speed = m_vecMoveSpeed.Magnitude2D();
sphereNormal.x = -m_vecMoveSpeed.x / Max(0.001f, speed);
sphereNormal.y = -m_vecMoveSpeed.y / Max(0.001f, speed);
GetMatrix().GetPosition().z -= 0.05f;
GetMatrix()->GetPosition().z -= 0.05f;
bSomeVCflag1 = true;
}
#endif
@ -3595,7 +3595,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
objUpsideDown = true;
if (obj->GetModelIndex() != MI_TRAFFICLIGHTS && obj->GetModelIndex() != MI_SINGLESTREETLIGHTS1 && obj->GetModelIndex() != MI_SINGLESTREETLIGHTS2) {
objColCenter = obj->GetMatrix() * objColCenter;
objColCenter = obj->GetMatrix().r() * objColCenter;
} else {
checkIntervalInDist = 0.4f;
if (objMat.GetUp().z <= 0.57f) {
@ -3612,7 +3612,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
objColCenter = obj->GetPosition();
} else {
objColCenter.x = adjustedColMax.x - 0.25f;
objColCenter = obj->GetMatrix() * objColCenter;
objColCenter = obj->GetMatrix().r() * objColCenter;
distLimitForTimer = 0.75f;
}
objUpsideDown = false;
@ -3698,7 +3698,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
#ifdef NEW_WALK_AROUND_ALGORITHM
else {
CVector tl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMax.y, 0.0f) - GetPosition();
CVector tl = obj->GetMatrix().r() * CVector(adjustedColMin.x, adjustedColMax.y, 0.0f) - GetPosition();
if (goingToEnterCar && (m_vehDoor == CAR_DOOR_LF || m_vehDoor == CAR_DOOR_LR)) {
cornerToGo = tl;
m_walkAroundType = 1;
@ -3735,7 +3735,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
#ifdef NEW_WALK_AROUND_ALGORITHM
else {
CVector tr = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMax.y, 0.0f) - GetPosition();
CVector tr = obj->GetMatrix().r() * CVector(adjustedColMax.x, adjustedColMax.y, 0.0f) - GetPosition();
if (tr.Magnitude2D() < cornerToGo.Magnitude2D()) {
if (goingToEnterCar && (m_vehDoor == CAR_DOOR_RF || m_vehDoor == CAR_DOOR_RR)) {
cornerToGo = tr;
@ -3774,7 +3774,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
#ifdef NEW_WALK_AROUND_ALGORITHM
else {
CVector br = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMin.y, 0.0f) - GetPosition();
CVector br = obj->GetMatrix().r() * CVector(adjustedColMax.x, adjustedColMin.y, 0.0f) - GetPosition();
if (iWouldPreferGoingBack == 2)
m_walkAroundType = 4;
else if (br.Magnitude2D() < cornerToGo.Magnitude2D()) {
@ -3812,7 +3812,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
}
#ifdef NEW_WALK_AROUND_ALGORITHM
else {
CVector bl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMin.y, 0.0f) - GetPosition();
CVector bl = obj->GetMatrix().r() * CVector(adjustedColMin.x, adjustedColMin.y, 0.0f) - GetPosition();
if (iWouldPreferGoingBack == 1)
m_walkAroundType = 7;
else if (bl.Magnitude2D() < cornerToGo.Magnitude2D()) {
@ -7144,8 +7144,8 @@ CPed::LookForInterestingNodes(void)
for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &veh->GetMatrix();
CVector effectPos = veh->GetMatrix() * effect->pos;
objMat = &veh->GetMatrix().r();
CVector effectPos = veh->GetMatrix().r() * effect->pos;
effectDist = effectPos - GetPosition();
if (effectDist.MagnitudeSqr() < sq(8.0f)) {
found = true;
@ -7162,8 +7162,8 @@ CPed::LookForInterestingNodes(void)
for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &obj->GetMatrix();
CVector effectPos = obj->GetMatrix() * effect->pos;
objMat = &obj->GetMatrix().r();
CVector effectPos = obj->GetMatrix().r() * effect->pos;
effectDist = effectPos - GetPosition();
if (effectDist.MagnitudeSqr() < sq(8.0f)) {
found = true;
@ -7180,8 +7180,8 @@ CPed::LookForInterestingNodes(void)
for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &building->GetMatrix();
CVector effectPos = building->GetMatrix() * effect->pos;
objMat = &building->GetMatrix().r();
CVector effectPos = building->GetMatrix().r() * effect->pos;
effectDist = effectPos - GetPosition();
if (effectDist.MagnitudeSqr() < sq(8.0f)) {
found = true;
@ -7198,8 +7198,8 @@ CPed::LookForInterestingNodes(void)
for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &building->GetMatrix();
CVector effectPos = building->GetMatrix() * effect->pos;
objMat = &building->GetMatrix().r();
CVector effectPos = building->GetMatrix().r() * effect->pos;
effectDist = effectPos - GetPosition();
if (effectDist.MagnitudeSqr() < sq(8.0f)) {
found = true;
@ -7857,10 +7857,10 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh)
CVector leftFrontPos = CVector(colMin->x - 0.5f, 0.5f + colMax->y, 0.0f);
CVector rightFrontPos = CVector(0.5f + colMax->x, 0.5f + colMax->y, 0.0f);
leftRearPos = veh->GetMatrix() * leftRearPos;
rightRearPos = veh->GetMatrix() * rightRearPos;
leftFrontPos = veh->GetMatrix() * leftFrontPos;
rightFrontPos = veh->GetMatrix() * rightFrontPos;
leftRearPos = veh->GetMatrix().r() * leftRearPos;
rightRearPos = veh->GetMatrix().r() * rightRearPos;
leftFrontPos = veh->GetMatrix().r() * leftFrontPos;
rightFrontPos = veh->GetMatrix().r() * rightFrontPos;
// Makes helperPos veh-ped distance vector.
helperPos -= veh->GetPosition();
@ -7868,7 +7868,7 @@ CPed::PossiblyFindBetterPosToSeekCar(CVector *pos, CVehicle *veh)
// ?!? I think it's absurd to use this unless another function like SeekCar finds next pos. with it and we're trying to simulate it's behaviour.
// On every run it returns another pos. for ped, with same distance to the veh.
// Sequence of positions are not guaranteed, it depends on global pos. (So sometimes it returns positions to make ped draw circle, sometimes don't)
helperPos = veh->GetMatrix() * helperPos;
helperPos = veh->GetMatrix().r() * helperPos;
float vehForwardHeading = veh->GetForward().Heading();
@ -8537,9 +8537,9 @@ void
CPed::Load(uint8*& buf)
{
SkipSaveBuf(buf, 52);
CopyFromBuf(buf, GetMatrix().GetPosition().x);
CopyFromBuf(buf, GetMatrix().GetPosition().y);
CopyFromBuf(buf, GetMatrix().GetPosition().z);
CopyFromBuf(buf, GetMatrix()->GetPosition().x);
CopyFromBuf(buf, GetMatrix()->GetPosition().y);
CopyFromBuf(buf, GetMatrix()->GetPosition().z);
SkipSaveBuf(buf, 288);
CopyFromBuf(buf, CharCreatedBy);
SkipSaveBuf(buf, 351);

View File

@ -895,8 +895,8 @@ CPed::ProcessObjective(void)
int chosenModel = CCarCtrl::ChooseModel(&zoneInfo, &ourPos, &chosenCarClass);
CAutomobile *newVeh = new CAutomobile(chosenModel, RANDOM_VEHICLE);
if (newVeh) {
newVeh->GetMatrix().GetPosition() = ThePaths.m_pathNodes[closestNode].GetPosition();
newVeh->GetMatrix().GetPosition().z += 4.0f;
newVeh->GetMatrix()->GetPosition() = ThePaths.m_pathNodes[closestNode].GetPosition();
newVeh->GetMatrix()->GetPosition().z += 4.0f;
newVeh->SetHeading(DEGTORAD(200.0f));
newVeh->SetStatus(STATUS_ABANDONED);
newVeh->m_nDoorLock = CARLOCK_UNLOCKED;
@ -3275,7 +3275,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
CMatrix vehDoorMat(veh->GetMatrix());
vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, GetLocalPositionToOpenCarDoor(veh, m_vehDoor, 0.0f));
// VC couch anims are inverted, so they're fixing it here.
GetMatrix() = vehDoorMat;
GetMatrix().r() = vehDoorMat;
}
}
@ -3695,7 +3695,7 @@ CPed::SetExitBoat(CVehicle *boat)
CColModel* boatCol = boat->GetColModel();
if (boat->IsUpsideDown()) {
newPos = { 0.0f, 0.0f, boatCol->boundingBox.min.z };
newPos = boat->GetMatrix() * newPos;
newPos = boat->GetMatrix().r() * newPos;
newPos.z += 1.0f;
m_vehDoor = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
@ -3950,7 +3950,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
zForPed = Max(foundColZ, foundColZ2);
if (zForPed > -99.0f)
GetMatrix().GetPosition().z = FEET_OFFSET + zForPed;
GetMatrix()->GetPosition().z = FEET_OFFSET + zForPed;
} else {
if (veh->GetUp().z > -0.8f) {
bool addDoorSmoke = false;

View File

@ -3125,22 +3125,22 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
if (carFrontZ < -0.2f) {
// Highest point of car's back
carHighestZ = (car->GetMatrix() * CVector(0.0f, vehColMinY, vehColMaxZ)).z;
carHighestZ = (car->GetMatrix().r() * CVector(0.0f, vehColMinY, vehColMaxZ)).z;
carLength = vehColMaxY - vehColMinY;
} else if (carFrontZ > 0.1f) {
// Highest point of car's front
carHighestZ = (car->GetMatrix() * CVector(0.0f, vehColMaxY, vehColMaxZ)).z;
carHighestZ = (car->GetMatrix().r() * CVector(0.0f, vehColMaxY, vehColMaxZ)).z;
float highestZDist = carHighestZ - GetPosition().z;
if (highestZDist > 0.0f) {
GetMatrix().GetPosition().z += 0.5f * highestZDist;
GetMatrix()->GetPosition().z += 0.5f * highestZDist;
carHighestZ += highestZDist * 0.25f;
}
carLength = vehColMaxY;
} else {
// Highest point of car's front
carHighestZ = (car->GetMatrix() * CVector(0.0f, vehColMaxY, vehColMaxZ)).z;
carHighestZ = (car->GetMatrix().r() * CVector(0.0f, vehColMaxY, vehColMaxZ)).z;
carLength = vehColMaxY;
}

View File

@ -893,8 +893,8 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
default:
break;
}
veh->GetMatrix().GetPosition().z += (movedVehicleCount / 4) * 7.0f;
veh->GetMatrix().GetForward() = RegenerationFront;
veh->GetMatrix()->GetPosition().z += (movedVehicleCount / 4) * 7.0f;
veh->GetMatrix()->GetForward() = RegenerationFront;
((CAutomobile*)veh)->PlaceOnRoadProperly();
CCarCtrl::JoinCarWithRoadSystem(veh);
CTheScripts::ClearSpaceForMissionEntity(veh->GetPosition(), veh);
@ -930,7 +930,7 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
ped->GetPosition().z + 2.0f, &foundGround);
if (foundGround) {
ped->GetMatrix().GetPosition().z = 1.0f + groundZ;
ped->GetMatrix()->GetPosition().z = 1.0f + groundZ;
//ped->GetPosition().z += 0.0f;
CTheScripts::ClearSpaceForMissionEntity(ped->GetPosition(), ped);
}
@ -983,8 +983,8 @@ CPopulation::ConvertToDummyObject(CObject *obj)
{
CDummyObject *dummy = new CDummyObject(obj);
dummy->GetMatrix() = obj->m_objectMatrix;
dummy->GetMatrix().UpdateRW();
dummy->GetMatrix().r() = obj->m_objectMatrix;
dummy->GetMatrix()->UpdateRW();
dummy->UpdateRwFrame();
if (IsGlass(obj->GetModelIndex()))

View File

@ -211,7 +211,7 @@ void CMovingThings::Render()
// ---------- CMovingThing ----------
void CMovingThing::Update()
{
m_pEntity->GetMatrix().UpdateRW();
m_pEntity->GetMatrix()->UpdateRW();
m_pEntity->UpdateRwFrame();
if (SQR(m_pEntity->GetPosition().x - TheCamera.GetPosition().x) + SQR(m_pEntity->GetPosition().y - TheCamera.GetPosition().y) < 40000.0f) {

View File

@ -432,10 +432,10 @@ CGlass::RenderEntityInGlass(CEntity *entity)
ASSERT(col!=nil);
if ( col->numTriangles >= 2 )
{
CVector a = object->GetMatrix() * col->vertices[0].Get();
CVector b = object->GetMatrix() * col->vertices[1].Get();
CVector c = object->GetMatrix() * col->vertices[2].Get();
CVector d = object->GetMatrix() * col->vertices[3].Get();
CVector a = object->GetMatrix().r() * col->vertices[0].Get();
CVector b = object->GetMatrix().r() * col->vertices[1].Get();
CVector c = object->GetMatrix().r() * col->vertices[2].Get();
CVector d = object->GetMatrix().r() * col->vertices[3].Get();
if ( object->bGlassCracked )
{
@ -621,10 +621,10 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
CColModel *col = object->GetColModel();
ASSERT(col!=nil);
CVector a = object->GetMatrix() * col->vertices[0].Get();
CVector b = object->GetMatrix() * col->vertices[1].Get();
CVector c = object->GetMatrix() * col->vertices[2].Get();
CVector d = object->GetMatrix() * col->vertices[3].Get();
CVector a = object->GetMatrix().r() * col->vertices[0].Get();
CVector b = object->GetMatrix().r() * col->vertices[1].Get();
CVector c = object->GetMatrix().r() * col->vertices[2].Get();
CVector d = object->GetMatrix().r() * col->vertices[3].Get();
float minx = Min(Min(a.x, b.x), Min(c.x, d.x));
float maxx = Max(Max(a.x, b.x), Max(c.x, d.x));
@ -656,7 +656,7 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed,
}
object->bGlassBroken = true;
object->GetMatrix().GetPosition().z = -100.0f;
object->GetMatrix()->GetPosition().z = -100.0f;
}
void

View File

@ -5,5 +5,5 @@
void
CInstance::Shutdown()
{
GetMatrix().Detach();
GetMatrix()->Detach();
}

View File

@ -278,9 +278,9 @@ GenericLoad()
qs = saveSize >> 24;
#endif
ReadDataFromBufferPointer(buf, CGame::currLevel);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().y);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().z);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix()->GetPosition().x);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix()->GetPosition().y);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix()->GetPosition().z);
ReadDataFromBufferPointer(buf, CClock::ms_nMillisecondsPerGameMinute);
ReadDataFromBufferPointer(buf, CClock::ms_nLastClockTick);
ReadDataFromBufferPointer(buf, CClock::ms_nGameClockHours);
@ -574,9 +574,9 @@ RestoreForStartLoad()
} else {
uint8 *_buf = buf + sizeof(wchar[24]) + sizeof(SYSTEMTIME) + sizeof(SIZE_OF_ONE_GAME_IN_BYTES);
ReadDataFromBufferPointer(_buf, CGame::currLevel);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix()->GetPosition().x);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix()->GetPosition().y);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix()->GetPosition().z);
ISLAND_LOADING_IS(LOW)
{
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);

View File

@ -303,9 +303,9 @@ CMemoryCard::RestoreForStartLoad(void)
uint8 *pBuf = buf + sizeof(uint32) + sizeof(uint32);
ReadDataFromBufferPointer(pBuf, CGame::currLevel);
ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix().GetPosition().y);
ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix().GetPosition().z);
ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix()->GetPosition().x);
ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix()->GetPosition().y);
ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix()->GetPosition().z);
if ( CGame::currLevel != LEVEL_INDUSTRIAL )
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
@ -371,9 +371,9 @@ CMemoryCard::LoadSavedGame(void)
ReadDataFromBufferPointer(buf, saveSize);
ReadDataFromBufferPointer(buf, CGame::currLevel);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().y);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().z);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix()->GetPosition().x);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix()->GetPosition().y);
ReadDataFromBufferPointer(buf, TheCamera.GetMatrix()->GetPosition().z);
ReadDataFromBufferPointer(buf, CClock::ms_nMillisecondsPerGameMinute);
ReadDataFromBufferPointer(buf, CClock::ms_nLastClockTick);
ReadDataFromBufferPointer(buf, CClock::ms_nGameClockHours);

View File

@ -3168,7 +3168,7 @@ CAutomobile::RcbanditCheck1CarWheels(CPtrList &list)
CColSphere sph;
mi->GetWheelPosn(i, wheelPos);
matW2B = Invert(GetMatrix());
sph.center = matW2B * (car->GetMatrix() * wheelPos);
sph.center = matW2B * (car->GetMatrix().r() * wheelPos);
sph.radius = mi->m_wheelScale*0.25f;
if(CCollision::TestSphereBox(sph, colModel->boundingBox))
return 1;
@ -3219,10 +3219,10 @@ CAutomobile::PlaceOnRoadProperly(void)
float c = Cos(angle);
float s = Sin(angle);
GetMatrix().GetRight() = CVector((front.y - rear.y) / len, -(front.x - rear.x) / len, 0.0f);
GetMatrix().GetForward() = CVector(-c * GetRight().y, c * GetRight().x, s);
GetMatrix().GetUp() = CrossProduct(GetRight(), GetForward());
GetMatrix().GetPosition() = CVector((front.x + rear.x) / 2.0f, (front.y + rear.y) / 2.0f, (frontZ + rearZ) / 2.0f + GetHeightAboveRoad());
GetMatrix()->GetRight() = CVector((front.y - rear.y) / len, -(front.x - rear.x) / len, 0.0f);
GetMatrix()->GetForward() = CVector(-c * GetRight().y, c * GetRight().x, s);
GetMatrix()->GetUp() = CrossProduct(GetRight(), GetForward());
GetMatrix()->GetPosition() = CVector((front.x + rear.x) / 2.0f, (front.y + rear.y) / 2.0f, (frontZ + rearZ) / 2.0f + GetHeightAboveRoad());
}
void
@ -4264,7 +4264,7 @@ CPed::MakeTyresMuddySectorList(CPtrList &list)
}
// I hope so
CVector wheelPos = veh->GetMatrix() * approxWheelOffset;
CVector wheelPos = veh->GetMatrix().r() * approxWheelOffset;
if (Abs(wheelPos.z - GetPosition().z) < 2.0f) {
if ((wheelPos - GetPosition()).MagnitudeSqr2D() < 1.0f) {
@ -4532,7 +4532,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
if(GetUp().z > 0.0f){
// simulate fast upward movement if going fast
float speed = CVector2D(m_vecMoveSpeed).Magnitude();
obj->GetMatrix().Translate(GetUp()*speed);
obj->GetMatrix()->Translate(GetUp()*speed);
}
}
obj->ApplyMoveForce(dist);

View File

@ -526,8 +526,8 @@ CBoat::ProcessControl(void)
}else{
// is this some inlined CPlaceable method?
CVector pos = GetPosition();
GetMatrix().RotateZ(m_fOrientation - GetForward().Heading());
GetMatrix().SetTranslateOnly(pos);
GetMatrix()->RotateZ(m_fOrientation - GetForward().Heading());
GetMatrix()->SetTranslateOnly(pos);
}
}
@ -687,7 +687,7 @@ CBoat::BlowUpCar(CEntity *culprit)
dist.Normalise();
if(GetUp().z > 0.0f)
dist += GetUp();
obj->GetMatrix().GetPosition() += dist;
obj->GetMatrix()->GetPosition() += dist;
CWorld::Add(obj);
@ -779,7 +779,7 @@ CBoat::RenderWaterOutPolys(void)
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
}
if (!CVehicle::bWheelsOnlyCheat && RwIm3DTransform(KeepWaterOutVertices, 4, GetMatrix().m_attachment, rwIM3D_VERTEXUV)) {
if (!CVehicle::bWheelsOnlyCheat && RwIm3DTransform(KeepWaterOutVertices, 4, GetMatrix()->m_attachment, rwIM3D_VERTEXUV)) {
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, KeepWaterOutIndices, 6);
RwIm3DEnd();
}

View File

@ -75,7 +75,7 @@ void CCranes::InitCranes(void)
void CCranes::AddThisOneCrane(CEntity* pEntity)
{
pEntity->GetMatrix().ResetOrientation();
pEntity->GetMatrix()->ResetOrientation();
if (NumCranes >= NUM_CRANES)
return;
CCrane* pCrane = &aCranes[NumCranes];
@ -386,7 +386,7 @@ void CCrane::Update(void)
m_pCraneEntity->GetForward().y = fCos;
m_pCraneEntity->GetRight().y = fSin;
m_pCraneEntity->GetForward().x = -fSin;
m_pCraneEntity->GetMatrix().UpdateRW();
m_pCraneEntity->GetMatrix()->UpdateRW();
m_pCraneEntity->UpdateRwFrame();
SetHookMatrix();
}
@ -405,7 +405,7 @@ bool CCrane::RotateCarriedCarProperly()
float fDeltaThisFrame = CAR_ROTATION_SPEED * CTimer::GetTimeStep();
if (Abs(fAngleDelta) <= fDeltaThisFrame) // no rotation is actually applied?
return true;
m_pVehiclePickedUp->GetMatrix().RotateZ(fAngleDelta < 0 ? -fDeltaThisFrame : fDeltaThisFrame);
m_pVehiclePickedUp->GetMatrix()->RotateZ(fAngleDelta < 0 ? -fDeltaThisFrame : fDeltaThisFrame);
return false;
}
@ -586,7 +586,7 @@ void CCrane::FindParametersForTarget(float X, float Y, float Z, float* pAngle, f
*pHeight = Z;
}
void CCrane::CalcHookCoordinates(float* pX, float* pY, float* pZ)
void CCrane::CalcHookCoordinates(rw::float32W* pX, float* pY, float* pZ)
{
*pX = Cos(m_fHookAngle) * m_fHookOffset + m_pCraneEntity->GetPosition().x;
*pY = Sin(m_fHookAngle) * m_fHookOffset + m_pCraneEntity->GetPosition().y;
@ -604,7 +604,7 @@ void CCrane::SetHookMatrix()
m_pHook->GetForward() = CrossProduct(up, m_pHook->GetRight());
m_pHook->GetUp() = up;
m_pHook->SetOrientation(0.0f, 0.0f, -HALFPI);
m_pHook->GetMatrix().UpdateRW();
m_pHook->GetMatrix()->UpdateRW();
m_pHook->UpdateRwFrame();
CWorld::Remove(m_pHook);
CWorld::Add(m_pHook);
@ -706,34 +706,34 @@ void CCranes::Load(uint8* buf, uint32 size)
aCranes[i].m_pCraneEntity = tmp != 0 ? CPools::GetBuildingPool()->GetSlot(tmp - 1) : nil;
ReadSaveBuf(&tmp, buf);
aCranes[i].m_pHook = tmp != 0 ? CPools::GetObjectPool()->GetSlot(tmp - 1) : nil;
ReadSaveBuf(&aCranes[i].m_nAudioEntity, buf);
ReadSaveBuf(&aCranes[i].m_fPickupX1, buf);
ReadSaveBuf(&aCranes[i].m_fPickupX2, buf);
ReadSaveBuf(&aCranes[i].m_fPickupY1, buf);
ReadSaveBuf(&aCranes[i].m_fPickupY2, buf);
ReadSaveBuf(&aCranes[i].m_vecDropoffTarget, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffHeading, buf);
ReadSaveBuf(&aCranes[i].m_fPickupAngle, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffAngle, buf);
ReadSaveBuf(&aCranes[i].m_fPickupDistance, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffDistance, buf);
ReadSaveBuf(&aCranes[i].m_fPickupHeight, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffHeight, buf);
ReadSaveBuf(&aCranes[i].m_fHookAngle, buf);
ReadSaveBuf(&aCranes[i].m_fHookOffset, buf);
ReadSaveBuf(&aCranes[i].m_fHookHeight, buf);
ReadSaveBuf(&aCranes[i].m_vecHookInitPos, buf);
ReadSaveBuf(&aCranes[i].m_vecHookCurPos, buf);
ReadSaveBuf(&aCranes[i].m_nAudioEntity, buf);
ReadSaveBuf(&aCranes[i].m_fPickupX1, buf);
ReadSaveBuf(&aCranes[i].m_fPickupX2, buf);
ReadSaveBuf(&aCranes[i].m_fPickupY1, buf);
ReadSaveBuf(&aCranes[i].m_fPickupY2, buf);
ReadSaveBuf(&aCranes[i].m_vecDropoffTarget, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffHeading, buf);
ReadSaveBuf(&aCranes[i].m_fPickupAngle, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffAngle, buf);
ReadSaveBuf(&aCranes[i].m_fPickupDistance, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffDistance, buf);
ReadSaveBuf(&aCranes[i].m_fPickupHeight, buf);
ReadSaveBuf(&aCranes[i].m_fDropoffHeight, buf);
ReadSaveBuf(&aCranes[i].m_fHookAngle, buf);
ReadSaveBuf(&aCranes[i].m_fHookOffset, buf);
ReadSaveBuf(&aCranes[i].m_fHookHeight, buf);
ReadSaveBuf(&aCranes[i].m_vecHookInitPos, buf);
ReadSaveBuf(&aCranes[i].m_vecHookCurPos, buf);
ReadSaveBuf(&aCranes[i].m_vecHookVelocity, buf);
ReadSaveBuf(&tmp, buf);
aCranes[i].m_pVehiclePickedUp = tmp != 0 ? CPools::GetVehiclePool()->GetSlot(tmp - 1) : nil;
ReadSaveBuf(&aCranes[i].m_nTimeForNextCheck, buf);
ReadSaveBuf(&aCranes[i].m_nCraneStatus, buf);
ReadSaveBuf(&aCranes[i].m_nCraneState, buf);
ReadSaveBuf(&aCranes[i].m_nVehiclesCollected, buf);
ReadSaveBuf(&aCranes[i].m_bIsCrusher, buf);
ReadSaveBuf(&aCranes[i].m_bIsMilitaryCrane, buf);
ReadSaveBuf(&aCranes[i].m_bWasMilitaryCrane, buf);
ReadSaveBuf(&aCranes[i].m_nTimeForNextCheck, buf);
ReadSaveBuf(&aCranes[i].m_nCraneStatus, buf);
ReadSaveBuf(&aCranes[i].m_nCraneState, buf);
ReadSaveBuf(&aCranes[i].m_nVehiclesCollected, buf);
ReadSaveBuf(&aCranes[i].m_bIsCrusher, buf);
ReadSaveBuf(&aCranes[i].m_bIsMilitaryCrane, buf);
ReadSaveBuf(&aCranes[i].m_bWasMilitaryCrane, buf);
ReadSaveBuf(&aCranes[i].m_bIsTop, buf);
SkipSaveBuf(buf, 1);
#else

View File

@ -1,4 +1,5 @@
#pragma once
#include "../../vendor/librw/src/rwbase.h"
#include "common.h"
#include "World.h"
@ -63,7 +64,7 @@ public:
bool GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, float fTargetHeight, float fSpeedMultiplier = 1.0f);
bool GoTowardsHeightTarget(float fTargetHeight, float fSpeedMultiplier = 1.0f);
void FindParametersForTarget(float X, float Y, float Z, float* pAngle, float* pDistance, float* pHeight);
void CalcHookCoordinates(float* pX, float* pY, float* pZ);
void CalcHookCoordinates(rw::float32W* pX, float* pY, float* pZ);
void SetHookMatrix(void);
float GetHeightToPickup() { return 4.0f + m_fPickupHeight + (m_bIsCrusher ? 4.5f : 0.0f); };

View File

@ -144,11 +144,11 @@ CHeli::ProcessControl(void)
if(GetPosition().z > 31.55f)
break;
m_pathState = 7;
GetMatrix().GetPosition().z = 31.55f;
GetMatrix()->GetPosition().z = 31.55f;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
break;
case 7:
GetMatrix().GetPosition().z = 31.55f;
GetMatrix()->GetPosition().z = 31.55f;
target = GetPosition();
break;
@ -214,8 +214,8 @@ CHeli::ProcessControl(void)
vTargetDist = target - GetPosition();
m_fTargetZ = target.z;
if(m_pathState == 6){
GetMatrix().GetPosition().x = GetMatrix().GetPosition().x*0.99f + target.x*0.01f;
GetMatrix().GetPosition().y = GetMatrix().GetPosition().y*0.99f + target.y*0.01f;
GetMatrix()->GetPosition().x = GetMatrix()->GetPosition().x*0.99f + target.x*0.01f;
GetMatrix()->GetPosition().y = GetMatrix()->GetPosition().y*0.99f + target.y*0.01f;
}
}else{
vTargetDist = FindPlayerCoors() - GetPosition();
@ -369,8 +369,8 @@ CHeli::ProcessControl(void)
m_vecMoveSpeed.x += speedDir.x*speedInc;
m_vecMoveSpeed.y += speedDir.y*speedInc;
}
GetMatrix().GetPosition().x += m_vecMoveSpeed.x*CTimer::GetTimeStep();
GetMatrix().GetPosition().y += m_vecMoveSpeed.y*CTimer::GetTimeStep();
GetMatrix()->GetPosition().x += m_vecMoveSpeed.x*CTimer::GetTimeStep();
GetMatrix()->GetPosition().y += m_vecMoveSpeed.y*CTimer::GetTimeStep();
// Find z target
if(m_heliStatus == HELI_STATUS_FLY_AWAY)
@ -391,7 +391,7 @@ CHeli::ProcessControl(void)
m_vecMoveSpeed.z -= speedIncZ;
else
m_vecMoveSpeed.z += speedIncZ*1.5f;
GetMatrix().GetPosition().z += m_vecMoveSpeed.z*CTimer::GetTimeStep();
GetMatrix()->GetPosition().z += m_vecMoveSpeed.z*CTimer::GetTimeStep();
// Find angular speed
float targetAngularSpeed;
@ -553,7 +553,7 @@ CHeli::ProcessControl(void)
RemoveAndAdd();
bIsInSafePosition = true;
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
}
@ -817,9 +817,9 @@ CHeli::GenerateHeli(bool catalina)
}
heliPos.z += 50.0f;
}
heli->GetMatrix().SetTranslate(heliPos);
heli->GetMatrix()->SetTranslate(heliPos);
if(catalina)
heli->GetMatrix().SetRotateZOnly(DEGTORAD(270.0f)); // game actually uses 3.14 here
heli->GetMatrix()->SetRotateZOnly(DEGTORAD(270.0f)); // game actually uses 3.14 here
heli->SetStatus(STATUS_ABANDONED);
heli->bIsLocked = true;

View File

@ -106,7 +106,7 @@ void
CPlane::DeleteRwObject(void)
{
if(m_rwObject && RwObjectGetType(m_rwObject) == rpATOMIC){
GetMatrix().Detach();
GetMatrix()->Detach();
if(RwObjectGetType(m_rwObject) == rpATOMIC){ // useless check
RwFrame *f = RpAtomicGetFrame((RpAtomic*)m_rwObject);
RpAtomicDestroy((RpAtomic*)m_rwObject);
@ -365,8 +365,8 @@ CPlane::ProcessControl(void)
CVector posFront2 = (1.0f - f)*pPathNodes[curPathNodeFront2].p + f*pPathNodes[nextPathNodeFront2].p;
// Now set matrix
GetMatrix().SetTranslateOnly((posRear + posFront) / 2.0f);
GetMatrix().GetPosition().z += 4.3f;
GetMatrix()->SetTranslateOnly((posRear + posFront) / 2.0f);
GetMatrix()->GetPosition().z += 4.3f;
CVector fwd = posFront - posRear;
fwd.Normalise();
if(pitch != 0.0f){
@ -381,9 +381,9 @@ CPlane::ProcessControl(void)
right.z += 3.0f*roll.z;
right.Normalise();
CVector up = CrossProduct(right, fwd);
GetMatrix().GetRight() = right;
GetMatrix().GetUp() = up;
GetMatrix().GetForward() = fwd;
GetMatrix()->GetRight() = right;
GetMatrix()->GetUp() = up;
GetMatrix()->GetForward() = fwd;
// Set speed
m_vecMoveSpeed = fwd*PlanePathSpeed[m_nPlaneId]/60.0f;
@ -517,8 +517,8 @@ CPlane::ProcessControl(void)
CVector posFront2 = (1.0f - f)*pathNodes[curPathNodeFront2].p + f*pathNodes[nextPathNodeFront2].p;
// Now set matrix
GetMatrix().SetTranslateOnly((posRear + posFront) / 2.0f);
GetMatrix().GetPosition().z += 1.0f;
GetMatrix()->SetTranslateOnly((posRear + posFront) / 2.0f);
GetMatrix()->GetPosition().z += 1.0f;
CVector fwd = posFront - posRear;
fwd.Normalise();
CVector fwd2 = posFront2 - posRear;
@ -528,9 +528,9 @@ CPlane::ProcessControl(void)
right.z += 3.0f*roll.z;
right.Normalise();
CVector up = CrossProduct(right, fwd);
GetMatrix().GetRight() = right;
GetMatrix().GetUp() = up;
GetMatrix().GetForward() = fwd;
GetMatrix()->GetRight() = right;
GetMatrix()->GetUp() = up;
GetMatrix()->GetForward() = fwd;
// Set speed
m_vecMoveSpeed = fwd*planePathSpeed/60.0f;
@ -542,7 +542,7 @@ CPlane::ProcessControl(void)
}
bIsInSafePosition = true;
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
// Handle streaming and such
@ -556,13 +556,13 @@ CPlane::ProcessControl(void)
m_rwObject = CModelInfo::GetModelInfo(mi->m_planeLodId)->CreateInstance();
POP_MEMID();
if(m_rwObject)
GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)));
GetMatrix()->AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)m_rwObject)));
}
}
}else if(CStreaming::HasModelLoaded(GetModelIndex())){
if(m_rwObject && RwObjectGetType(m_rwObject) == rpATOMIC){
// Get rid of LOD model
GetMatrix().Detach();
GetMatrix()->Detach();
if(m_rwObject){ // useless check
if(RwObjectGetType(m_rwObject) == rpATOMIC){ // useless check
RwFrame *f = RpAtomicGetFrame((RpAtomic*)m_rwObject);
@ -761,7 +761,7 @@ CPlane::InitPlanes(void)
for(i = 0; i < 3; i++){
CPlane *plane = new CPlane(MI_AIRTRAIN, PERMANENT_VEHICLE);
plane->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
plane->GetMatrix()->SetTranslate(0.0f, 0.0f, 0.0f);
plane->SetStatus(STATUS_ABANDONED);
plane->bIsLocked = true;
plane->m_nPlaneId = i;
@ -775,7 +775,7 @@ CPlane::InitPlanes(void)
for(i = 0; i < 3; i++){
CPlane *plane = new CPlane(MI_DEADDODO, PERMANENT_VEHICLE);
plane->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
plane->GetMatrix()->SetTranslate(0.0f, 0.0f, 0.0f);
plane->SetStatus(STATUS_ABANDONED);
plane->bIsLocked = true;
plane->m_nPlaneId = i;
@ -933,7 +933,7 @@ CPlane::CreateIncomingCesna(void)
pDrugRunCesna = nil;
}
pDrugRunCesna = new CPlane(MI_DEADDODO, PERMANENT_VEHICLE);
pDrugRunCesna->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
pDrugRunCesna->GetMatrix()->SetTranslate(0.0f, 0.0f, 0.0f);
pDrugRunCesna->SetStatus(STATUS_ABANDONED);
pDrugRunCesna->bIsLocked = true;
pDrugRunCesna->m_nPlaneId = 0;
@ -955,7 +955,7 @@ CPlane::CreateDropOffCesna(void)
pDropOffCesna = nil;
}
pDropOffCesna = new CPlane(MI_DEADDODO, PERMANENT_VEHICLE);
pDropOffCesna->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
pDropOffCesna->GetMatrix()->SetTranslate(0.0f, 0.0f, 0.0f);
pDropOffCesna->SetStatus(STATUS_ABANDONED);
pDropOffCesna->bIsLocked = true;
pDropOffCesna->m_nPlaneId = 0;

View File

@ -236,7 +236,7 @@ CTrain::ProcessControl(void)
break;
}
GetMatrix().UpdateRW();
GetMatrix()->UpdateRW();
UpdateRwFrame();
RemoveAndAdd();
@ -446,7 +446,7 @@ CTrain::InitTrains(void)
int16 wagonGroup[] = { 0, 0, 0, 1, 1 };
for(i = 0; i < 5; i++){
train = new CTrain(MI_TRAIN, PERMANENT_VEHICLE);
train->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
train->GetMatrix()->SetTranslate(0.0f, 0.0f, 0.0f);
train->SetStatus(STATUS_ABANDONED);
train->bIsLocked = true;
train->m_fWagonPosition = wagonPositions[i];
@ -465,7 +465,7 @@ CTrain::InitTrains(void)
int16 wagonGroup_S[] = { 0, 0, 1, 1, 2, 2, 3, 3 };
for(i = 0; i < 8; i++){
train = new CTrain(MI_TRAIN, PERMANENT_VEHICLE);
train->GetMatrix().SetTranslate(0.0f, 0.0f, 0.0f);
train->GetMatrix()->SetTranslate(0.0f, 0.0f, 0.0f);
train->SetStatus(STATUS_ABANDONED);
train->bIsLocked = true;
train->m_fWagonPosition = wagonPositions_S[i];

View File

@ -1340,7 +1340,7 @@ CVehicle::Load(uint8*& buf)
ReadSaveBuf(&tmp.GetPosition().x, buf);
ReadSaveBuf(&tmp.GetPosition().y, buf);
ReadSaveBuf(&tmp.GetPosition().z, buf);
m_matrix = tmp;
SetMatrix(tmp);
SkipSaveBuf(buf, 16);
LoadEntityFlags(buf);
SkipSaveBuf(buf, 212);

View File

@ -134,7 +134,7 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
if (!fireSource)
{
fireOffset = shooter->GetMatrix() * fireOffset;
fireOffset = shooter->GetMatrix().r() * fireOffset;
#ifdef FIX_BUGS
static CVector tmp;
tmp = fireOffset;
@ -1722,24 +1722,24 @@ CWeapon::FireInstantHitFromCar(CAutomobile *shooter, bool left)
CVector source, target;
if ( left )
{
source = shooter->GetMatrix() * CVector(-shooter->GetColModel()->boundingBox.max.x + -0.2f,
source = shooter->GetMatrix().r() * CVector(-shooter->GetColModel()->boundingBox.max.x + -0.2f,
float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y,
modelInfo->GetFrontSeatPosn().z + 0.5f);
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
target = shooter->GetMatrix() * CVector(-info->m_fRange,
target = shooter->GetMatrix().r() * CVector(-info->m_fRange,
modelInfo->GetFrontSeatPosn().y,
modelInfo->GetFrontSeatPosn().z + 0.5f);
}
else
{
source = shooter->GetMatrix() * CVector(shooter->GetColModel()->boundingBox.max.x + 0.2f,
source = shooter->GetMatrix().r() * CVector(shooter->GetColModel()->boundingBox.max.x + 0.2f,
float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y,
modelInfo->GetFrontSeatPosn().z + 0.5f);
source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed;
target = shooter->GetMatrix() * CVector(info->m_fRange,
target = shooter->GetMatrix().r() * CVector(info->m_fRange,
modelInfo->GetFrontSeatPosn().y,
modelInfo->GetFrontSeatPosn().z + 0.5f);
}
@ -2302,7 +2302,7 @@ CWeapon::HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo)
if (fireSource)
source = *fireSource;
else
source = holder->GetMatrix() * adjustedOffset;
source = holder->GetMatrix().r() * adjustedOffset;
CEntity *aimEntity = aimingTo ? aimingTo : ((CPed*)holder)->m_pSeekTarget;
ASSERT(aimEntity!=nil);

View File

@ -1,5 +1,7 @@
#pragma once
extern void stacktrace();
#include "common_defines.h"
#ifndef RW_PS2
@ -238,9 +240,61 @@ inline V2d scale(const V2d &a, float32 r) { return makeV2d(a.x*r, a.y*r); }
inline float32 length(const V2d &v) { return sqrtf(v.x*v.x + v.y*v.y); }
inline V2d normalize(const V2d &v) { return scale(v, 1.0f/length(v)); }
struct float32W {
float32 v;
operator float32() const { return v; }
float32W operator=(float32 f) {
if (std::isnan(f)) {
fprintf(stderr, "float32W: f is NaN\n");
stacktrace();
}
v = f;
return *this;
}
//operastor+=(float32 f)
float32W operator+=(float32 f) {
if (std::isnan(f)) {
fprintf(stderr, "float32W: f is NaN1\n");
stacktrace();
}
v += f;
return *this;
}
float32W operator-=(float32 f) {
if (std::isnan(f)) {
fprintf(stderr, "float32W: f is NaN2\n");
stacktrace();
}
v -= f;
return *this;
}
float32W operator*=(float32 f) {
if (std::isnan(f)) {
fprintf(stderr, "float32W: f is NaN3\n");
stacktrace();
}
v *= f;
return *this;
}
float32W operator/=(float32 f) {
if (std::isnan(f)) {
fprintf(stderr, "float32W: f is NaN4\n");
stacktrace();
}
v /= f;
return *this;
}
};
struct V3d
{
float32 x, y, z;
float32W x;
float32 y, z;
void set(float32 x, float32 y, float32 z){
this->x = x; this->y = y; this->z = z; }
static void transformPoints(V3d *out, const V3d *in, int32 n, const Matrix *m);