Missing functions (#21)

- add some missing functions
- added config.h for users that vendor Box3D
- joint unit tests
- improve joint limit consistency
- extend build matrix
This commit is contained in:
Erin Catto 2026-06-30 10:57:46 -07:00 • committed by GitHub
commit 8441b4a06d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 918 additions and 410 deletions

View file

@ -103,14 +103,13 @@ void b3SphericalJoint_SetTwistLimits( b3JointId jointId, float lowerLimitRadians
B3_ASSERT( b3IsValidFloat( lowerLimitRadians ) && b3IsValidFloat( upperLimitRadians ) );
b3World* world = b3GetWorld( jointId.world0 );
B3_REC( world, SphericalJointSetTwistLimits, jointId, lowerLimitRadians, upperLimitRadians );
float lowerTwistAngle = b3MinFloat( lowerLimitRadians, upperLimitRadians );
float upperTwistAngle = b3MaxFloat( lowerLimitRadians, upperLimitRadians );
lowerTwistAngle = b3ClampFloat( lowerTwistAngle, -B3_PI, B3_PI );
upperTwistAngle = b3ClampFloat( upperTwistAngle, -B3_PI, B3_PI );
float lowerAngle = b3MinFloat( lowerLimitRadians, upperLimitRadians );
float upperAngle = b3MaxFloat( lowerLimitRadians, upperLimitRadians );
b3JointSim* base = b3GetJointSimCheckType( jointId, b3_sphericalJoint );
base->sphericalJoint.lowerTwistAngle = lowerTwistAngle;
base->sphericalJoint.upperTwistAngle = upperTwistAngle;
base->sphericalJoint.lowerTwistAngle = b3ClampFloat( lowerAngle, -0.99f * B3_PI, 0.99f * B3_PI );
base->sphericalJoint.upperTwistAngle = b3ClampFloat( upperAngle, -0.99f * B3_PI, 0.99f * B3_PI );
}
float b3SphericalJoint_GetTwistAngle( b3JointId jointId )
@ -245,6 +244,13 @@ float b3SphericalJoint_GetMaxMotorTorque( b3JointId jointId )
return base->sphericalJoint.maxMotorTorque;
}
b3Vec3 b3SphericalJoint_GetMotorTorque( b3JointId jointId )
{
b3World* world = b3GetWorld( jointId.world0 );
b3JointSim* base = b3GetJointSimCheckType( jointId, b3_sphericalJoint );
return b3MulSV( world->inv_h, base->sphericalJoint.motorImpulse );
}
b3Vec3 b3GetSphericalJointForce( b3World* world, b3JointSim* base )
{
b3Vec3 force = b3MulSV( world->inv_h, base->sphericalJoint.linearImpulse );