|  | 
| 10 | 10 |  *****************************************************************************/ | 
| 11 | 11 | 
 | 
| 12 | 12 | #include "StdInc.h" | 
|  | 13 | +#include <numbers> | 
| 13 | 14 | #include <multiplayer/CMultiplayer.h> | 
| 14 | 15 | #include <core/CCoreInterface.h> | 
| 15 | 16 | #include "CGameSA.h" | 
| @@ -275,7 +276,13 @@ auto CWorldSA::ProcessLineAgainstMesh(CEntitySAInterface* targetEntity, CVector | 
| 275 | 276 |     } | 
| 276 | 277 | 
 | 
| 277 | 278 |     // 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 | +    } | 
| 279 | 286 |     c.entInvMat = c.entMat.Inverse(); | 
| 280 | 287 | 
 | 
| 281 | 288 |     // ...to transform the line origin and end into object space | 
| @@ -533,9 +540,18 @@ CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float rad | 
| 533 | 540 |         return nullptr; | 
| 534 | 541 | 
 | 
| 535 | 542 |     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 | +    } | 
| 539 | 555 |     result.entityRotation = -result.entityRotation; | 
| 540 | 556 |     result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0; | 
| 541 | 557 |     result.type = static_cast<eEntityType>(entity->nType); | 
|  | 
0 commit comments