move API from PhysicsEngine to ObjectMotionState

This commit is contained in:
Andrew Meadows 2015-06-03 14:56:04 -07:00
parent 8e61a10bcf
commit b0ca2df3aa
5 changed files with 5 additions and 39 deletions

View file

@ -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<ObjectMotionState*>(entity->getPhysicsInfo());
if (motionState && motionState->isActive()) {
renderHoverDot(entity, args);
}
}

View file

@ -200,3 +200,4 @@ void ObjectMotionState::updateBodyMassProperties() {
_body->setMassProps(mass, inertia);
_body->updateInertiaTensor();
}

View file

@ -125,6 +125,8 @@ public:
virtual int16_t computeCollisionGroup() = 0;
bool isActive() const { return _body ? _body->isActive() : false; }
friend class PhysicsEngine;
protected:

View file

@ -431,40 +431,6 @@ void PhysicsEngine::setCharacterController(DynamicCharacterController* character
}
}
// static
bool PhysicsEngine::physicsInfoIsActive(void* physicsInfo) {
if (!physicsInfo) {
return false;
}
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(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<ObjectMotionState*>(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;

View file

@ -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: