Doubles (#14)
Added a compile time option to use double precision body positions. Most math remains single precision with minimal performance loss. `BOX3D_DOUBLE_PRECISION` Improved accuracy of body inertia computation when shapes are far from the body origin. WARNING: several APIs changed but migration should be straight forward if doubles are not enabled.
This commit is contained in:
parent
a252f03b19
commit
09c65b08ea
115 changed files with 7591 additions and 5295 deletions
|
|
@ -46,8 +46,8 @@ float b3SphericalJoint_GetConeAngle( b3JointId jointId )
|
|||
{
|
||||
b3World* world = b3GetWorld( jointId.world0 );
|
||||
b3JointSim* base = b3GetJointSimCheckType( jointId, b3_sphericalJoint );
|
||||
b3Transform transformA = b3GetBodyTransform( world, base->bodyIdA );
|
||||
b3Transform transformB = b3GetBodyTransform( world, base->bodyIdB );
|
||||
b3WorldTransform transformA = b3GetBodyTransform( world, base->bodyIdA );
|
||||
b3WorldTransform transformB = b3GetBodyTransform( world, base->bodyIdB );
|
||||
|
||||
b3Quat quatA = b3MulQuat( transformA.q, base->localFrameA.q );
|
||||
b3Quat quatB = b3MulQuat( transformB.q, base->localFrameB.q );
|
||||
|
|
@ -109,8 +109,8 @@ float b3SphericalJoint_GetTwistAngle( b3JointId jointId )
|
|||
{
|
||||
b3World* world = b3GetWorld( jointId.world0 );
|
||||
b3JointSim* base = b3GetJointSimCheckType( jointId, b3_sphericalJoint );
|
||||
b3Transform transformA = b3GetBodyTransform( world, base->bodyIdA );
|
||||
b3Transform transformB = b3GetBodyTransform( world, base->bodyIdB );
|
||||
b3WorldTransform transformA = b3GetBodyTransform( world, base->bodyIdA );
|
||||
b3WorldTransform transformB = b3GetBodyTransform( world, base->bodyIdB );
|
||||
|
||||
b3Quat quatA = b3MulQuat( transformA.q, base->localFrameA.q );
|
||||
b3Quat quatB = b3MulQuat( transformB.q, base->localFrameB.q );
|
||||
|
|
@ -231,8 +231,8 @@ b3Vec3 b3GetSphericalJointForce( b3World* world, b3JointSim* base )
|
|||
|
||||
b3Vec3 b3GetSphericalJointTorque( b3World* world, b3JointSim* base )
|
||||
{
|
||||
b3Transform xfA = b3GetBodyTransform( world, base->bodyIdA );
|
||||
b3Transform xfB = b3GetBodyTransform( world, base->bodyIdB );
|
||||
b3WorldTransform xfA = b3GetBodyTransform( world, base->bodyIdA );
|
||||
b3WorldTransform xfB = b3GetBodyTransform( world, base->bodyIdB );
|
||||
b3Quat qA = b3MulQuat( xfA.q, base->localFrameA.q );
|
||||
b3Quat qB = b3MulQuat( xfB.q, base->localFrameB.q );
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ void b3PrepareSphericalJoint( b3JointSim* base, b3StepContext* context )
|
|||
joint->frameB.q = b3MulQuat( bodySimB->transform.q, base->localFrameB.q );
|
||||
joint->frameB.p = b3RotateVector( bodySimB->transform.q, b3Sub( base->localFrameB.p, bodySimB->localCenter ) );
|
||||
|
||||
joint->deltaCenter = b3Sub( bodySimB->center, bodySimA->center );
|
||||
joint->deltaCenter = b3SubPos( bodySimB->center, bodySimA->center );
|
||||
|
||||
// Cone axis is the z-axis of body A.
|
||||
b3Vec3 coneAxis = b3RotateVector( joint->frameA.q, b3Vec3_axisZ );
|
||||
|
|
@ -630,22 +630,22 @@ void b3SolveSphericalJoint( b3JointSim* base, b3StepContext* context, bool useBi
|
|||
}
|
||||
}
|
||||
|
||||
void b3DrawSphericalJoint( b3DebugDraw* draw, b3JointSim* base, b3Transform transformA, b3Transform transformB, float scale )
|
||||
void b3DrawSphericalJoint( b3DebugDraw* draw, b3JointSim* base, b3WorldTransform transformA, b3WorldTransform transformB, float scale )
|
||||
{
|
||||
b3Transform frameA = b3MulTransforms( transformA, base->localFrameA );
|
||||
b3WorldTransform frameA = b3MulWorldTransforms( transformA, base->localFrameA );
|
||||
|
||||
float length1 = 0.1f * scale;
|
||||
draw->DrawSegmentFcn( frameA.p, b3MulAdd( frameA.p, length1, b3RotateVector( frameA.q, b3Vec3_axisX ) ), b3_colorRed,
|
||||
draw->DrawSegmentFcn( frameA.p, b3OffsetPos( frameA.p, b3MulSV( length1, b3RotateVector( frameA.q, b3Vec3_axisX ) ) ), b3_colorRed,
|
||||
draw->context );
|
||||
draw->DrawSegmentFcn( frameA.p, b3MulAdd( frameA.p, length1, b3RotateVector( frameA.q, b3Vec3_axisY ) ), b3_colorGreen,
|
||||
draw->DrawSegmentFcn( frameA.p, b3OffsetPos( frameA.p, b3MulSV( length1, b3RotateVector( frameA.q, b3Vec3_axisY ) ) ), b3_colorGreen,
|
||||
draw->context );
|
||||
draw->DrawSegmentFcn( frameA.p, b3MulAdd( frameA.p, length1, b3RotateVector( frameA.q, b3Vec3_axisZ ) ), b3_colorBlue,
|
||||
draw->DrawSegmentFcn( frameA.p, b3OffsetPos( frameA.p, b3MulSV( length1, b3RotateVector( frameA.q, b3Vec3_axisZ ) ) ), b3_colorBlue,
|
||||
draw->context );
|
||||
|
||||
b3Transform frameB = b3MulTransforms( transformB, base->localFrameB );
|
||||
b3WorldTransform frameB = b3MulWorldTransforms( transformB, base->localFrameB );
|
||||
|
||||
float length2 = 0.2f * scale;
|
||||
draw->DrawSegmentFcn( frameB.p, b3MulAdd( frameB.p, length2, b3RotateVector( frameB.q, b3Vec3_axisZ ) ), b3_colorOrange,
|
||||
draw->DrawSegmentFcn( frameB.p, b3OffsetPos( frameB.p, b3MulSV( length2, b3RotateVector( frameB.q, b3Vec3_axisZ ) ) ), b3_colorOrange,
|
||||
draw->context );
|
||||
|
||||
b3SphericalJoint* joint = &base->sphericalJoint;
|
||||
|
|
@ -678,20 +678,20 @@ void b3DrawSphericalJoint( b3DebugDraw* draw, b3JointSim* base, b3Transform tran
|
|||
|
||||
if ( index == 0 )
|
||||
{
|
||||
draw->DrawSegmentFcn( frameA.p, b3TransformPoint( frameA, vertex1 ), b3_colorCyan, draw->context );
|
||||
draw->DrawSegmentFcn( frameA.p, b3TransformWorldPoint( frameA, vertex1 ), b3_colorCyan, draw->context );
|
||||
}
|
||||
|
||||
if ( index == kSliceCount - 1 )
|
||||
{
|
||||
draw->DrawSegmentFcn( b3TransformPoint( frameA, vertex2 ), frameA.p, b3_colorCyan, draw->context );
|
||||
draw->DrawSegmentFcn( b3TransformWorldPoint( frameA, vertex2 ), frameA.p, b3_colorCyan, draw->context );
|
||||
}
|
||||
draw->DrawSegmentFcn( b3TransformPoint( frameA, vertex1 ), b3TransformPoint( frameA, vertex2 ), b3_colorCyan,
|
||||
draw->DrawSegmentFcn( b3TransformWorldPoint( frameA, vertex1 ), b3TransformWorldPoint( frameA, vertex2 ), b3_colorCyan,
|
||||
draw->context );
|
||||
}
|
||||
|
||||
float twistAngle = b3GetTwistAngle( relQ );
|
||||
b3Vec3 p2 = { wedgeRadius * b3Cos( twistAngle ), wedgeRadius * b3Sin( twistAngle ), 0.0f };
|
||||
draw->DrawSegmentFcn( frameA.p, b3TransformPoint( frameA, p2 ), b3_colorYellow, draw->context );
|
||||
draw->DrawSegmentFcn( frameA.p, b3TransformWorldPoint( frameA, p2 ), b3_colorYellow, draw->context );
|
||||
}
|
||||
|
||||
// Swing limit
|
||||
|
|
@ -709,8 +709,8 @@ void b3DrawSphericalJoint( b3DebugDraw* draw, b3JointSim* base, b3Transform tran
|
|||
b3Vec3 vertex1 = { coneRadius * b3Cos( phi1 ), coneRadius * b3Sin( phi1 ), coneHeight };
|
||||
b3Vec3 vertex2 = { coneRadius * b3Cos( phi2 ), coneRadius * b3Sin( phi2 ), coneHeight };
|
||||
|
||||
draw->DrawSegmentFcn( frameA.p, b3TransformPoint( frameA, vertex1 ), b3_colorCyan, draw->context );
|
||||
draw->DrawSegmentFcn( b3TransformPoint( frameA, vertex1 ), b3TransformPoint( frameA, vertex2 ), b3_colorCyan,
|
||||
draw->DrawSegmentFcn( frameA.p, b3TransformWorldPoint( frameA, vertex1 ), b3_colorCyan, draw->context );
|
||||
draw->DrawSegmentFcn( b3TransformWorldPoint( frameA, vertex1 ), b3TransformWorldPoint( frameA, vertex2 ), b3_colorCyan,
|
||||
draw->context );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue