Fix IsSphereVisible calls

This commit is contained in:
Sergeanur 2021-05-27 16:50:15 +03:00
parent 50058371ef
commit 2ad3a75be5
5 changed files with 11 additions and 17 deletions

View File

@ -3650,7 +3650,7 @@ CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
} }
bool bool
CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat) CCamera::IsSphereVisible(const CVector &center, float radius, Const CMatrix *mat)
{ {
#ifdef GTA_PS2 #ifdef GTA_PS2
CVuVector c; CVuVector c;
@ -3680,7 +3680,7 @@ CCamera::IsSphereVisible(const CVector &center, float radius)
return IsSphereVisible(center, radius, &m_cameraMatrix); return IsSphereVisible(center, radius, &m_cameraMatrix);
#else #else
// ...and on PC they decided to call the other one with a default matrix. // ...and on PC they decided to call the other one with a default matrix.
CMatrix mat(m_cameraMatrix); // this matrix construction is stupid and gone in VC CMatrix mat(GetCameraMatrix()); // this matrix construction is stupid and gone in VC
return IsSphereVisible(center, radius, &mat); return IsSphereVisible(center, radius, &mat);
#endif #endif
} }

View File

@ -639,7 +639,7 @@ public:
CVector &GetGameCamPosition(void) { return m_vecGameCamPos; } CVector &GetGameCamPosition(void) { return m_vecGameCamPos; }
void CalculateDerivedValues(void); void CalculateDerivedValues(void);
bool IsPointVisible(const CVector &center, const CMatrix *mat); bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat); bool IsSphereVisible(const CVector &center, float radius, Const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius); bool IsSphereVisible(const CVector &center, float radius);
bool IsBoxVisible(CVUVECTOR *box, const CMatrix *mat); bool IsBoxVisible(CVUVECTOR *box, const CMatrix *mat);
}; };

View File

@ -5362,7 +5362,7 @@ CPed::WarpPedToNearLeaderOffScreen(void)
continue; continue;
appropriatePos.z = zCorrectedPos.z; appropriatePos.z = zCorrectedPos.z;
if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f, &TheCamera.GetCameraMatrix()) if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f)
&& CWorld::GetIsLineOfSightClear(appropriatePos, warpToPos, true, true, false, true, false, false, false) && CWorld::GetIsLineOfSightClear(appropriatePos, warpToPos, true, true, false, true, false, false, false)
&& !CWorld::TestSphereAgainstWorld(appropriatePos, 0.6f, this, true, true, false, true, false, false)) { && !CWorld::TestSphereAgainstWorld(appropriatePos, 0.6f, this, true, true, false, true, false, false)) {
teleported = true; teleported = true;
@ -5396,7 +5396,7 @@ CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo)
continue; continue;
appropriatePos.z = zCorrectedPos.z; appropriatePos.z = zCorrectedPos.z;
if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f, &TheCamera.GetCameraMatrix()) if (!TheCamera.IsSphereVisible(appropriatePos, 0.6f)
&& CWorld::GetIsLineOfSightClear(appropriatePos, warpToPos, true, true, false, true, false, false, false) && CWorld::GetIsLineOfSightClear(appropriatePos, warpToPos, true, true, false, true, false, false, false)
&& !CWorld::TestSphereAgainstWorld(appropriatePos, 0.6f, this, true, true, false, true, false, false)) { && !CWorld::TestSphereAgainstWorld(appropriatePos, 0.6f, this, true, true, false, true, false, false)) {
teleported = true; teleported = true;

View File

@ -706,8 +706,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
generatedCoors.z = Max(generatedCoors.z, groundZ); generatedCoors.z = Max(generatedCoors.z, groundZ);
} }
bool farEnoughToAdd = true; bool farEnoughToAdd = true;
CMatrix mat(TheCamera.GetCameraMatrix()); if (TheCamera.IsSphereVisible(generatedCoors, 2.0f)) {
if (TheCamera.IsSphereVisible(generatedCoors, 2.0f, &mat)) {
if (PedCreationDistMultiplier() * MIN_CREATION_DIST > (generatedCoors - playerCentreOfWorld).Magnitude2D()) if (PedCreationDistMultiplier() * MIN_CREATION_DIST > (generatedCoors - playerCentreOfWorld).Magnitude2D())
farEnoughToAdd = false; farEnoughToAdd = false;
} }

View File

@ -740,8 +740,7 @@ CWaterLevel::RenderWater()
if ( fHugeSectorMaxRenderDistSqr > fHugeSectorDistToCamSqr ) if ( fHugeSectorMaxRenderDistSqr > fHugeSectorDistToCamSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecHugeSectorCentre.x, vecHugeSectorCentre.y, 0.0f), SectorRadius(HUGE_SECTOR_SIZE)) )
&TheCamera.GetCameraMatrix()) )
{ {
if ( fHugeSectorDistToCamSqr >= SQR(500.0f) /*fHugeSectorNearDist*/ ) if ( fHugeSectorDistToCamSqr >= SQR(500.0f) /*fHugeSectorNearDist*/ )
{ {
@ -782,8 +781,7 @@ CWaterLevel::RenderWater()
if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr ) if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecLargeSectorCentre.x, vecLargeSectorCentre.y, 0.0f), SectorRadius(LARGE_SECTOR_SIZE), //90.879997f, if ( TheCamera.IsSphereVisible(CVector(vecLargeSectorCentre.x, vecLargeSectorCentre.y, 0.0f), SectorRadius(LARGE_SECTOR_SIZE)) ) //90.879997f,
&TheCamera.GetCameraMatrix()) )
{ {
// Render four small(32x32) sectors, or one large(64x64). // Render four small(32x32) sectors, or one large(64x64).
@ -945,8 +943,7 @@ CWaterLevel::RenderWater()
if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) )
&TheCamera.GetCameraMatrix()) )
{ {
RenderOneFlatExtraHugeWaterPoly( RenderOneFlatExtraHugeWaterPoly(
vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2,
@ -979,8 +976,7 @@ CWaterLevel::RenderWater()
if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) )
&TheCamera.GetCameraMatrix()) )
{ {
RenderOneFlatExtraHugeWaterPoly( RenderOneFlatExtraHugeWaterPoly(
vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2,
@ -1003,8 +999,7 @@ CWaterLevel::RenderWater()
if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr ) if ( fCamDistToSector < fHugeSectorMaxRenderDistSqr )
{ {
if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE), if ( TheCamera.IsSphereVisible(CVector(vecExtraHugeSectorCentre.x, vecExtraHugeSectorCentre.y, 0.0f), SectorRadius(EXTRAHUGE_SECTOR_SIZE)) )
&TheCamera.GetCameraMatrix()) )
{ {
RenderOneFlatExtraHugeWaterPoly( RenderOneFlatExtraHugeWaterPoly(
vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2, vecExtraHugeSectorCentre.x - EXTRAHUGE_SECTOR_SIZE/2,