From 1df6c32a4e8cf287baf3e6191dda0c3e609b2484 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 1 Dec 2014 16:03:14 -0800 Subject: [PATCH] moving Shape* back into shared lib removing dependency of entities lib on physics lib physics lib now depends on entities lib --- interface/src/Application.cpp | 7 +++--- libraries/avatars/CMakeLists.txt | 2 +- libraries/entities/CMakeLists.txt | 3 +-- libraries/entities/src/BoxEntityItem.cpp | 3 ++- libraries/entities/src/BoxEntityItem.h | 4 ---- libraries/entities/src/EntityItem.cpp | 17 +++---------- libraries/entities/src/EntityItem.h | 21 +++++++--------- libraries/entities/src/EntitySimulation.h | 2 +- libraries/entities/src/EntityTree.cpp | 3 +-- libraries/entities/src/EntityTreeElement.cpp | 6 ++--- libraries/entities/src/EntityTreeElement.h | 4 ++-- .../entities/src/SimpleEntitySimulation.cpp | 2 +- .../entities/src/SimpleEntitySimulation.h | 2 +- libraries/octree/CMakeLists.txt | 2 +- libraries/physics/CMakeLists.txt | 3 ++- libraries/physics/src/ContactPoint.h | 3 ++- .../src/EntityMotionState.cpp | 12 +++++----- .../src/EntityMotionState.h | 4 +++- libraries/physics/src/PhysicsEngine.cpp | 24 +++++++++---------- libraries/physics/src/PhysicsEngine.h | 20 ++++++++-------- libraries/physics/src/PhysicsEntity.h | 6 ++--- libraries/physics/src/ShapeInfo.cpp | 1 + libraries/physics/src/ShapeInfo.h | 2 -- .../{physics => shared}/src/AACubeShape.cpp | 2 +- .../{physics => shared}/src/AACubeShape.h | 0 .../{physics => shared}/src/CapsuleShape.cpp | 6 ++--- .../{physics => shared}/src/CapsuleShape.h | 3 +-- .../{physics => shared}/src/CollisionInfo.cpp | 2 +- .../{physics => shared}/src/CollisionInfo.h | 0 .../{physics => shared}/src/ListShape.cpp | 0 libraries/{physics => shared}/src/ListShape.h | 0 .../{physics => shared}/src/PlaneShape.cpp | 5 ++-- .../{physics => shared}/src/PlaneShape.h | 0 .../src/RayIntersectionInfo.h | 0 libraries/{physics => shared}/src/Shape.h | 0 .../{physics => shared}/src/ShapeCollider.cpp | 8 +++---- .../{physics => shared}/src/ShapeCollider.h | 4 ++-- .../{physics => shared}/src/SphereShape.cpp | 0 .../{physics => shared}/src/SphereShape.h | 3 +-- 39 files changed, 81 insertions(+), 105 deletions(-) rename libraries/{entities => physics}/src/EntityMotionState.cpp (95%) rename libraries/{entities => physics}/src/EntityMotionState.h (97%) rename libraries/{physics => shared}/src/AACubeShape.cpp (98%) rename libraries/{physics => shared}/src/AACubeShape.h (100%) rename libraries/{physics => shared}/src/CapsuleShape.cpp (99%) rename libraries/{physics => shared}/src/CapsuleShape.h (98%) rename libraries/{physics => shared}/src/CollisionInfo.cpp (99%) rename libraries/{physics => shared}/src/CollisionInfo.h (100%) rename libraries/{physics => shared}/src/ListShape.cpp (100%) rename libraries/{physics => shared}/src/ListShape.h (100%) rename libraries/{physics => shared}/src/PlaneShape.cpp (98%) rename libraries/{physics => shared}/src/PlaneShape.h (100%) rename libraries/{physics => shared}/src/RayIntersectionInfo.h (100%) rename libraries/{physics => shared}/src/Shape.h (100%) rename libraries/{physics => shared}/src/ShapeCollider.cpp (99%) rename libraries/{physics => shared}/src/ShapeCollider.h (99%) rename libraries/{physics => shared}/src/SphereShape.cpp (100%) rename libraries/{physics => shared}/src/SphereShape.h (98%) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6f94925858..8abbf6314f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2021,8 +2021,8 @@ void Application::init() { connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::updateMyAvatarTransform); #ifdef USE_BULLET_PHYSICS - _physicsEngine.initSafe(_entities.getTree()); - _entities.getTree()->setPhysicsEngine(&_physicsEngine); +// _physicsEngine.initSafe(_entities.getTree()); +// _entities.getTree()->setSimulation(&_physicsEngine); #endif // USE_BULLET_PHYSICS } @@ -4159,15 +4159,14 @@ void Application::updateMyAvatarTransform() { glm::vec3 avatarPosition = _myAvatar->getPosition(); glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset(); if (glm::distance(avatarPosition, physicsWorldOffset) > SIMULATION_OFFSET_QUANTIZATION) { - //_entityCollisionSystem.forgetAllPhysics(); glm::vec3 newOriginOffset = avatarPosition; int halfExtent = (int)HALF_SIMULATION_EXTENT; for (int i = 0; i < 3; ++i) { newOriginOffset[i] = (float)(glm::max(halfExtent, ((int)(avatarPosition[i] / SIMULATION_OFFSET_QUANTIZATION)) * (int)SIMULATION_OFFSET_QUANTIZATION)); } + // TODO: Andrew to replace this with method that actually moves existing object positions in PhysicsEngine _physicsEngine.setOriginOffset(newOriginOffset); - //_entityCollisionSystem.rememberAllPhysics(); } #endif // USE_BULLET_PHYSICS } diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 42b3cf7d3c..8cbbf7d1ae 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -5,7 +5,7 @@ setup_hifi_library(Network Script) include_glm() -link_hifi_libraries(shared octree voxels networking physics) +link_hifi_libraries(shared octree voxels networking) include_hifi_library_headers(fbx) # call macro to link our dependencies and bubble them up via a property on our target diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index 5e3ab70f76..40d71a032d 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -4,9 +4,8 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) include_glm() -include_bullet() -link_hifi_libraries(shared octree fbx networking animation physics) +link_hifi_libraries(shared octree fbx networking animation) # call macro to link our dependencies and bubble them up via a property on our target link_shared_dependencies() diff --git a/libraries/entities/src/BoxEntityItem.cpp b/libraries/entities/src/BoxEntityItem.cpp index d1a58722b0..ecd1306297 100644 --- a/libraries/entities/src/BoxEntityItem.cpp +++ b/libraries/entities/src/BoxEntityItem.cpp @@ -15,7 +15,6 @@ #include #include "BoxEntityItem.h" -#include "EntityMotionState.h" #include "EntityTree.h" #include "EntityTreeElement.h" @@ -97,6 +96,7 @@ void BoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor()); } +/* #ifdef USE_BULLET_PHYSICS EntityMotionState* BoxEntityItem::createMotionState() { if (!_motionState) { @@ -107,4 +107,5 @@ EntityMotionState* BoxEntityItem::createMotionState() { return _motionState; } #endif // USE_BULLET_PHYSICS +*/ diff --git a/libraries/entities/src/BoxEntityItem.h b/libraries/entities/src/BoxEntityItem.h index faae308b43..bea4f0c32a 100644 --- a/libraries/entities/src/BoxEntityItem.h +++ b/libraries/entities/src/BoxEntityItem.h @@ -50,10 +50,6 @@ public: _color[GREEN_INDEX] = value.green; _color[BLUE_INDEX] = value.blue; } - -#ifdef USE_BULLET_PHYSICS - EntityMotionState* createMotionState(); -#endif // USE_BULLET_PHYSICS protected: rgbColor _color; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index f07ce3ca16..928645b349 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -21,7 +21,6 @@ #include "EntityScriptingInterface.h" #include "EntityItem.h" -#include "EntityMotionState.h" #include "EntityTree.h" const float EntityItem::IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime @@ -91,7 +90,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) { _lastEditedFromRemoteInRemoteTime = 0; _lastUpdated = 0; _created = 0; - _motionState = NULL; + _physicsInfo = NULL; _updateFlags = 0; _changedOnServer = 0; initFromEntityItemID(entityItemID); @@ -105,7 +104,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert _lastEditedFromRemoteInRemoteTime = 0; _lastUpdated = 0; _created = properties.getCreated(); - _motionState = NULL; + _physicsInfo = NULL; _updateFlags = 0; _changedOnServer = 0; initFromEntityItemID(entityItemID); @@ -114,9 +113,6 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert } EntityItem::~EntityItem() { - // Make sure the EntityItem has been removed from the physics engine AND - // that its _motionState has been destroyed BEFORE you get here. - assert(_motionState == NULL); } EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const { @@ -628,7 +624,7 @@ void EntityItem::update(const quint64& updateTime) { qDebug() << " ********** EntityItem::update() .... SETTING _lastUpdated=" << _lastUpdated; } - if (!_motionState) { + if (!_physicsInfo) { if (hasAngularVelocity()) { glm::quat rotation = getRotation(); glm::vec3 angularVelocity = glm::radians(getAngularVelocity()); @@ -1072,10 +1068,3 @@ void EntityItem::updateScript(const QString& value) { } } -void EntityItem::destroyMotionState() { - if (_motionState) { - delete _motionState; - _motionState = NULL; - } -} - diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 7c43194152..d3225daa64 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -22,7 +22,6 @@ #include // for EncodeBitstreamParams class #include // for OctreeElement::AppendState #include -#include #include #include "EntityItemID.h" @@ -46,13 +45,13 @@ class EntityItem { public: enum EntityUpdateFlags { // flags for things that need to be relayed to physics engine - UPDATE_POSITION = PHYSICS_UPDATE_POSITION, //0x0001, - UPDATE_VELOCITY = PHYSICS_UPDATE_VELOCITY, //0x0002, - UPDATE_GRAVITY = PHYSICS_UPDATE_GRAVITY, //0x0004, - UPDATE_MASS = PHYSICS_UPDATE_MASS, //0x0008, - UPDATE_COLLISION_GROUP = PHYSICS_UPDATE_COLLISION_GROUP, //0x0010, - UPDATE_MOTION_TYPE = PHYSICS_UPDATE_MOTION_TYPE, //0x0020, - UPDATE_SHAPE = PHYSICS_UPDATE_SHAPE, //0x0040, + UPDATE_POSITION = 0x0001, + UPDATE_VELOCITY = 0x0002, + UPDATE_GRAVITY = 0x0004, + UPDATE_MASS = 0x0008, + UPDATE_COLLISION_GROUP = 0x0010, + UPDATE_MOTION_TYPE = 0x0020, + UPDATE_SHAPE = 0x0040, //... // add new flags here in the middle //... @@ -303,9 +302,7 @@ public: uint32_t getUpdateFlags() const { return _updateFlags; } void clearUpdateFlags() { _updateFlags = 0; } - EntityMotionState* getMotionState() const { return _motionState; } - virtual EntityMotionState* createMotionState() { return NULL; } - void destroyMotionState(); + void* getPhysicsInfo() const { return _physicsInfo; } SimulationState getSimulationState() const { return _simulationState; } void setSimulationState(SimulationState state) { _simulationState = state; } @@ -352,7 +349,7 @@ protected: void setRadius(float value); AACubeShape _collisionShape; - EntityMotionState* _motionState; + void* _physicsInfo; SimulationState _simulationState; // only set by EntityTree // UpdateFlags are set whenever a property changes that requires the change to be communicated to other diff --git a/libraries/entities/src/EntitySimulation.h b/libraries/entities/src/EntitySimulation.h index 770d6ebdb0..edbae91c0a 100644 --- a/libraries/entities/src/EntitySimulation.h +++ b/libraries/entities/src/EntitySimulation.h @@ -25,7 +25,7 @@ public: virtual void setEntityTree(EntityTree* tree); /// \param[out] entitiesToDelete list of entities removed from simulation and should be deleted. - virtual void update(QSet& entitiesToDelete) = 0; + virtual void updateEntities(QSet& entitiesToDelete) = 0; /// \param entity pointer to EntityItem to add to the simulation /// \sideeffect the EntityItem::_simulationState member may be updated to indicate membership to internal list diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 9f78a350ff..f5e6260270 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -16,7 +16,6 @@ #include "AddEntityOperator.h" #include "DeleteEntityOperator.h" -#include "EntityMotionState.h" #include "MovingEntitiesOperator.h" #include "UpdateEntityOperator.h" @@ -653,7 +652,7 @@ void EntityTree::update() { if (_simulation) { lockForWrite(); QSet entitiesToDelete; - _simulation->update(entitiesToDelete); + _simulation->updateEntities(entitiesToDelete); if (entitiesToDelete.size() > 0) { // translate into list of ID's QSet idsToDelete; diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index f36b648703..0b5dfee1d1 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -16,9 +16,7 @@ #include #include -#include -#include "EntityMotionState.h" #include "EntityTree.h" #include "EntityTreeElement.h" @@ -655,6 +653,7 @@ EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) return foundEntity; } +/* TODO: probably move the cleanupEntities() stuff into EntityTree void EntityTreeElement::cleanupEntities(PhysicsEngine* physicsEngine) { uint16_t numberOfEntities = _entityItems->size(); for (uint16_t i = 0; i < numberOfEntities; i++) { @@ -662,13 +661,14 @@ void EntityTreeElement::cleanupEntities(PhysicsEngine* physicsEngine) { EntityMotionState* motionState = entity->getMotionState(); if (motionState) { assert(physicsEngine); - physicsEngine->removeEntity(static_cast(motionState)); + physicsEngine->removeObject(static_cast(motionState)); entity->destroyMotionState(); } delete entity; } _entityItems->clear(); } +*/ bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) { bool foundEntity = false; diff --git a/libraries/entities/src/EntityTreeElement.h b/libraries/entities/src/EntityTreeElement.h index df6342fd97..102d3b9068 100644 --- a/libraries/entities/src/EntityTreeElement.h +++ b/libraries/entities/src/EntityTreeElement.h @@ -21,7 +21,6 @@ class EntityTree; class EntityTreeElement; -class PhysicsEngine; class EntityTreeUpdateArgs { public: @@ -176,7 +175,8 @@ public: EntityItem* getEntityWithEntityItemID(const EntityItemID& id); - void cleanupEntities(PhysicsEngine* physicsEngine); + // TODO: probably move the cleanupEntities() stuff into EntityTree + //void cleanupEntities(PhysicsEngine* physicsEngine); bool removeEntityWithEntityItemID(const EntityItemID& id); bool removeEntityItem(EntityItem* entity); diff --git a/libraries/entities/src/SimpleEntitySimulation.cpp b/libraries/entities/src/SimpleEntitySimulation.cpp index b3316978a9..f91c80d67b 100644 --- a/libraries/entities/src/SimpleEntitySimulation.cpp +++ b/libraries/entities/src/SimpleEntitySimulation.cpp @@ -16,7 +16,7 @@ #include "MovingEntitiesOperator.h" #include "SimpleEntitySimulation.h" -void SimpleEntitySimulation::update(QSet& entitiesToDelete) { +void SimpleEntitySimulation::updateEntities(QSet& entitiesToDelete) { quint64 now = usecTimestampNow(); updateChangedEntities(now, entitiesToDelete); updateMovingEntities(now, entitiesToDelete); diff --git a/libraries/entities/src/SimpleEntitySimulation.h b/libraries/entities/src/SimpleEntitySimulation.h index 7d0e8f0113..deff531fa4 100644 --- a/libraries/entities/src/SimpleEntitySimulation.h +++ b/libraries/entities/src/SimpleEntitySimulation.h @@ -21,7 +21,7 @@ public: SimpleEntitySimulation() : EntitySimulation() { } virtual ~SimpleEntitySimulation() { setEntityTree(NULL); } - virtual void update(QSet& entitiesToDelete); + virtual void updateEntities(QSet& entitiesToDelete); virtual void addEntity(EntityItem* entity); virtual void removeEntity(EntityItem* entity); diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 9aea2fdea1..cfac2dcfa4 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -5,7 +5,7 @@ setup_hifi_library() include_glm() -link_hifi_libraries(shared networking physics) +link_hifi_libraries(shared networking) # find ZLIB find_package(ZLIB REQUIRED) diff --git a/libraries/physics/CMakeLists.txt b/libraries/physics/CMakeLists.txt index 4799deea3d..15e1ab238c 100644 --- a/libraries/physics/CMakeLists.txt +++ b/libraries/physics/CMakeLists.txt @@ -6,7 +6,8 @@ setup_hifi_library() include_glm() include_bullet() -link_hifi_libraries(shared) +link_hifi_libraries(shared fbx entities) +include_hifi_library_headers(fbx) # call macro to link our dependencies and bubble them up via a property on our target link_shared_dependencies() diff --git a/libraries/physics/src/ContactPoint.h b/libraries/physics/src/ContactPoint.h index dde8aa38e1..c2443f361f 100644 --- a/libraries/physics/src/ContactPoint.h +++ b/libraries/physics/src/ContactPoint.h @@ -15,7 +15,8 @@ #include #include -#include "CollisionInfo.h" +#include + #include "VerletPoint.h" class Shape; diff --git a/libraries/entities/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp similarity index 95% rename from libraries/entities/src/EntityMotionState.cpp rename to libraries/physics/src/EntityMotionState.cpp index b27e372902..c9fbc79169 100644 --- a/libraries/entities/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifdef USE_BULLET_PHYSICS -#include -#endif // USE_BULLET_PHYSICS +#include -#include "EntityItem.h" +#ifdef USE_BULLET_PHYSICS +#include "BulletUtil.h" +#endif // USE_BULLET_PHYSICS #include "EntityMotionState.h" // TODO: store _cachedWorldOffset in a more central location -- VoxelTree and others also need to know about it @@ -67,7 +67,7 @@ void EntityMotionState::getWorldTransform (btTransform &worldTrans) const { // iff the corresponding RigidBody is DYNAMIC and has moved. void EntityMotionState::setWorldTransform (const btTransform &worldTrans) { uint32_t updateFlags = _entity->getUpdateFlags(); - if (! (updateFlags & PHYSICS_UPDATE_POSITION)) { + if (! (updateFlags & EntityItem::UPDATE_POSITION)) { glm::vec3 pos; bulletToGLM(worldTrans.getOrigin(), pos); _entity->setPositionInMeters(pos + _cachedWorldOffset); @@ -77,7 +77,7 @@ void EntityMotionState::setWorldTransform (const btTransform &worldTrans) { _entity->setRotation(rot); } - if (! (updateFlags & PHYSICS_UPDATE_VELOCITY)) { + if (! (updateFlags & EntityItem::UPDATE_VELOCITY)) { glm::vec3 v; getVelocity(v); _entity->setVelocityInMeters(v); diff --git a/libraries/entities/src/EntityMotionState.h b/libraries/physics/src/EntityMotionState.h similarity index 97% rename from libraries/entities/src/EntityMotionState.h rename to libraries/physics/src/EntityMotionState.h index ace42613dd..793633e783 100644 --- a/libraries/entities/src/EntityMotionState.h +++ b/libraries/physics/src/EntityMotionState.h @@ -13,9 +13,11 @@ #define hifi_EntityMotionState_h #include + #ifdef USE_BULLET_PHYSICS -#include +#include "CustomMotionState.h" #else // USE_BULLET_PHYSICS + // CustomMotionState stubbery class CustomMotionState { public: diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 0dfa451b99..b0e62beac4 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -24,10 +24,10 @@ void PhysicsEngine::init() { _constraintSolver = new btSequentialImpulseConstraintSolver; _dynamicsWorld = new btDiscreteDynamicsWorld(_collisionDispatcher, _broadphaseFilter, _constraintSolver, _collisionConfig); - // TODO: once the initial physics system is working we will set gravity of the world to be zero - // and each object will have to specify its own local gravity, or we'll set up gravity zones. - //_dynamicsWorld->setGravity(btVector3(0.0f, 0.0f, 0.0f)); - // + // default gravity of the world is zero, so each object must specify its own gravity + // TODO: set up gravity zones + _dynamicsWorld->setGravity(btVector3(0.0f, 0.0f, 0.0f)); + // GROUND HACK: In the meantime we add a big planar floor to catch falling objects // NOTE: we don't care about memory leaking groundShape and groundObject --> // they'll exist until the executable exits. @@ -123,7 +123,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::addEntity(CustomMotionState* motionState) { +bool PhysicsEngine::addObject(CustomMotionState* motionState) { assert(motionState); ShapeInfo info; motionState->computeShapeInfo(info); @@ -170,7 +170,7 @@ bool PhysicsEngine::addEntity(CustomMotionState* motionState) { return false; } -bool PhysicsEngine::removeEntity(CustomMotionState* motionState) { +bool PhysicsEngine::removeObject(CustomMotionState* motionState) { assert(motionState); btRigidBody* body = motionState->_body; if (body) { @@ -186,7 +186,7 @@ bool PhysicsEngine::removeEntity(CustomMotionState* motionState) { return false; } -bool PhysicsEngine::updateEntity(CustomMotionState* motionState, uint32_t flags) { +bool PhysicsEngine::updateObject(CustomMotionState* motionState, uint32_t flags) { btRigidBody* body = motionState->_body; if (!body) { return false; @@ -194,16 +194,16 @@ bool PhysicsEngine::updateEntity(CustomMotionState* motionState, uint32_t flags) if (flags & PHYSICS_UPDATE_HARD) { // a hard update requires the body be pulled out of physics engine, changed, then reinserted - updateEntityHard(body, motionState, flags); + updateObjectHard(body, motionState, flags); } else if (flags & PHYSICS_UPDATE_EASY) { // an easy update does not require that the body be pulled out of physics engine - updateEntityEasy(body, motionState, flags); + updateObjectEasy(body, motionState, flags); } return true; } // private -void PhysicsEngine::updateEntityHard(btRigidBody* body, CustomMotionState* motionState, uint32_t flags) { +void PhysicsEngine::updateObjectHard(btRigidBody* body, CustomMotionState* motionState, uint32_t flags) { MotionType newType = motionState->getMotionType(); // pull body out of physics engine @@ -227,7 +227,7 @@ void PhysicsEngine::updateEntityHard(btRigidBody* body, CustomMotionState* motio } bool easyUpdate = flags & PHYSICS_UPDATE_EASY; if (easyUpdate) { - updateEntityEasy(body, motionState, flags); + updateObjectEasy(body, motionState, flags); } // update the motion parameters @@ -280,7 +280,7 @@ void PhysicsEngine::updateEntityHard(btRigidBody* body, CustomMotionState* motio } // private -void PhysicsEngine::updateEntityEasy(btRigidBody* body, CustomMotionState* motionState, uint32_t flags) { +void PhysicsEngine::updateObjectEasy(btRigidBody* body, CustomMotionState* 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 b9a44dc579..dfac1b17e8 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -77,22 +77,22 @@ public: /// \return true if Voxel removed bool removeVoxel(const glm::vec3& position, float scale); - /// \param motionState pointer to Entity's MotionState - /// \return true if Entity added - bool addEntity(CustomMotionState* motionState); + /// \param motionState pointer to Object's MotionState + /// \return true if Object added + bool addObject(CustomMotionState* motionState); - /// \param motionState pointer to Entity's MotionState - /// \return true if Entity removed - bool removeEntity(CustomMotionState* motionState); + /// \param motionState pointer to Object's MotionState + /// \return true if Object removed + bool removeObject(CustomMotionState* motionState); - /// \param motionState pointer to Entity's 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 updateEntity(CustomMotionState* motionState, uint32_t flags); + bool updateObject(CustomMotionState* motionState, uint32_t flags); protected: - void updateEntityHard(btRigidBody* body, CustomMotionState* motionState, uint32_t flags); - void updateEntityEasy(btRigidBody* body, CustomMotionState* motionState, uint32_t flags); + void updateObjectHard(btRigidBody* body, CustomMotionState* motionState, uint32_t flags); + void updateObjectEasy(btRigidBody* body, CustomMotionState* motionState, uint32_t flags); btClock _clock; btDefaultCollisionConfiguration* _collisionConfig; diff --git a/libraries/physics/src/PhysicsEntity.h b/libraries/physics/src/PhysicsEntity.h index bf401d9339..92b302debb 100644 --- a/libraries/physics/src/PhysicsEntity.h +++ b/libraries/physics/src/PhysicsEntity.h @@ -18,13 +18,13 @@ #include #include +#include +#include + #ifdef USE_BULLET_PHYSICS #include "PhysicsEngine.h" #endif // USE_BULLET_PHYSICS -#include "CollisionInfo.h" -#include "RayIntersectionInfo.h" - class Shape; class PhysicsSimulation; diff --git a/libraries/physics/src/ShapeInfo.cpp b/libraries/physics/src/ShapeInfo.cpp index cf848793a9..5587a6b528 100644 --- a/libraries/physics/src/ShapeInfo.cpp +++ b/libraries/physics/src/ShapeInfo.cpp @@ -17,6 +17,7 @@ #include // for MILLIMETERS_PER_METER #include "BulletUtil.h" +#include "DoubleHashKey.h" #include "ShapeInfo.h" void ShapeInfo::collectInfo(const btCollisionShape* shape) { diff --git a/libraries/physics/src/ShapeInfo.h b/libraries/physics/src/ShapeInfo.h index 40dedfef1e..1be59c9472 100644 --- a/libraries/physics/src/ShapeInfo.h +++ b/libraries/physics/src/ShapeInfo.h @@ -18,8 +18,6 @@ #include #include -#include "DoubleHashKey.h" - class ShapeInfo { public: ShapeInfo() : _type(INVALID_SHAPE_PROXYTYPE) {} diff --git a/libraries/physics/src/AACubeShape.cpp b/libraries/shared/src/AACubeShape.cpp similarity index 98% rename from libraries/physics/src/AACubeShape.cpp rename to libraries/shared/src/AACubeShape.cpp index 7ec024bf08..d713485c65 100644 --- a/libraries/physics/src/AACubeShape.cpp +++ b/libraries/shared/src/AACubeShape.cpp @@ -13,7 +13,7 @@ #include #include "AACubeShape.h" -#include // for SQUARE_ROOT_OF_3 +#include "SharedUtil.h" // for SQUARE_ROOT_OF_3 glm::vec3 faceNormals[3] = { glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f) }; diff --git a/libraries/physics/src/AACubeShape.h b/libraries/shared/src/AACubeShape.h similarity index 100% rename from libraries/physics/src/AACubeShape.h rename to libraries/shared/src/AACubeShape.h diff --git a/libraries/physics/src/CapsuleShape.cpp b/libraries/shared/src/CapsuleShape.cpp similarity index 99% rename from libraries/physics/src/CapsuleShape.cpp rename to libraries/shared/src/CapsuleShape.cpp index 153f1991d4..242f3160ce 100644 --- a/libraries/physics/src/CapsuleShape.cpp +++ b/libraries/shared/src/CapsuleShape.cpp @@ -12,11 +12,9 @@ #include #include -#include -#include - #include "CapsuleShape.h" - +#include "GeometryUtil.h" +#include "SharedUtil.h" CapsuleShape::CapsuleShape() : Shape(CAPSULE_SHAPE), _radius(0.0f), _halfHeight(0.0f) {} diff --git a/libraries/physics/src/CapsuleShape.h b/libraries/shared/src/CapsuleShape.h similarity index 98% rename from libraries/physics/src/CapsuleShape.h rename to libraries/shared/src/CapsuleShape.h index b79af60582..b91bf9f1ec 100644 --- a/libraries/physics/src/CapsuleShape.h +++ b/libraries/shared/src/CapsuleShape.h @@ -12,9 +12,8 @@ #ifndef hifi_CapsuleShape_h #define hifi_CapsuleShape_h -#include - #include "Shape.h" +#include "SharedUtil.h" // default axis of CapsuleShape is Y-axis const glm::vec3 DEFAULT_CAPSULE_AXIS(0.0f, 1.0f, 0.0f); diff --git a/libraries/physics/src/CollisionInfo.cpp b/libraries/shared/src/CollisionInfo.cpp similarity index 99% rename from libraries/physics/src/CollisionInfo.cpp rename to libraries/shared/src/CollisionInfo.cpp index 9add847980..b168b038f6 100644 --- a/libraries/physics/src/CollisionInfo.cpp +++ b/libraries/shared/src/CollisionInfo.cpp @@ -10,10 +10,10 @@ // -#include #include "CollisionInfo.h" #include "Shape.h" +#include "SharedUtil.h" CollisionInfo::CollisionInfo() : _data(NULL), diff --git a/libraries/physics/src/CollisionInfo.h b/libraries/shared/src/CollisionInfo.h similarity index 100% rename from libraries/physics/src/CollisionInfo.h rename to libraries/shared/src/CollisionInfo.h diff --git a/libraries/physics/src/ListShape.cpp b/libraries/shared/src/ListShape.cpp similarity index 100% rename from libraries/physics/src/ListShape.cpp rename to libraries/shared/src/ListShape.cpp diff --git a/libraries/physics/src/ListShape.h b/libraries/shared/src/ListShape.h similarity index 100% rename from libraries/physics/src/ListShape.h rename to libraries/shared/src/ListShape.h diff --git a/libraries/physics/src/PlaneShape.cpp b/libraries/shared/src/PlaneShape.cpp similarity index 98% rename from libraries/physics/src/PlaneShape.cpp rename to libraries/shared/src/PlaneShape.cpp index 2e71c2f330..012c418580 100644 --- a/libraries/physics/src/PlaneShape.cpp +++ b/libraries/shared/src/PlaneShape.cpp @@ -9,10 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include - +#include "GLMHelpers.h" #include "PlaneShape.h" +#include "SharedUtil.h" const glm::vec3 UNROTATED_NORMAL(0.0f, 1.0f, 0.0f); diff --git a/libraries/physics/src/PlaneShape.h b/libraries/shared/src/PlaneShape.h similarity index 100% rename from libraries/physics/src/PlaneShape.h rename to libraries/shared/src/PlaneShape.h diff --git a/libraries/physics/src/RayIntersectionInfo.h b/libraries/shared/src/RayIntersectionInfo.h similarity index 100% rename from libraries/physics/src/RayIntersectionInfo.h rename to libraries/shared/src/RayIntersectionInfo.h diff --git a/libraries/physics/src/Shape.h b/libraries/shared/src/Shape.h similarity index 100% rename from libraries/physics/src/Shape.h rename to libraries/shared/src/Shape.h diff --git a/libraries/physics/src/ShapeCollider.cpp b/libraries/shared/src/ShapeCollider.cpp similarity index 99% rename from libraries/physics/src/ShapeCollider.cpp rename to libraries/shared/src/ShapeCollider.cpp index a7a4e34518..32d785b46a 100644 --- a/libraries/physics/src/ShapeCollider.cpp +++ b/libraries/shared/src/ShapeCollider.cpp @@ -11,16 +11,14 @@ #include -#include -#include - -#include "ShapeCollider.h" - #include "AACubeShape.h" #include "CapsuleShape.h" +#include "GeometryUtil.h" #include "ListShape.h" #include "PlaneShape.h" +#include "ShapeCollider.h" #include "SphereShape.h" +#include "StreamUtils.h" // NOTE: diff --git a/libraries/physics/src/ShapeCollider.h b/libraries/shared/src/ShapeCollider.h similarity index 99% rename from libraries/physics/src/ShapeCollider.h rename to libraries/shared/src/ShapeCollider.h index f2c0de470d..16023ac6a5 100644 --- a/libraries/physics/src/ShapeCollider.h +++ b/libraries/shared/src/ShapeCollider.h @@ -14,10 +14,10 @@ #include -#include - #include "CollisionInfo.h" #include "RayIntersectionInfo.h" +#include "SharedUtil.h" + class Shape; class SphereShape; diff --git a/libraries/physics/src/SphereShape.cpp b/libraries/shared/src/SphereShape.cpp similarity index 100% rename from libraries/physics/src/SphereShape.cpp rename to libraries/shared/src/SphereShape.cpp diff --git a/libraries/physics/src/SphereShape.h b/libraries/shared/src/SphereShape.h similarity index 98% rename from libraries/physics/src/SphereShape.h rename to libraries/shared/src/SphereShape.h index 9cb83f92e1..c8562a99da 100644 --- a/libraries/physics/src/SphereShape.h +++ b/libraries/shared/src/SphereShape.h @@ -12,9 +12,8 @@ #ifndef hifi_SphereShape_h #define hifi_SphereShape_h -#include - #include "Shape.h" +#include "SharedUtil.h" class SphereShape : public Shape {