mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
impl AvatarMotionState::set/getWorldTransform()
This commit is contained in:
parent
67f5d0773d
commit
2e3973dfdd
3 changed files with 19 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -88,7 +88,6 @@ void EntityMotionState::handleEasyChanges(uint32_t flags) {
|
|||
if ((flags & EntityItem::DIRTY_PHYSICS_ACTIVATION) && !_body->isActive()) {
|
||||
_body->activate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue