cleanup and moving things around

This commit is contained in:
Andrew Meadows 2014-11-19 15:31:17 -08:00
parent 3b85805048
commit 48164c9399
3 changed files with 21 additions and 30 deletions

View file

@ -669,8 +669,7 @@ void EntityTree::update() {
// 1) stationary things that are not changing - most models // 1) stationary things that are not changing - most models
// 2) mortal things - these are stationary but have a lifetime - then need to be checked, // 2) mortal things - these are stationary but have a lifetime - then need to be checked,
// can be touched linearly, and won't change the tree // can be touched linearly, and won't change the tree
// 2) changing things - like things animating they can be touched linearly and they don't change the tree // 2) moving/changing things - like things animating they can be touched linearly and they don't change the tree
// 3) moving things - these need to scan the tree and update accordingly
// finally - all things that need to be deleted, can be handled on a single delete pass. // finally - all things that need to be deleted, can be handled on a single delete pass.
// //
// TODO: theoretically we could combine the move and delete tree passes... // TODO: theoretically we could combine the move and delete tree passes...

View file

@ -149,8 +149,8 @@ bool PhysicsEngine::addEntity(CustomMotionState* motionState) {
motionState->applyVelocities(); motionState->applyVelocities();
break; break;
} }
case MOTION_TYPE_STATIC:
default: { default: {
// MOTION_TYPE_STATIC
body = new btRigidBody(mass, motionState, shape, inertia); body = new btRigidBody(mass, motionState, shape, inertia);
body->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT); body->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
body->updateInertiaTensor(); body->updateInertiaTensor();
@ -166,6 +166,22 @@ bool PhysicsEngine::addEntity(CustomMotionState* motionState) {
return false; return false;
} }
bool PhysicsEngine::removeEntity(CustomMotionState* motionState) {
assert(motionState);
btRigidBody* body = motionState->_body;
if (body) {
const btCollisionShape* shape = body->getCollisionShape();
ShapeInfo info;
info.collectInfo(shape);
_dynamicsWorld->removeRigidBody(body);
_shapeManager.releaseShape(info);
delete body;
motionState->_body = NULL;
return true;
}
return false;
}
bool PhysicsEngine::updateEntityMotionType(CustomMotionState* motionState) { bool PhysicsEngine::updateEntityMotionType(CustomMotionState* motionState) {
btRigidBody* body = motionState->_body; btRigidBody* body = motionState->_body;
if (!body) { if (!body) {
@ -216,28 +232,6 @@ bool PhysicsEngine::updateEntityMotionType(CustomMotionState* motionState) {
return false; return false;
} }
bool PhysicsEngine::removeEntity(CustomMotionState* motionState) {
assert(motionState);
btRigidBody* body = motionState->_body;
if (body) {
const btCollisionShape* shape = body->getCollisionShape();
ShapeInfo info;
info.collectInfo(shape);
_dynamicsWorld->removeRigidBody(body);
_shapeManager.releaseShape(info);
delete body;
motionState->_body = NULL;
return true;
}
return false;
}
bool PhysicsEngine::updateEntityMotionType(CustomMotionState* motionState, MotionType type) {
// TODO: implement this
assert(motionState);
return false;
}
bool PhysicsEngine::updateEntityMassProperties(CustomMotionState* motionState, float mass, const glm::vec3& inertiaEigenValues) { bool PhysicsEngine::updateEntityMassProperties(CustomMotionState* motionState, float mass, const glm::vec3& inertiaEigenValues) {
// TODO: implement this // TODO: implement this
assert(motionState); assert(motionState);

View file

@ -63,15 +63,13 @@ public:
/// \return true if Entity added /// \return true if Entity added
bool addEntity(CustomMotionState* motionState); bool addEntity(CustomMotionState* motionState);
/// \param motionState pointer to Entity's MotionState
/// \return true if entity updated
bool updateEntityMotionType(CustomMotionState* motionState);
/// \param motionState pointer to Entity's MotionState /// \param motionState pointer to Entity's MotionState
/// \return true if Entity removed /// \return true if Entity removed
bool removeEntity(CustomMotionState* motionState); bool removeEntity(CustomMotionState* motionState);
bool updateEntityMotionType(CustomMotionState* motionState, MotionType type); /// \param motionState pointer to Entity's MotionState
/// \return true if entity updated
bool updateEntityMotionType(CustomMotionState* motionState);
bool updateEntityMassProperties(CustomMotionState* motionState, float mass, const glm::vec3& inertiaEigenValues); bool updateEntityMassProperties(CustomMotionState* motionState, float mass, const glm::vec3& inertiaEigenValues);