Fixed OBB hitbox with swept box ray tracing
This commit is contained in:
parent
db03935f34
commit
bca77a7d2e
1 changed files with 9 additions and 9 deletions
|
@ -1479,21 +1479,21 @@ bool IntersectRayWithOBB( const Ray_t &ray, const matrix3x4_t &matOBBToWorld,
|
||||||
Collision_ClearTrace( ray.m_Start + ray.m_StartOffset, ray.m_Delta, pTrace );
|
Collision_ClearTrace( ray.m_Start + ray.m_StartOffset, ray.m_Delta, pTrace );
|
||||||
|
|
||||||
// Compute a bounding sphere around the bloated OBB
|
// Compute a bounding sphere around the bloated OBB
|
||||||
|
Vector vecOBBExtents;
|
||||||
|
VectorAdd( vecOBBMins, vecOBBMaxs, vecOBBExtents );
|
||||||
|
vecOBBExtents *= 0.5f;
|
||||||
|
|
||||||
Vector vecOBBCenter;
|
Vector vecOBBCenter;
|
||||||
VectorAdd( vecOBBMins, vecOBBMaxs, vecOBBCenter );
|
VectorTransform( vecOBBExtents, matOBBToWorld, vecOBBCenter );
|
||||||
vecOBBCenter *= 0.5f;
|
|
||||||
vecOBBCenter.x += matOBBToWorld[0][3];
|
|
||||||
vecOBBCenter.y += matOBBToWorld[1][3];
|
|
||||||
vecOBBCenter.z += matOBBToWorld[2][3];
|
|
||||||
|
|
||||||
Vector vecOBBHalfDiagonal;
|
Vector vecOBBHalfDiagonal;
|
||||||
VectorSubtract( vecOBBMaxs, vecOBBMins, vecOBBHalfDiagonal );
|
VectorSubtract( vecOBBMaxs, vecOBBMins, vecOBBHalfDiagonal );
|
||||||
vecOBBHalfDiagonal *= 0.5f;
|
vecOBBHalfDiagonal *= 0.5f;
|
||||||
|
|
||||||
// TODO_ENHANCED: make sphere hitboxes.
|
// TODO_ENHANCED: should be fixed now.
|
||||||
// float flRadius = vecOBBHalfDiagonal.Length() + ray.m_Extents.Length();
|
float flRadius = vecOBBHalfDiagonal.Length() + ray.m_Extents.Length();
|
||||||
// if ( !IsRayIntersectingSphere( ray.m_Start, ray.m_Delta, vecOBBCenter, flRadius, flTolerance ) )
|
if ( !IsRayIntersectingSphere( ray.m_Start, ray.m_Delta, vecOBBCenter, flRadius, flTolerance ) )
|
||||||
// return false;
|
return false;
|
||||||
|
|
||||||
// Ok, we passed the trivial reject, so lets do the dirty deed.
|
// Ok, we passed the trivial reject, so lets do the dirty deed.
|
||||||
// Basically we're going to do the GJK thing explicitly. We'll shrink the ray down
|
// Basically we're going to do the GJK thing explicitly. We'll shrink the ray down
|
||||||
|
|
Loading…
Reference in a new issue