Gyro tolerance (#191)
This commit is contained in:
parent
0cfc475b88
commit
efca0c184d
23 changed files with 420 additions and 63 deletions
16
src/solver.c
16
src/solver.c
|
|
@ -106,25 +106,23 @@ static void b3IntegrateVelocitiesTask( b3SolverBlock block, b3StepContext* conte
|
|||
// I * (w2 - w1) + h * cross(w2, I * w2) = 0
|
||||
// This is all done in local coordinates where the Jacobian is easier to compute.
|
||||
// This improves the simulation of long skinny bodies.
|
||||
if ( sim->flags & b3_enableGyroscopicTorque )
|
||||
{
|
||||
// Get current rotation.
|
||||
b3Quat q0 = sim->transform.q;
|
||||
b3Quat q = b3MulQuat( state->deltaRotation, q0 );
|
||||
|
||||
// todo wasteful computation
|
||||
b3Matrix3 inertiaLocal = b3InvertMatrix( sim->invInertiaLocal );
|
||||
|
||||
// Compute local angular velocity
|
||||
b3Vec3 omega1 = b3InvRotateVector( q, w );
|
||||
b3Vec3 omega2 = omega1;
|
||||
|
||||
// Symmetric inertia tensor: 6 unique entries (column-major)
|
||||
float i00 = inertiaLocal.cx.x;
|
||||
float i01 = inertiaLocal.cy.x;
|
||||
float i02 = inertiaLocal.cz.x;
|
||||
float i11 = inertiaLocal.cy.y;
|
||||
float i12 = inertiaLocal.cz.y;
|
||||
float i22 = inertiaLocal.cz.z;
|
||||
float i00 = sim->inertia.cx.x;
|
||||
float i01 = sim->inertia.cy.x;
|
||||
float i02 = sim->inertia.cz.x;
|
||||
float i11 = sim->inertia.cy.y;
|
||||
float i12 = sim->inertia.cz.y;
|
||||
float i22 = sim->inertia.cz.z;
|
||||
|
||||
for ( int gyroIteration = 0; gyroIteration < B3_GYROSCOPIC_ITERATIONS; ++gyroIteration )
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue