Fix swept box ray tracing with OBBs

This commit is contained in:
Kamay Xutax 2024-09-15 00:27:27 +02:00
parent 0d8dceea43
commit 3ec518643e
2 changed files with 10 additions and 10 deletions

View file

@ -1475,12 +1475,12 @@ bool IntersectRayWithOBB( const Ray_t &ray, const matrix3x4_t &matOBBToWorld,
Collision_ClearTrace( ray.m_Start + ray.m_StartOffset, ray.m_Delta, pTrace );
// Compute a bounding sphere around the bloated OBB
Vector vecOBBExtents;
VectorAdd( vecOBBMins, vecOBBMaxs, vecOBBExtents );
vecOBBExtents *= 0.5f;
Vector vecOBBCenter;
VectorAdd( vecOBBMins, vecOBBMaxs, vecOBBCenter );
vecOBBCenter *= 0.5f;
vecOBBCenter.x += matOBBToWorld[0][3];
vecOBBCenter.y += matOBBToWorld[1][3];
vecOBBCenter.z += matOBBToWorld[2][3];
VectorTransform( vecOBBExtents, matOBBToWorld, vecOBBCenter );
Vector vecOBBHalfDiagonal;
VectorSubtract( vecOBBMaxs, vecOBBMins, vecOBBHalfDiagonal );

View file

@ -1475,12 +1475,12 @@ bool IntersectRayWithOBB( const Ray_t &ray, const matrix3x4_t &matOBBToWorld,
Collision_ClearTrace( ray.m_Start + ray.m_StartOffset, ray.m_Delta, pTrace );
// Compute a bounding sphere around the bloated OBB
Vector vecOBBExtents;
VectorAdd( vecOBBMins, vecOBBMaxs, vecOBBExtents );
vecOBBExtents *= 0.5f;
Vector vecOBBCenter;
VectorAdd( vecOBBMins, vecOBBMaxs, vecOBBCenter );
vecOBBCenter *= 0.5f;
vecOBBCenter.x += matOBBToWorld[0][3];
vecOBBCenter.y += matOBBToWorld[1][3];
vecOBBCenter.z += matOBBToWorld[2][3];
VectorTransform( vecOBBExtents, matOBBToWorld, vecOBBCenter );
Vector vecOBBHalfDiagonal;
VectorSubtract( vecOBBMaxs, vecOBBMins, vecOBBHalfDiagonal );