From b0ca2df3aa52e4b73242bd8ba173a13c49f910d8 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 3 Jun 2015 14:56:04 -0700 Subject: [PATCH] move API from PhysicsEngine to ObjectMotionState --- .../src/RenderableDebugableEntityItem.cpp | 3 +- libraries/physics/src/ObjectMotionState.cpp | 1 + libraries/physics/src/ObjectMotionState.h | 2 ++ libraries/physics/src/PhysicsEngine.cpp | 34 ------------------- libraries/physics/src/PhysicsEngine.h | 4 --- 5 files changed, 5 insertions(+), 39 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp b/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp index 017cb289f0..7854aee82f 100644 --- a/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp @@ -80,7 +80,8 @@ void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) renderBoundingBox(entity, args, 0.3f, yellowColor); } - if (PhysicsEngine::physicsInfoIsActive(entity->getPhysicsInfo())) { + ObjectMotionState* motionState = static_cast(entity->getPhysicsInfo()); + if (motionState && motionState->isActive()) { renderHoverDot(entity, args); } } diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 57b75f0f3b..e2f248ead7 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -200,3 +200,4 @@ void ObjectMotionState::updateBodyMassProperties() { _body->setMassProps(mass, inertia); _body->updateInertiaTensor(); } + diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index fc0c58b5da..4a9fd769c8 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -125,6 +125,8 @@ public: virtual int16_t computeCollisionGroup() = 0; + bool isActive() const { return _body ? _body->isActive() : false; } + friend class PhysicsEngine; protected: diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index c27eaafdfd..b6a509a874 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -431,40 +431,6 @@ void PhysicsEngine::setCharacterController(DynamicCharacterController* character } } -// static -bool PhysicsEngine::physicsInfoIsActive(void* physicsInfo) { - if (!physicsInfo) { - return false; - } - - ObjectMotionState* motionState = static_cast(physicsInfo); - btRigidBody* body = motionState->getRigidBody(); - if (!body) { - return false; - } - - return body->isActive(); -} - -// static -bool PhysicsEngine::getBodyLocation(void* physicsInfo, glm::vec3& positionReturn, glm::quat& rotationReturn) { - if (!physicsInfo) { - return false; - } - - ObjectMotionState* motionState = static_cast(physicsInfo); - btRigidBody* body = motionState->getRigidBody(); - if (!body) { - return false; - } - - const btTransform& worldTrans = body->getCenterOfMassTransform(); - positionReturn = bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(); - rotationReturn = bulletToGLM(worldTrans.getRotation()); - - return true; -} - int16_t PhysicsEngine::getCollisionMask(int16_t group) const { const int16_t* mask = _collisionMasks.find(btHashInt((int)group)); return mask ? *mask : COLLISION_MASK_DEFAULT; diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index edc6615a26..db00a2ba01 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -91,10 +91,6 @@ public: void dumpNextStats() { _dumpNextStats = true; } - // TODO: Andrew to move these to ObjectMotionState - static bool physicsInfoIsActive(void* physicsInfo); - static bool getBodyLocation(void* physicsInfo, glm::vec3& positionReturn, glm::quat& rotationReturn); - int16_t getCollisionMask(int16_t group) const; private: