mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-23 09:39:16 +01:00
More CWorld fixes
This commit is contained in:
parent
03247ce98f
commit
e777f24064
@ -30,7 +30,7 @@
|
|||||||
#include "ParticleObject.h"
|
#include "ParticleObject.h"
|
||||||
#include "EventList.h"
|
#include "EventList.h"
|
||||||
|
|
||||||
#define OBJECT_REPOSITION_OFFSET_Z 0.2f
|
#define OBJECT_REPOSITION_OFFSET_Z 2.0f
|
||||||
|
|
||||||
CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
|
CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
|
||||||
|
|
||||||
@ -738,9 +738,9 @@ CWorld::FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const
|
|||||||
pEntity->m_scanCode = ms_nCurrentScanCode;
|
pEntity->m_scanCode = ms_nCurrentScanCode;
|
||||||
float fMagnitude = 0.0f;
|
float fMagnitude = 0.0f;
|
||||||
if (bCheck2DOnly)
|
if (bCheck2DOnly)
|
||||||
fMagnitude = CVector2D(position - pEntity->GetPosition()).Magnitude();
|
fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr2D();
|
||||||
else
|
else
|
||||||
fMagnitude = CVector(position - pEntity->GetPosition()).Magnitude();
|
fMagnitude = (position - pEntity->GetPosition()).MagnitudeSqr();
|
||||||
if (fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) {
|
if (fMagnitude < radius * radius && *nEntitiesFound < maxEntitiesToFind) {
|
||||||
if (aEntities)
|
if (aEntities)
|
||||||
aEntities[*nEntitiesFound] = pEntity;
|
aEntities[*nEntitiesFound] = pEntity;
|
||||||
@ -1044,9 +1044,9 @@ CWorld::FindObjectsKindaCollidingSectorList(CPtrList& list, const CVector& posit
|
|||||||
pEntity->m_scanCode = ms_nCurrentScanCode;
|
pEntity->m_scanCode = ms_nCurrentScanCode;
|
||||||
float fMagnitude = 0.0f;
|
float fMagnitude = 0.0f;
|
||||||
if (bCheck2DOnly)
|
if (bCheck2DOnly)
|
||||||
fMagnitude = CVector2D(position - pEntity->GetPosition()).Magnitude();
|
fMagnitude = (position - pEntity->GetPosition()).Magnitude2D();
|
||||||
else
|
else
|
||||||
fMagnitude = CVector(position - pEntity->GetPosition()).Magnitude();
|
fMagnitude = (position - pEntity->GetPosition()).Magnitude();
|
||||||
if (pEntity->GetBoundRadius() + radius > fMagnitude && *nCollidingEntities < maxEntitiesToFind) {
|
if (pEntity->GetBoundRadius() + radius > fMagnitude && *nCollidingEntities < maxEntitiesToFind) {
|
||||||
if (aEntities)
|
if (aEntities)
|
||||||
aEntities[*nCollidingEntities] = pEntity;
|
aEntities[*nCollidingEntities] = pEntity;
|
||||||
@ -1162,7 +1162,7 @@ CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList(CPtrList& list, cons
|
|||||||
if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) {
|
if (pEntity->m_scanCode != CWorld::ms_nCurrentScanCode) {
|
||||||
pEntity->m_scanCode = CWorld::ms_nCurrentScanCode;
|
pEntity->m_scanCode = CWorld::ms_nCurrentScanCode;
|
||||||
CColSphere sphere;
|
CColSphere sphere;
|
||||||
CVector vecDistance = pEntity->m_matrix.GetPosition() - position;
|
CVector vecDistance = pEntity->GetPosition() - position;
|
||||||
sphere.radius = pEntity->GetBoundRadius();
|
sphere.radius = pEntity->GetBoundRadius();
|
||||||
sphere.center = Multiply3x3(vecDistance, matrix);
|
sphere.center = Multiply3x3(vecDistance, matrix);
|
||||||
if (CCollision::TestSphereBox(sphere, boundingBox) && *nEntitiesFound < maxEntitiesToFind) {
|
if (CCollision::TestSphereBox(sphere, boundingBox) && *nEntitiesFound < maxEntitiesToFind) {
|
||||||
@ -1226,7 +1226,7 @@ CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList& list, const CVec
|
|||||||
fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z &&
|
fRadius + entityPos.z >= vecStartPos.z && entityPos.z - fRadius <= vecEndPos.z &&
|
||||||
*nIntersecting < maxEntitiesToFind) {
|
*nIntersecting < maxEntitiesToFind) {
|
||||||
if (aEntities)
|
if (aEntities)
|
||||||
aEntities[*nIntersecting] = (CEntity*)pEntity;
|
aEntities[*nIntersecting] = pEntity;
|
||||||
++*nIntersecting;
|
++*nIntersecting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1402,7 +1402,7 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1
|
|||||||
CVehicle *pVehicle = (CVehicle*)pNode->item;
|
CVehicle *pVehicle = (CVehicle*)pNode->item;
|
||||||
if (pVehicle->m_scanCode != CWorld::ms_nCurrentScanCode) {
|
if (pVehicle->m_scanCode != CWorld::ms_nCurrentScanCode) {
|
||||||
pVehicle->m_scanCode = CWorld::ms_nCurrentScanCode;
|
pVehicle->m_scanCode = CWorld::ms_nCurrentScanCode;
|
||||||
const CVector& vehiclePos = pVehicle->m_matrix.GetPosition();
|
const CVector& vehiclePos = pVehicle->GetPosition();
|
||||||
eCarMission carMission = pVehicle->AutoPilot.m_nCarMission;
|
eCarMission carMission = pVehicle->AutoPilot.m_nCarMission;
|
||||||
if (pVehicle != FindPlayerVehicle() &&
|
if (pVehicle != FindPlayerVehicle() &&
|
||||||
vehiclePos.x > fStartX && vehiclePos.x < fEndX &&
|
vehiclePos.x > fStartX && vehiclePos.x < fEndX &&
|
||||||
@ -1422,11 +1422,11 @@ CWorld::CallOffChaseForAreaSectorListVehicles(CPtrList& list, float x1, float y1
|
|||||||
// Maybe break the loop when bInsideSphere is set to true?
|
// Maybe break the loop when bInsideSphere is set to true?
|
||||||
}
|
}
|
||||||
if (bInsideSphere) {
|
if (bInsideSphere) {
|
||||||
if (pVehicle->m_matrix.GetPosition().x <= (x1 + x2) * 0.5f)
|
if (pVehicle->GetPosition().x <= (x1 + x2) * 0.5f)
|
||||||
pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f);
|
pVehicle->m_vecMoveSpeed.x = min(pVehicle->m_vecMoveSpeed.x, 0.0f);
|
||||||
else
|
else
|
||||||
pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f);
|
pVehicle->m_vecMoveSpeed.x = max(pVehicle->m_vecMoveSpeed.x, 0.0f);
|
||||||
if (pVehicle->m_matrix.GetPosition().y <= (y1 + y2) * 0.5f)
|
if (pVehicle->GetPosition().y <= (y1 + y2) * 0.5f)
|
||||||
pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f);
|
pVehicle->m_vecMoveSpeed.y = min(pVehicle->m_vecMoveSpeed.y, 0.0f);
|
||||||
else
|
else
|
||||||
pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f);
|
pVehicle->m_vecMoveSpeed.y = max(pVehicle->m_vecMoveSpeed.y, 0.0f);
|
||||||
@ -1573,8 +1573,8 @@ CWorld::AddParticles(void)
|
|||||||
for (int32 y = 0; y < NUMSECTORS_Y; y++) {
|
for (int32 y = 0; y < NUMSECTORS_Y; y++) {
|
||||||
for (int32 x = 0; x < NUMSECTORS_X; x++) {
|
for (int32 x = 0; x < NUMSECTORS_X; x++) {
|
||||||
CSector* pSector = GetSector(x, y);
|
CSector* pSector = GetSector(x, y);
|
||||||
CEntity::AddSteamsFromGround1(pSector->m_lists[ENTITYLIST_BUILDINGS]);
|
CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]);
|
||||||
CEntity::AddSteamsFromGround1(pSector->m_lists[ENTITYLIST_DUMMIES]);
|
CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1784,7 +1784,7 @@ CWorld::RepositionOneObject(CEntity* pEntity)
|
|||||||
|| modelId == MI_FIRE_HYDRANT
|
|| modelId == MI_FIRE_HYDRANT
|
||||||
|| modelId == MI_BOLLARDLIGHT
|
|| modelId == MI_BOLLARDLIGHT
|
||||||
|| modelId == MI_PARKTABLE) {
|
|| modelId == MI_PARKTABLE) {
|
||||||
CVector& position = pEntity->m_matrix.GetPosition();
|
CVector& position = pEntity->GetPosition();
|
||||||
float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z;
|
float fBoundingBoxMinZ = pEntity->GetColModel()->boundingBox.min.z;
|
||||||
position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ;
|
position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, nil) - fBoundingBoxMinZ;
|
||||||
pEntity->m_matrix.UpdateRW();
|
pEntity->m_matrix.UpdateRW();
|
||||||
@ -1792,13 +1792,13 @@ CWorld::RepositionOneObject(CEntity* pEntity)
|
|||||||
} else if (modelId == MI_BUOY) {
|
} else if (modelId == MI_BUOY) {
|
||||||
float fWaterLevel = 0.0f;
|
float fWaterLevel = 0.0f;
|
||||||
bool bFound = true;
|
bool bFound = true;
|
||||||
const CVector& position = pEntity->m_matrix.GetPosition();
|
const CVector& position = pEntity->GetPosition();
|
||||||
float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound);
|
float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound);
|
||||||
if (CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) {
|
if (CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &fWaterLevel)) {
|
||||||
if (!bFound || fWaterLevel > fGroundZ) {
|
if (!bFound || fWaterLevel > fGroundZ) {
|
||||||
CColModel* pColModel = pEntity->GetColModel();
|
CColModel* pColModel = pEntity->GetColModel();
|
||||||
float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z;
|
float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z;
|
||||||
pEntity->m_matrix.GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
|
pEntity->GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2075,7 +2075,7 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa
|
|||||||
CPtrNode* pNode = list.first;
|
CPtrNode* pNode = list.first;
|
||||||
while (pNode) {
|
while (pNode) {
|
||||||
CPhysical* pEntity = (CPhysical*)pNode->item;
|
CPhysical* pEntity = (CPhysical*)pNode->item;
|
||||||
CVector vecDistance = pEntity->m_matrix.GetPosition() - position;
|
CVector vecDistance = pEntity->GetPosition() - position;
|
||||||
float fMagnitude = vecDistance.Magnitude();
|
float fMagnitude = vecDistance.Magnitude();
|
||||||
if (fRadius > fMagnitude) {
|
if (fRadius > fMagnitude) {
|
||||||
CWeapon::BlowUpExplosiveThings(pEntity);
|
CWeapon::BlowUpExplosiveThings(pEntity);
|
||||||
@ -2096,7 +2096,7 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa
|
|||||||
if (pEntity->IsObject() && modelId != MI_EXPLODINGBARREL && modelId != MI_PETROLPUMP)
|
if (pEntity->IsObject() && modelId != MI_EXPLODINGBARREL && modelId != MI_PETROLPUMP)
|
||||||
pObject->bHasBeenDamaged = true;
|
pObject->bHasBeenDamaged = true;
|
||||||
} else {
|
} else {
|
||||||
CVector pos = pEntity->m_matrix.GetPosition();
|
CVector pos = pEntity->GetPosition();
|
||||||
pos.z -= 0.5f;
|
pos.z -= 0.5f;
|
||||||
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, pos, true);
|
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, pos, true);
|
||||||
pObject->bHasBeenDamaged = true;
|
pObject->bHasBeenDamaged = true;
|
||||||
@ -2122,7 +2122,7 @@ CWorld::TriggerExplosionSectorList(CPtrList& list, const CVector& position, floa
|
|||||||
pEntity->ApplyMoveForce(vecForceDir);
|
pEntity->ApplyMoveForce(vecForceDir);
|
||||||
if (!pEntity->bPedPhysics) {
|
if (!pEntity->bPedPhysics) {
|
||||||
float fBoundRadius = pEntity->GetBoundRadius();
|
float fBoundRadius = pEntity->GetBoundRadius();
|
||||||
float fDistanceZ = position.z - pEntity->m_matrix.GetPosition().z;
|
float fDistanceZ = position.z - pEntity->GetPosition().z;
|
||||||
float fPointZ = fBoundRadius;
|
float fPointZ = fBoundRadius;
|
||||||
if (max(fDistanceZ, -fBoundRadius) < fBoundRadius)
|
if (max(fDistanceZ, -fBoundRadius) < fBoundRadius)
|
||||||
{
|
{
|
||||||
|
@ -866,7 +866,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CEntity::AddSteamsFromGround1(CPtrList& list)
|
CEntity::AddSteamsFromGround(CPtrList& list)
|
||||||
{
|
{
|
||||||
CPtrNode *pNode = list.first;
|
CPtrNode *pNode = list.first;
|
||||||
while (pNode) {
|
while (pNode) {
|
||||||
@ -922,7 +922,7 @@ STARTPATCHES
|
|||||||
InjectHook(0x473F60, &CEntity::DetachFromRwObject, PATCH_JUMP);
|
InjectHook(0x473F60, &CEntity::DetachFromRwObject, PATCH_JUMP);
|
||||||
|
|
||||||
InjectHook(0x475A20, &CEntity::PreRenderForGlassWindow, PATCH_JUMP);
|
InjectHook(0x475A20, &CEntity::PreRenderForGlassWindow, PATCH_JUMP);
|
||||||
InjectHook(0x50CE40, &CEntity::AddSteamsFromGround, PATCH_JUMP);
|
InjectHook(0x50CE40, (void (CEntity::*)(CVector*))& CEntity::AddSteamsFromGround, PATCH_JUMP);
|
||||||
InjectHook(0x475670, &CEntity::ModifyMatrixForTreeInWind, PATCH_JUMP);
|
InjectHook(0x475670, &CEntity::ModifyMatrixForTreeInWind, PATCH_JUMP);
|
||||||
InjectHook(0x475830, &CEntity::ModifyMatrixForBannerInWind, PATCH_JUMP);
|
InjectHook(0x475830, &CEntity::ModifyMatrixForBannerInWind, PATCH_JUMP);
|
||||||
InjectHook(0x4FA530, &CEntity::ProcessLightsForEntity, PATCH_JUMP);
|
InjectHook(0x4FA530, &CEntity::ProcessLightsForEntity, PATCH_JUMP);
|
||||||
|
@ -154,6 +154,6 @@ public:
|
|||||||
void ModifyMatrixForBannerInWind(void);
|
void ModifyMatrixForBannerInWind(void);
|
||||||
void ProcessLightsForEntity(void);
|
void ProcessLightsForEntity(void);
|
||||||
|
|
||||||
static void AddSteamsFromGround1(CPtrList& list);
|
static void AddSteamsFromGround(CPtrList& list);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CEntity) == 0x64, "CEntity: error");
|
static_assert(sizeof(CEntity) == 0x64, "CEntity: error");
|
||||||
|
Loading…
Reference in New Issue
Block a user