eliminate angular dynamics of other-avatars

This commit is contained in:
Andrew Meadows 2018-08-01 11:58:52 -07:00
parent c939699879
commit bd6f00e707
3 changed files with 14 additions and 1 deletions

View file

@ -96,6 +96,10 @@ void AvatarMotionState::setWorldTransform(const btTransform& worldTrans) {
btVector3 velocity = glmToBullet(getObjectLinearVelocity()) + (1.0f / SPRING_TIMESCALE) * offsetToTarget;
_body->setLinearVelocity(velocity);
_body->setAngularVelocity(glmToBullet(getObjectAngularVelocity()));
// slam its rotation
btTransform newTransform = worldTrans;
newTransform.setRotation(glmToBullet(getObjectRotation()));
_body->setWorldTransform(newTransform);
}
}
@ -191,6 +195,14 @@ void AvatarMotionState::cacheShapeDiameter() {
}
}
void AvatarMotionState::setRigidBody(btRigidBody* body) {
ObjectMotionState::setRigidBody(body);
if (_body) {
// remove angular dynamics from this body
_body->setAngularFactor(0.0f);
}
}
void AvatarMotionState::setShape(const btCollisionShape* shape) {
cacheShapeDiameter();
ObjectMotionState::setShape(shape);

View file

@ -74,6 +74,7 @@ public:
friend class Avatar;
protected:
void setRigidBody(btRigidBody* body) override;
void setShape(const btCollisionShape* shape) override;
void cacheShapeDiameter();

View file

@ -175,7 +175,7 @@ protected:
virtual void setMotionType(PhysicsMotionType motionType);
void updateCCDConfiguration();
void setRigidBody(btRigidBody* body);
virtual void setRigidBody(btRigidBody* body);
virtual void setShape(const btCollisionShape* shape);
MotionStateType _type { MOTIONSTATE_TYPE_INVALID }; // type of MotionState