diff --git a/libraries/physics/src/EntityMotionState.h b/libraries/physics/src/EntityMotionState.h index 534ef1c135..91186c823c 100644 --- a/libraries/physics/src/EntityMotionState.h +++ b/libraries/physics/src/EntityMotionState.h @@ -15,10 +15,10 @@ #include #ifdef USE_BULLET_PHYSICS -#include "CustomMotionState.h" +#include "ObjectMotionState.h" #else // USE_BULLET_PHYSICS -// CustomMotionState stubbery -class CustomMotionState { +// ObjectMotionState stubbery +class ObjectMotionState { public: bool _foo; }; @@ -26,7 +26,7 @@ public: class EntityItem; -class EntityMotionState : public CustomMotionState { +class EntityMotionState : public ObjectMotionState { public: static void setWorldOffset(const glm::vec3& offset); static const glm::vec3& getWorldOffset(); diff --git a/libraries/physics/src/CustomMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp similarity index 72% rename from libraries/physics/src/CustomMotionState.cpp rename to libraries/physics/src/ObjectMotionState.cpp index 20bd1aac69..9a57db3dae 100644 --- a/libraries/physics/src/CustomMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -1,5 +1,5 @@ // -// CustomMotionState.cpp +// ObjectMotionState.cpp // libraries/physcis/src // // Created by Andrew Meadows 2014.11.05 @@ -14,7 +14,7 @@ #include #include "BulletUtil.h" -#include "CustomMotionState.h" +#include "ObjectMotionState.h" const float MIN_DENSITY = 200.0f; const float DEFAULT_DENSITY = 1000.0f; @@ -29,7 +29,7 @@ const float MAX_FRICTION = 10.0f; const float DEFAULT_RESTITUTION = 0.0f; -CustomMotionState::CustomMotionState() : +ObjectMotionState::ObjectMotionState() : _density(DEFAULT_DENSITY), _volume(DEFAULT_VOLUME), _friction(DEFAULT_FRICTION), @@ -39,50 +39,50 @@ CustomMotionState::CustomMotionState() : _body(NULL) { } -CustomMotionState::~CustomMotionState() { +ObjectMotionState::~ObjectMotionState() { // NOTE: you MUST remove this MotionState from the world before you call the dtor. assert(_body == NULL); } -void CustomMotionState::setDensity(float density) { +void ObjectMotionState::setDensity(float density) { _density = btMax(btMin(fabsf(density), MAX_DENSITY), MIN_DENSITY); } -void CustomMotionState::setFriction(float friction) { +void ObjectMotionState::setFriction(float friction) { _friction = btMax(btMin(fabsf(friction), MAX_FRICTION), 0.0f); } -void CustomMotionState::setRestitution(float restitution) { +void ObjectMotionState::setRestitution(float restitution) { _restitution = btMax(btMin(fabsf(restitution), 1.0f), 0.0f); } -void CustomMotionState::setVolume(float volume) { +void ObjectMotionState::setVolume(float volume) { _volume = btMax(btMin(fabsf(volume), MAX_VOLUME), MIN_VOLUME); } -void CustomMotionState::setVelocity(const glm::vec3& velocity) const { +void ObjectMotionState::setVelocity(const glm::vec3& velocity) const { btVector3 v; glmToBullet(velocity, v); _body->setLinearVelocity(v); } -void CustomMotionState::setAngularVelocity(const glm::vec3& velocity) const { +void ObjectMotionState::setAngularVelocity(const glm::vec3& velocity) const { btVector3 v; glmToBullet(velocity, v); _body->setAngularVelocity(v); } -void CustomMotionState::setGravity(const glm::vec3& gravity) const { +void ObjectMotionState::setGravity(const glm::vec3& gravity) const { btVector3 g; glmToBullet(gravity, g); _body->setGravity(g); } -void CustomMotionState::getVelocity(glm::vec3& velocityOut) const { +void ObjectMotionState::getVelocity(glm::vec3& velocityOut) const { bulletToGLM(_body->getLinearVelocity(), velocityOut); } -void CustomMotionState::getAngularVelocity(glm::vec3& angularVelocityOut) const { +void ObjectMotionState::getAngularVelocity(glm::vec3& angularVelocityOut) const { bulletToGLM(_body->getAngularVelocity(), angularVelocityOut); } diff --git a/libraries/physics/src/CustomMotionState.h b/libraries/physics/src/ObjectMotionState.h similarity index 88% rename from libraries/physics/src/CustomMotionState.h rename to libraries/physics/src/ObjectMotionState.h index d78aa66dfd..10e001f7c4 100644 --- a/libraries/physics/src/CustomMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -1,5 +1,5 @@ // -// CustomMotionState.h +// ObjectMotionState.h // libraries/physcis/src // // Created by Andrew Meadows 2014.11.05 @@ -9,8 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_CustomMotionState_h -#define hifi_CustomMotionState_h +#ifndef hifi_ObjectMotionState_h +#define hifi_ObjectMotionState_h #ifdef USE_BULLET_PHYSICS @@ -25,10 +25,10 @@ enum MotionType { MOTION_TYPE_KINEMATIC // keyframed motion }; -class CustomMotionState : public btMotionState { +class ObjectMotionState : public btMotionState { public: - CustomMotionState(); - ~CustomMotionState(); + ObjectMotionState(); + ~ObjectMotionState(); //// these override methods of the btMotionState base class //virtual void getWorldTransform (btTransform &worldTrans) const; @@ -70,4 +70,4 @@ protected: }; #endif // USE_BULLET_PHYSICS -#endif // hifi_CustomMotionState_h +#endif // hifi_ObjectMotionState_h diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 56740b5e57..a6013111b8 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -46,7 +46,7 @@ void PhysicsEngine::updateEntities(QSet& entitiesToDelete) { EntityItem* entity = *item_itr; void* physicsInfo = entity->getPhysicsInfo(); if (physicsInfo) { - CustomMotionState* motionState = static_cast(physicsInfo); + ObjectMotionState* motionState = static_cast(physicsInfo); updateObject(motionState, entity->getUpdateFlags()); } entity->clearUpdateFlags(); @@ -103,7 +103,7 @@ void PhysicsEngine::removeEntity(EntityItem* entity) { assert(entity); void* physicsInfo = entity->getPhysicsInfo(); if (physicsInfo) { - CustomMotionState* motionState = static_cast(physicsInfo); + ObjectMotionState* motionState = static_cast(physicsInfo); removeObject(motionState); entity->setPhysicsInfo(NULL); } @@ -122,7 +122,7 @@ void PhysicsEngine::clearEntities() { for (entityItr = _entities.begin(); entityItr != _entities.end(); ++entityItr) { void* physicsInfo = (*entityItr)->getPhysicsInfo(); if (physicsInfo) { - CustomMotionState* motionState = static_cast(physicsInfo); + ObjectMotionState* motionState = static_cast(physicsInfo); removeObject(motionState); } } @@ -242,7 +242,7 @@ bool PhysicsEngine::removeVoxel(const glm::vec3& position, float scale) { // CF_DISABLE_VISUALIZE_OBJECT = 32, //disable debug drawing // CF_DISABLE_SPU_COLLISION_PROCESSING = 64//disable parallel/SPU processing -bool PhysicsEngine::addObject(CustomMotionState* motionState) { +bool PhysicsEngine::addObject(ObjectMotionState* motionState) { assert(motionState); ShapeInfo info; motionState->computeShapeInfo(info); @@ -289,7 +289,7 @@ bool PhysicsEngine::addObject(CustomMotionState* motionState) { return false; } -bool PhysicsEngine::removeObject(CustomMotionState* motionState) { +bool PhysicsEngine::removeObject(ObjectMotionState* motionState) { assert(motionState); btRigidBody* body = motionState->_body; if (body) { @@ -305,7 +305,7 @@ bool PhysicsEngine::removeObject(CustomMotionState* motionState) { return false; } -bool PhysicsEngine::updateObject(CustomMotionState* motionState, uint32_t flags) { +bool PhysicsEngine::updateObject(ObjectMotionState* motionState, uint32_t flags) { btRigidBody* body = motionState->_body; if (!body) { return false; @@ -322,7 +322,7 @@ bool PhysicsEngine::updateObject(CustomMotionState* motionState, uint32_t flags) } // private -void PhysicsEngine::updateObjectHard(btRigidBody* body, CustomMotionState* motionState, uint32_t flags) { +void PhysicsEngine::updateObjectHard(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags) { MotionType newType = motionState->getMotionType(); // pull body out of physics engine @@ -398,7 +398,7 @@ void PhysicsEngine::updateObjectHard(btRigidBody* body, CustomMotionState* motio } // private -void PhysicsEngine::updateObjectEasy(btRigidBody* body, CustomMotionState* motionState, uint32_t flags) { +void PhysicsEngine::updateObjectEasy(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags) { if (flags & PHYSICS_UPDATE_POSITION) { btTransform transform; motionState->getWorldTransform(transform); diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index fdf42f5209..2656a3f8cf 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -39,7 +39,7 @@ const uint32_t PHYSICS_UPDATE_EASY = PHYSICS_UPDATE_POSITION | PHYSICS_UPDATE_VE #include #include "BulletUtil.h" -#include "CustomMotionState.h" +#include "ObjectMotionState.h" #include "PositionHashKey.h" #include "ShapeManager.h" #include "ThreadSafeDynamicsWorld.h" @@ -101,20 +101,20 @@ public: /// \param motionState pointer to Object's MotionState /// \return true if Object added - bool addObject(CustomMotionState* motionState); + bool addObject(ObjectMotionState* motionState); /// \param motionState pointer to Object's MotionState /// \return true if Object removed - bool removeObject(CustomMotionState* motionState); + bool removeObject(ObjectMotionState* motionState); /// \param motionState pointer to Object's MotionState /// \param flags set of bits indicating what categories of properties need to be updated /// \return true if entity updated - bool updateObject(CustomMotionState* motionState, uint32_t flags); + bool updateObject(ObjectMotionState* motionState, uint32_t flags); protected: - void updateObjectHard(btRigidBody* body, CustomMotionState* motionState, uint32_t flags); - void updateObjectEasy(btRigidBody* body, CustomMotionState* motionState, uint32_t flags); + void updateObjectHard(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags); + void updateObjectEasy(btRigidBody* body, ObjectMotionState* motionState, uint32_t flags); btClock _clock; btDefaultCollisionConfiguration* _collisionConfig;