Fixed box inertia tensor calculation

This commit is contained in:
Diren D Bharwani 2022-12-30 17:59:59 +08:00
parent 7b1b4873ec
commit 50e3ddf0dd
2 changed files with 15 additions and 4 deletions

View File

@ -19,7 +19,7 @@
Interpolate: true Interpolate: true
Sleeping Enabled: true Sleeping Enabled: true
Freeze Position X: false Freeze Position X: false
Freeze Position Y: false Freeze Position Y: true
Freeze Position Z: false Freeze Position Z: false
Freeze Rotation X: false Freeze Rotation X: false
Freeze Rotation Y: false Freeze Rotation Y: false
@ -29,6 +29,7 @@
DrawColliders: false DrawColliders: false
Colliders: Colliders:
- Is Trigger: false - Is Trigger: false
Collision Tag: 1
Type: Sphere Type: Sphere
Radius: 1 Radius: 1
Friction: 0.400000006 Friction: 0.400000006
@ -90,6 +91,7 @@
DrawColliders: false DrawColliders: false
Colliders: Colliders:
- Is Trigger: false - Is Trigger: false
Collision Tag: 1
Type: Sphere Type: Sphere
Radius: 2.5 Radius: 2.5
Friction: 0.400000006 Friction: 0.400000006
@ -130,6 +132,7 @@
DrawColliders: false DrawColliders: false
Colliders: Colliders:
- Is Trigger: false - Is Trigger: false
Collision Tag: 1
Type: Box Type: Box
Half Extents: {x: 1, y: 1, z: 1} Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006 Friction: 0.400000006

View File

@ -236,9 +236,17 @@ namespace SHADE
{ {
static constexpr float ONE_OVER_TWELVE = (1.0f / 12.0f); static constexpr float ONE_OVER_TWELVE = (1.0f / 12.0f);
const float H2_PLUS_D2 = Extents.y * Extents.y + Extents.z * Extents.z; const float WIDTH = 2.0f * Extents.x;
const float W2_PLUS_H2 = Extents.x * Extents.x + Extents.y * Extents.y; const float HEIGHT = 2.0f * Extents.y;
const float W2_PLUS_D2 = Extents.x * Extents.x + Extents.z * Extents.z; const float DEPTH = 2.0f * Extents.z;
const float WIDTH_SQUARED = WIDTH * WIDTH;
const float HEIGHT_SQUARED = HEIGHT * HEIGHT;
const float DEPTH_SQUARED = DEPTH * DEPTH;
const float H2_PLUS_D2 = HEIGHT_SQUARED + DEPTH_SQUARED;
const float W2_PLUS_H2 = WIDTH_SQUARED + HEIGHT_SQUARED;
const float W2_PLUS_D2 = WIDTH_SQUARED + DEPTH_SQUARED;
SHMatrix result; SHMatrix result;
result.m[0][0] = ONE_OVER_TWELVE * mass * H2_PLUS_D2; result.m[0][0] = ONE_OVER_TWELVE * mass * H2_PLUS_D2;