impl AvatarMotionState::set/getWorldTransform()

This commit is contained in:
Andrew Meadows 2015-05-21 15:34:30 -07:00
parent 67f5d0773d
commit 2e3973dfdd
3 changed files with 19 additions and 14 deletions

View file

@ -11,6 +11,7 @@
#include "Avatar.h"
#include "AvatarMotionState.h"
#include "BulletUtil.h"
AvatarMotionState::AvatarMotionState(Avatar* avatar, btCollisionShape* shape) : ObjectMotionState(shape), _avatar(avatar) {
}
@ -19,14 +20,6 @@ AvatarMotionState::~AvatarMotionState() {
_avatar = nullptr;
}
// virtual
void AvatarMotionState::handleEasyChanges(uint32_t flags) {
}
// virtual
void AvatarMotionState::handleHardAndEasyChanges(uint32_t flags, PhysicsEngine* engine) {
}
// virtual
uint32_t AvatarMotionState::getAndClearIncomingDirtyFlags() {
uint32_t dirtyFlags = 0;
@ -58,12 +51,28 @@ bool AvatarMotionState::isMoving() const {
// virtual
void AvatarMotionState::getWorldTransform(btTransform& worldTrans) const {
// TODO: implement this
if (!_avatar) {
return;
}
worldTrans.setOrigin(glmToBullet(getObjectPosition()));
worldTrans.setRotation(glmToBullet(getObjectRotation()));
_body->setLinearVelocity(glmToBullet(getObjectLinearVelocity()));
_body->setAngularVelocity(glmToBullet(getObjectLinearVelocity()));
}
// virtual
void AvatarMotionState::setWorldTransform(const btTransform& worldTrans) {
// TODO: implement this
if (!_avatar) {
return;
}
// The PhysicsEngine does not move other Avatars.
// Instead we enforce the current transform of the Avatar
btTransform newTransform;
newTransform.setOrigin(glmToBullet(getObjectPosition()));
newTransform.setRotation(glmToBullet(getObjectRotation()));
_body->setWorldTransform(newTransform);
_body->setLinearVelocity(glmToBullet(getObjectLinearVelocity()));
_body->setAngularVelocity(glmToBullet(getObjectLinearVelocity()));
}
// These pure virtual methods must be implemented for each MotionState type

View file

@ -23,9 +23,6 @@ public:
AvatarMotionState(Avatar* avatar, btCollisionShape* shape);
~AvatarMotionState();
virtual void handleEasyChanges(uint32_t flags);
virtual void handleHardAndEasyChanges(uint32_t flags, PhysicsEngine* engine);
virtual MotionType getMotionType() const { return _motionType; }
virtual uint32_t getAndClearIncomingDirtyFlags();

View file

@ -88,7 +88,6 @@ void EntityMotionState::handleEasyChanges(uint32_t flags) {
if ((flags & EntityItem::DIRTY_PHYSICS_ACTIVATION) && !_body->isActive()) {
_body->activate();
}
}