Fixed a potential infinite loop in AABB Tree
This behaviour should've thrown an exception wtf???
This commit is contained in:
parent
eda1147b5c
commit
1b885c8878
|
@ -337,7 +337,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SHASSERT(index >= 0 && index < capacity, "Trying to free an invalid AABB Tree node!")
|
SHASSERT(index >= 0 && index < capacity, "Trying to free an invalid AABB Tree node!")
|
||||||
|
|
||||||
nodes[index].next = NULL_NODE;
|
nodes[index].next = freeList;
|
||||||
nodes[index].height = NULL_NODE;
|
nodes[index].height = NULL_NODE;
|
||||||
|
|
||||||
// Put it back on the free list
|
// Put it back on the free list
|
||||||
|
|
|
@ -127,9 +127,9 @@ namespace SHADE
|
||||||
* Faces:
|
* Faces:
|
||||||
*
|
*
|
||||||
* Front: 0 (0,1,2,3) Normal: -Z
|
* Front: 0 (0,1,2,3) Normal: -Z
|
||||||
* Right: 1 (1,5,6,2) Normal: X
|
* Right: 1 (5,6,2,1) Normal: X
|
||||||
* Back: 2 (5,4,7,6) Normal: Z
|
* Back: 2 (5,4,7,6) Normal: Z
|
||||||
* Left: 3 (4,0,3,7) Normal: -X
|
* Left: 3 (0,3,7,4) Normal: -X
|
||||||
* Top: 4 (3,2,6,7) Normal: Y
|
* Top: 4 (3,2,6,7) Normal: Y
|
||||||
* Bottom: 5 (4,5,1,0) Normal: -Y
|
* Bottom: 5 (4,5,1,0) Normal: -Y
|
||||||
*
|
*
|
||||||
|
|
|
@ -644,29 +644,24 @@ namespace SHADE
|
||||||
const SHMatrix RT = SHMatrix::Transpose(R);
|
const SHMatrix RT = SHMatrix::Transpose(R);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compute world inertia as a Vector
|
* Compute world inertia as a Vector
|
||||||
|
*
|
||||||
| a b c || x | | ax + by + cz |
|
* | a b c || x | | ax + by + cz |
|
||||||
| d e f || y | = | dx + ey + fz |
|
* | d e f || y | = | dx + ey + fz |
|
||||||
| g h i || z | | gx + hy + iz |
|
* | g h i || z | | gx + hy + iz |
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SHMatrix tmp = SHMatrix
|
SHMatrix localInertiaTensor = SHMatrix::Identity;
|
||||||
{
|
|
||||||
SHVec4 { localInvInertia.x, 0.0f, 0.0f, 0.0f }
|
|
||||||
, SHVec4 { 0.0f, localInvInertia.y, 0.0f, 0.0f }
|
|
||||||
, SHVec4 { 0.0f, 0.0f, localInvInertia.z, 0.0f }
|
|
||||||
, SHVec4 { 0.0f, 0.0f, 0.0, 1.0f }
|
|
||||||
};
|
|
||||||
|
|
||||||
tmp *= RT;
|
// Set the diagonals
|
||||||
|
localInertiaTensor.m[0][0] = localInvInertia.x;
|
||||||
|
localInertiaTensor.m[1][1] = localInvInertia.y;
|
||||||
|
localInertiaTensor.m[2][2] = localInvInertia.z;
|
||||||
|
|
||||||
worldInvInertia = SHVec3
|
localInertiaTensor *= RT;
|
||||||
{
|
const SHVec3 DIAGONALS { localInertiaTensor.m[0][0], localInertiaTensor.m[1][1], localInertiaTensor.m[2][2] };
|
||||||
R.m[0][0] * tmp.m[0][0] + RT.m[0][1] * tmp.m[1][1] + RT.m[0][2] * tmp.m[2][2]
|
|
||||||
, R.m[1][0] * tmp.m[0][0] + RT.m[1][1] * tmp.m[1][1] + RT.m[1][2] * tmp.m[2][2]
|
worldInvInertia = R * DIAGONALS;
|
||||||
, R.m[2][0] * tmp.m[0][0] + RT.m[2][1] * tmp.m[1][1] + RT.m[2][2] * tmp.m[2][2]
|
|
||||||
};
|
|
||||||
|
|
||||||
// Compute world centroid
|
// Compute world centroid
|
||||||
worldCentroid = (R * localCentroid) + motionState.position;
|
worldCentroid = (R * localCentroid) + motionState.position;
|
||||||
|
|
Loading…
Reference in New Issue