Skip to content

Commit 8982441

Browse files
Synchronize changes from 1.6 master branch [ci skip]
da8e500 processLineAgainstMesh crash fix (#4491) 4ce24be Visual Studio Update
2 parents 4c33285 + da8e500 commit 8982441

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Client/game_sa/CWorldSA.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13+
#include <numbers>
1314
#include <multiplayer/CMultiplayer.h>
1415
#include <core/CCoreInterface.h>
1516
#include "CGameSA.h"
@@ -275,7 +276,13 @@ auto CWorldSA::ProcessLineAgainstMesh(CEntitySAInterface* targetEntity, CVector
275276
}
276277

277278
// Get matrix, and it's inverse
278-
c.entity->matrix->ConvertToMatrix(c.entMat);
279+
if (c.entity->matrix)
280+
c.entity->matrix->ConvertToMatrix(c.entMat);
281+
else
282+
{
283+
c.entMat.SetPosition(c.entity->m_transform.m_translate);
284+
c.entMat.SetRotation(CVector{0.0f, 0.0f, c.entity->m_transform.m_heading});
285+
}
279286
c.entInvMat = c.entMat.Inverse();
280287

281288
// ...to transform the line origin and end into object space
@@ -533,9 +540,18 @@ CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float rad
533540
return nullptr;
534541

535542
result.collisionDetected = true;
536-
result.modelID = entity->m_nModelIndex;
537-
result.entityPosition = entity->matrix->vPos;
538-
ConvertMatrixToEulerAngles(*entity->matrix, result.entityRotation.fX, result.entityRotation.fY, result.entityRotation.fZ);
543+
result.modelID = entity->m_nModelIndex;
544+
if (entity->matrix)
545+
{
546+
result.entityPosition = entity->matrix->vPos;
547+
ConvertMatrixToEulerAngles(*entity->matrix, result.entityRotation.fX, result.entityRotation.fY, result.entityRotation.fZ);
548+
}
549+
else
550+
{
551+
result.entityPosition = entity->m_transform.m_translate;
552+
result.entityRotation.fX = result.entityRotation.fY = 0.0f;
553+
result.entityRotation.fZ = entity->m_transform.m_heading * (180.0f/std::numbers::pi);
554+
}
539555
result.entityRotation = -result.entityRotation;
540556
result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0;
541557
result.type = static_cast<eEntityType>(entity->nType);

0 commit comments

Comments
 (0)