diff --git a/.clang-format b/.clang-format index e4ecbd3..eaea153 100644 --- a/.clang-format +++ b/.clang-format @@ -12,7 +12,7 @@ BraceWrapping: AfterUnion: true BeforeWhile: true -ColumnLimit: 130 +ColumnLimit: 100 PointerAlignment: Left UseTab: Always BreakConstructorInitializers: BeforeComma diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2f3b107 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*.{c,h,cpp,inl}] +guidelines = 100 +guidelines_style = 1px dotted gray diff --git a/src/body.c b/src/body.c index 6d67343..70bbc28 100644 --- a/src/body.c +++ b/src/body.c @@ -892,6 +892,9 @@ b3BodyTOIResult b3Body_TimeOfImpactMover( b3BodyId bodyId, b3Pos origin, const b return result; } +// This computes the deviation of the principal inertia values without computing eigenvalues. +// It computes: +// ((I1 - I2)^2 + (I1 - I3)^2 + (I2 - I3)^2) / (I1^2 + I2^2 + I3^2) // https://en.wikipedia.org/wiki/Cauchy_stress_tensor#Stress_deviator_tensor static void b3UpdateIsotropicInertia( b3World* world, b3Body* body, b3BodySim* bodySim ) { diff --git a/src/solver.c b/src/solver.c index f1697bd..236c848 100644 --- a/src/solver.c +++ b/src/solver.c @@ -106,6 +106,8 @@ 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 the principal inertia values of I are roughly equal (isotropic) then + // cross(w2, I * w2) ~= 0, so this can be skipped. if ( sim->flags & b3_enableGyroscopicTorque ) { // Get current rotation.