added angular limits to the Generic D6 constraint. Works for small angles. Will add a check for different combinations, and use different extraction of ordering of rotation from the diff quaternion.
Improved vehicle interpolation of wheels, and added Z-up axis option for the Demo made 'getWorldTransform' const method in btMotionState added future 'deactivationCallback'(not used yet)
This commit is contained in:
@@ -19,16 +19,25 @@ struct btDefaultMotionState : public btMotionState
|
||||
}
|
||||
|
||||
///synchronizes world transform from user to physics
|
||||
virtual void getWorldTransform(btTransform& centerOfMassWorldTrans )
|
||||
virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const
|
||||
{
|
||||
centerOfMassWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ;
|
||||
}
|
||||
|
||||
///synchronizes world transform from physics to user
|
||||
///Bullet only calls the update of worldtransform for active objects
|
||||
virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans)
|
||||
{
|
||||
m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ;
|
||||
}
|
||||
|
||||
///Bullet gives a callback for objects that are about to be deactivated (put asleep)
|
||||
/// You can intercept this callback for your own bookkeeping.
|
||||
///Also you can return false to disable deactivation for this object this frame.
|
||||
virtual bool deactivationCallback(void* userPointer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //DEFAULT_MOTION_STATE_H
|
||||
|
||||
@@ -29,10 +29,15 @@ class btMotionState
|
||||
|
||||
}
|
||||
|
||||
virtual void getWorldTransform(btTransform& worldTrans )=0;
|
||||
virtual void getWorldTransform(btTransform& worldTrans ) const =0;
|
||||
|
||||
//Bullet only calls the update of worldtransform for active objects
|
||||
virtual void setWorldTransform(const btTransform& worldTrans)=0;
|
||||
|
||||
|
||||
//future: when Bullet makes attempt to deactivate object, you can intercept this callback (return false to disable deactivation for this object this frame)
|
||||
virtual bool deactivationCallback(void* userPointer) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //BT_MOTIONSTATE_H
|
||||
|
||||
@@ -108,7 +108,16 @@ public:
|
||||
static void calculateVelocity(const btTransform& transform0,const btTransform& transform1,btScalar timeStep,btVector3& linVel,btVector3& angVel)
|
||||
{
|
||||
linVel = (transform1.getOrigin() - transform0.getOrigin()) / timeStep;
|
||||
#ifdef USE_QUATERNION_DIFF
|
||||
btVector3 axis;
|
||||
btScalar angle;
|
||||
calculateDiffAxisAngle(transform0,transform1,axis,angle);
|
||||
angVel = axis * angle / timeStep;
|
||||
}
|
||||
|
||||
static void calculateDiffAxisAngle(const btTransform& transform0,const btTransform& transform1,btVector3& axis,btScalar& angle)
|
||||
{
|
||||
|
||||
#ifdef USE_QUATERNION_DIFF
|
||||
btQuaternion orn0 = transform0.getRotation();
|
||||
btQuaternion orn1a = transform1.getRotation();
|
||||
btQuaternion orn1 = orn0.farthest(orn1a);
|
||||
@@ -118,9 +127,7 @@ public:
|
||||
btQuaternion dorn;
|
||||
dmat.getRotation(dorn);
|
||||
#endif//USE_QUATERNION_DIFF
|
||||
|
||||
btVector3 axis;
|
||||
btScalar angle;
|
||||
|
||||
angle = dorn.getAngle();
|
||||
axis = btVector3(dorn.x(),dorn.y(),dorn.z());
|
||||
axis[3] = 0.f;
|
||||
@@ -130,13 +137,8 @@ public:
|
||||
axis = btVector3(1.f,0.f,0.f);
|
||||
else
|
||||
axis /= btSqrt(len);
|
||||
|
||||
|
||||
angVel = axis * angle / timeStep;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //SIMD_TRANSFORM_UTIL_H
|
||||
|
||||
Reference in New Issue
Block a user