- Code: Select all
dFloat NewtonContactJointGetClosestDistance(const NewtonJoint* const contactJoint)
{
TRACE_FUNCTION(__FUNCTION__);
dgContact* const joint = (dgContact *)contactJoint;
return joint->GetClosestDistance( );
}
void NewtonBodyGetPosition(const NewtonBody* const bodyPtr, dFloat* const posPtr)
{
TRACE_FUNCTION(__FUNCTION__);
dgBody* const body = (dgBody *)bodyPtr;
const dgVector & rot = body->GetPosition();
posPtr[0] = rot.m_x;
posPtr[1] = rot.m_y;
posPtr[2] = rot.m_z;
}
The second is handy to avoid having a matrix if you only need a vector3.
Also, I found the following could be optimized (not much though):
- Code: Select all
void NewtonBodyGetRotation(const NewtonBody* const bodyPtr, dFloat* const rotPtr)
{
TRACE_FUNCTION(__FUNCTION__);
dgBody* const body = (dgBody *)bodyPtr;
const dgQuaternion rot = body->GetRotation(); // This was before
const dgQuaternion & rot = body->GetRotation(); // Reference avoid uneeded copy
rotPtr[0] = rot.m_q0;
rotPtr[1] = rot.m_q1;
rotPtr[2] = rot.m_q2;
rotPtr[3] = rot.m_q3;
}