I am blending my client and server positions of btRigidBodys like this:
Code: Select all
void CModel::UpdateVelocity( const float& lx, const float& ly, const float& lz,
const float& ax, const float& ay, const float& az )
{
const btVector3 clientPos = m_body->getWorldTransform().getOrigin();
const btQuaternion clientRot = m_body->getWorldTransform().getRotation().normalized();
const btVector3 serverPos( px, py, pz );
const btQuaternion serverRot = btQuaternion( rx, ry, rz, rw ).normalized();
const btVector3 lerpPos = clientPos.lerp( serverPos, SERVER_UPDATE_BIAS );
const btQuaternion lerpRot = clientRot.slerp( serverRot, SERVER_UPDATE_BIAS );
btTransform t;
t.setIdentity();
t.setOrigin( lerpPos );
t.setRotation(lerpRot);
m_body->setWorldTransform(t);
m_body->setCenterOfMassTransform(t);
}
Code: Select all
msvcr80d.dll!_wassert(const wchar_t * expr=0x01c1e3c4, const wchar_t * filename=0x01c1e3f0, unsigned int lineno=197) Line 384 C
Objects.dll!btAcos(float x=1.0000001) Line 197 + 0x29 bytes C++
Objects.dll!btQuaternion::angle(const btQuaternion & q={...}) Line 148 + 0x1e bytes C++
Objects.dll!btQuaternion::slerp(const btQuaternion & q={...}, const float & t=1.0000000) Line 196 + 0xc bytes C++
> Objects.dll!CModel::UpdateTransform(const float & px=698.87201, const float & py=3.2585874, const float & pz=704.51593, const float & rx=0.00022888184, const float & ry=0.024795890, const float & rz=1.5258789e-005, const float & rw=0.99966431) Line 456 C++
Why is this? My quaternions are normalised. They are generated by bullet code on the server.
My theory is that when passed thru the network engine, the serialisation process for the 4 floats used to describe the quaternion is lossy, so the client receives slightly wrong values, triggering this problem. Is there any other way than normalisation that I can correct the quaternion?
Many thanks
Simon