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:
parent
70ba099709
commit
8441b4a06d
31 changed files with 918 additions and 410 deletions
|
|
@ -73,18 +73,16 @@ float b3RevoluteJoint_GetUpperLimit( b3JointId jointId )
|
|||
|
||||
void b3RevoluteJoint_SetLimits( b3JointId jointId, float lowerLimitRadians, float upperLimitRadians )
|
||||
{
|
||||
B3_ASSERT( lowerLimitRadians <= upperLimitRadians );
|
||||
B3_ASSERT( b3IsValidFloat( lowerLimitRadians ) && b3IsValidFloat( upperLimitRadians ) );
|
||||
b3World* world = b3GetWorld( jointId.world0 );
|
||||
B3_REC( world, RevoluteJointSetLimits, jointId, lowerLimitRadians, upperLimitRadians );
|
||||
float lowerAngle = b3ClampFloat( lowerLimitRadians, -B3_PI, B3_PI );
|
||||
float upperAngle = b3ClampFloat( upperLimitRadians, -B3_PI, B3_PI );
|
||||
|
||||
float lowerAngle = b3MinFloat( lowerLimitRadians, upperLimitRadians );
|
||||
float upperAngle = b3MaxFloat( lowerLimitRadians, upperLimitRadians );
|
||||
|
||||
b3JointSim* base = b3GetJointSimCheckType( jointId, b3_revoluteJoint );
|
||||
base->revoluteJoint.lowerAngle = lowerAngle;
|
||||
base->revoluteJoint.upperAngle = upperAngle;
|
||||
base->revoluteJoint.lowerImpulse = 0.0f;
|
||||
base->revoluteJoint.upperImpulse = 0.0f;
|
||||
base->revoluteJoint.lowerAngle = b3ClampFloat( lowerAngle, -0.99f * B3_PI, 0.99f * B3_PI );
|
||||
base->revoluteJoint.upperAngle = b3ClampFloat( upperAngle, -0.99f * B3_PI, 0.99f * B3_PI );
|
||||
}
|
||||
|
||||
float b3RevoluteJoint_GetAngle( b3JointId jointId )
|
||||
|
|
@ -219,6 +217,13 @@ float b3RevoluteJoint_GetMaxMotorTorque( b3JointId jointId )
|
|||
return base->revoluteJoint.maxMotorTorque;
|
||||
}
|
||||
|
||||
float b3RevoluteJoint_GetMotorTorque( b3JointId jointId )
|
||||
{
|
||||
b3World* world = b3GetWorld( jointId.world0 );
|
||||
b3JointSim* base = b3GetJointSimCheckType( jointId, b3_revoluteJoint );
|
||||
return world->inv_h * base->revoluteJoint.motorImpulse;
|
||||
}
|
||||
|
||||
b3Vec3 b3GetRevoluteJointForce( b3World* world, b3JointSim* base )
|
||||
{
|
||||
b3Vec3 force = b3MulSV( world->inv_h, base->revoluteJoint.linearImpulse );
|
||||
|
|
|
|||
Loading…
Reference in a new issue