diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 5ebf72b215..b48e61718c 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -14,7 +14,7 @@ #include -#include +#include #include "Avatar.h" @@ -175,7 +175,7 @@ private: float _oculusYawOffset; QList _animationHandles; - SimulationEngine _simulationEngine; + PhysicsSimulation _simulationEngine; // private methods float computeDistanceToFloor(const glm::vec3& startPoint); diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 89a57c14af..515dcd4f27 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -561,7 +561,7 @@ void Model::setJointStates(QVector states) { _jointStates = states; // compute an approximate bounding radius for broadphase collision queries - // against SimulationEngine boundaries + // against PhysicsSimulation boundaries int numJoints = _jointStates.size(); float radius = 0.0f; for (int i = 0; i < numJoints; ++i) { @@ -785,7 +785,7 @@ AnimationHandlePointer Model::createAnimationHandle() { return handle; } -// virtual override from PhysicalEntity +// virtual override from PhysicsEntity void Model::buildShapes() { // TODO: figure out how to load/build collision shapes for general models } diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index 8851f42eb1..2045a0c9b5 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include @@ -33,7 +33,7 @@ typedef QSharedPointer AnimationHandlePointer; typedef QWeakPointer WeakAnimationHandlePointer; /// A generic 3D model displaying geometry loaded from a URL. -class Model : public QObject, public PhysicalEntity { +class Model : public QObject, public PhysicsEntity { Q_OBJECT public: @@ -131,7 +131,7 @@ public: const QList& getRunningAnimations() const { return _runningAnimations; } - // virtual overrides from PhysicalEntity + // virtual overrides from PhysicsEntity virtual void buildShapes(); virtual void updateShapePositions(); diff --git a/libraries/shared/src/PhysicalEntity.cpp b/libraries/shared/src/PhysicsEntity.cpp similarity index 83% rename from libraries/shared/src/PhysicalEntity.cpp rename to libraries/shared/src/PhysicsEntity.cpp index 87d8e982c6..10c08a3cea 100644 --- a/libraries/shared/src/PhysicalEntity.cpp +++ b/libraries/shared/src/PhysicsEntity.cpp @@ -1,5 +1,5 @@ // -// PhysicalEntity.cpp +// PhysicsEntity.cpp // libraries/shared/src // // Created by Andrew Meadows 2014.06.11 @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "PhysicalEntity.h" +#include "PhysicsEntity.h" #include "Shape.h" #include "ShapeCollider.h" -PhysicalEntity::PhysicalEntity() : +PhysicsEntity::PhysicsEntity() : _translation(0.0f), _rotation(), _boundingRadius(0.0f), @@ -22,26 +22,26 @@ PhysicalEntity::PhysicalEntity() : _simulation(NULL) { } -PhysicalEntity::~PhysicalEntity() { +PhysicsEntity::~PhysicsEntity() { // entity should be removed from the simulation before it is deleted assert(_simulation == NULL); } -void PhysicalEntity::setTranslation(const glm::vec3& translation) { +void PhysicsEntity::setTranslation(const glm::vec3& translation) { if (_translation != translation) { _shapesAreDirty = !_shapes.isEmpty(); _translation = translation; } } -void PhysicalEntity::setRotation(const glm::quat& rotation) { +void PhysicsEntity::setRotation(const glm::quat& rotation) { if (_rotation != rotation) { _shapesAreDirty = !_shapes.isEmpty(); _rotation = rotation; } } -void PhysicalEntity::setShapeBackPointers() { +void PhysicsEntity::setShapeBackPointers() { for (int i = 0; i < _shapes.size(); i++) { Shape* shape = _shapes[i]; if (shape) { @@ -50,7 +50,7 @@ void PhysicalEntity::setShapeBackPointers() { } } -void PhysicalEntity::setEnableShapes(bool enable) { +void PhysicsEntity::setEnableShapes(bool enable) { if (enable != _enableShapes) { clearShapes(); _enableShapes = enable; @@ -60,14 +60,14 @@ void PhysicalEntity::setEnableShapes(bool enable) { } } -void PhysicalEntity::clearShapes() { +void PhysicsEntity::clearShapes() { for (int i = 0; i < _shapes.size(); ++i) { delete _shapes[i]; } _shapes.clear(); } -bool PhysicalEntity::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const { +bool PhysicsEntity::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const { /* TODO: Andrew to make this work int numShapes = _shapes.size(); float minDistance = FLT_MAX; @@ -88,7 +88,7 @@ bool PhysicalEntity::findRayIntersection(const glm::vec3& origin, const glm::vec return false; } -bool PhysicalEntity::findCollisions(const QVector shapes, CollisionList& collisions) { +bool PhysicsEntity::findCollisions(const QVector shapes, CollisionList& collisions) { bool collided = false; int numTheirShapes = shapes.size(); for (int i = 0; i < numTheirShapes; ++i) { @@ -107,7 +107,7 @@ bool PhysicalEntity::findCollisions(const QVector shapes, Collisio return collided; } -bool PhysicalEntity::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadius, +bool PhysicsEntity::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadius, CollisionList& collisions, int skipIndex) { bool collided = false; // TODO: Andrew to implement this or make it unecessary @@ -144,7 +144,7 @@ bool PhysicalEntity::findSphereCollisions(const glm::vec3& sphereCenter, float s return collided; } -bool PhysicalEntity::findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions) { +bool PhysicsEntity::findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions) { bool collided = false; PlaneShape planeShape(plane); for (int i = 0; i < _shapes.size(); i++) { diff --git a/libraries/shared/src/PhysicalEntity.h b/libraries/shared/src/PhysicsEntity.h similarity index 68% rename from libraries/shared/src/PhysicalEntity.h rename to libraries/shared/src/PhysicsEntity.h index 959550dbb2..3e20115729 100644 --- a/libraries/shared/src/PhysicalEntity.h +++ b/libraries/shared/src/PhysicsEntity.h @@ -1,5 +1,5 @@ // -// PhysicalEntity.h +// PhysicsEntity.h // libraries/shared/src // // Created by Andrew Meadows 2014.05.30 @@ -9,8 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_PhysicalEntity_h -#define hifi_PhysicalEntity_h +#ifndef hifi_PhysicsEntity_h +#define hifi_PhysicsEntity_h #include @@ -20,17 +20,17 @@ #include "CollisionInfo.h" class Shape; -class SimulationEngine; +class PhysicsSimulation; -// PhysicalEntity is the base class for anything that owns one or more Shapes that collide in a -// SimulationEngine. Each CollisionInfo generated by a SimulationEngine has back pointers to the -// two Shapes involved, and those Shapes may (optionally) have valid back pointers to their PhysicalEntity. +// PhysicsEntity is the base class for anything that owns one or more Shapes that collide in a +// PhysicsSimulation. Each CollisionInfo generated by a PhysicsSimulation has back pointers to the +// two Shapes involved, and those Shapes may (optionally) have valid back pointers to their PhysicsEntity. -class PhysicalEntity { +class PhysicsEntity { public: - PhysicalEntity(); - virtual ~PhysicalEntity(); + PhysicsEntity(); + virtual ~PhysicsEntity(); void setTranslation(const glm::vec3& translation); void setRotation(const glm::quat& rotation); @@ -46,7 +46,7 @@ public: virtual void buildShapes() = 0; virtual void clearShapes(); - SimulationEngine* getSimulation() const { return _simulation; } + PhysicsSimulation* getSimulation() const { return _simulation; } bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const; bool findCollisions(const QVector shapes, CollisionList& collisions); @@ -54,8 +54,8 @@ public: bool findPlaneCollisions(const glm::vec4& plane, CollisionList& collisions); protected: - // SimulationEngine is a friend so that it can set the protected _simulation backpointer - friend SimulationEngine; + // PhysicsSimulation is a friend so that it can set the protected _simulation backpointer + friend PhysicsSimulation; glm::vec3 _translation; glm::quat _rotation; @@ -63,7 +63,7 @@ protected: bool _shapesAreDirty; bool _enableShapes; QVector _shapes; - SimulationEngine* _simulation; + PhysicsSimulation* _simulation; }; -#endif // hifi_PhysicalEntity_h +#endif // hifi_PhysicsEntity_h diff --git a/libraries/shared/src/SimulationEngine.cpp b/libraries/shared/src/PhysicsSimulation.cpp similarity index 82% rename from libraries/shared/src/SimulationEngine.cpp rename to libraries/shared/src/PhysicsSimulation.cpp index bba33592e9..5fb6fa4a04 100644 --- a/libraries/shared/src/SimulationEngine.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -1,5 +1,5 @@ // -// SimulationEngine.cpp +// PhysicsSimulation.cpp // interface/src/avatar // // Created by Andrew Meadows 2014.06.06 @@ -11,29 +11,29 @@ #include -#include "SimulationEngine.h" +#include "PhysicsSimulation.h" -#include "PhysicalEntity.h" +#include "PhysicsEntity.h" #include "Ragdoll.h" #include "SharedUtil.h" #include "ShapeCollider.h" -int MAX_DOLLS_PER_ENGINE = 16; -int MAX_ENTITIES_PER_ENGINE = 64; -int MAX_COLLISIONS_PER_ENGINE = 256; +int MAX_DOLLS_PER_SIMULATION = 16; +int MAX_ENTITIES_PER_SIMULATION = 64; +int MAX_COLLISIONS_PER_SIMULATION = 256; const int NUM_SHAPE_BITS = 6; const int SHAPE_INDEX_MASK = (1 << (NUM_SHAPE_BITS + 1)) - 1; -SimulationEngine::SimulationEngine() : _collisionList(MAX_COLLISIONS_PER_ENGINE) { +PhysicsSimulation::PhysicsSimulation() : _collisionList(MAX_COLLISIONS_PER_SIMULATION) { } -SimulationEngine::~SimulationEngine() { +PhysicsSimulation::~PhysicsSimulation() { _dolls.clear(); } -bool SimulationEngine::addEntity(PhysicalEntity* entity) { +bool PhysicsSimulation::addEntity(PhysicsEntity* entity) { if (!entity) { return false; } @@ -50,7 +50,7 @@ bool SimulationEngine::addEntity(PhysicalEntity* entity) { return false; } int numEntities = _entities.size(); - if (numEntities > MAX_ENTITIES_PER_ENGINE) { + if (numEntities > MAX_ENTITIES_PER_SIMULATION) { // list is full return false; } @@ -60,7 +60,7 @@ bool SimulationEngine::addEntity(PhysicalEntity* entity) { return true; } -void SimulationEngine::removeEntity(PhysicalEntity* entity) { +void PhysicsSimulation::removeEntity(PhysicsEntity* entity) { if (!entity || !entity->_simulation || !(entity->_simulation == this)) { return; } @@ -72,7 +72,7 @@ void SimulationEngine::removeEntity(PhysicalEntity* entity) { _entities.pop_back(); } else { // swap the last for this one - PhysicalEntity* lastEntity = _entities[numEntities - 1]; + PhysicsEntity* lastEntity = _entities[numEntities - 1]; _entities.pop_back(); _entities[i] = lastEntity; } @@ -82,12 +82,12 @@ void SimulationEngine::removeEntity(PhysicalEntity* entity) { } } -bool SimulationEngine::addRagdoll(Ragdoll* doll) { +bool PhysicsSimulation::addRagdoll(Ragdoll* doll) { if (!doll) { return false; } int numDolls = _dolls.size(); - if (numDolls > MAX_DOLLS_PER_ENGINE) { + if (numDolls > MAX_DOLLS_PER_SIMULATION) { // list is full return false; } @@ -102,7 +102,7 @@ bool SimulationEngine::addRagdoll(Ragdoll* doll) { return true; } -void SimulationEngine::removeRagdoll(Ragdoll* doll) { +void PhysicsSimulation::removeRagdoll(Ragdoll* doll) { int numDolls = _dolls.size(); for (int i = 0; i < numDolls; ++i) { if (doll == _dolls[i]) { @@ -120,7 +120,7 @@ void SimulationEngine::removeRagdoll(Ragdoll* doll) { } } -void SimulationEngine::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) { +void PhysicsSimulation::stepForward(float deltaTime, float minError, int maxIterations, quint64 maxUsec) { /* TODO: Andrew to make this work int iterations = 0; float delta = 0.0f; @@ -143,7 +143,7 @@ void SimulationEngine::stepForward(float deltaTime, float minError, int maxItera // collide _collisionList.clear(); - // TODO: keep track of QSet collidedEntities; + // TODO: keep track of QSet collidedEntities; for (int i = 0; i < numDolls; ++i) { const QVector* shapesA = _dolls.at(i)->getShapes(); if (!shapesA) { @@ -186,10 +186,10 @@ void SimulationEngine::stepForward(float deltaTime, float minError, int maxItera */ } -int SimulationEngine::computeCollisions() { +int PhysicsSimulation::computeCollisions() { return 0.0f; } -void SimulationEngine::processCollisions() { +void PhysicsSimulation::processCollisions() { } diff --git a/libraries/shared/src/SimulationEngine.h b/libraries/shared/src/PhysicsSimulation.h similarity index 80% rename from libraries/shared/src/SimulationEngine.h rename to libraries/shared/src/PhysicsSimulation.h index f064760b6e..b5667db351 100644 --- a/libraries/shared/src/SimulationEngine.h +++ b/libraries/shared/src/PhysicsSimulation.h @@ -1,5 +1,5 @@ // -// SimulationEngine.h +// PhysicsSimulation.h // interface/src/avatar // // Created by Andrew Meadows 2014.06.06 @@ -9,26 +9,26 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_SimulationEngine_h -#define hifi_SimulationEngine_h +#ifndef hifi_PhysicsSimulation +#define hifi_PhysicsSimulation #include #include "CollisionInfo.h" -class PhysicalEntity; +class PhysicsEntity; class Ragdoll; -class SimulationEngine { +class PhysicsSimulation { public: - SimulationEngine(); - ~SimulationEngine(); + PhysicsSimulation(); + ~PhysicsSimulation(); /// \return true if entity was added to or is already in the list - bool addEntity(PhysicalEntity* entity); + bool addEntity(PhysicsEntity* entity); - void removeEntity(PhysicalEntity* entity); + void removeEntity(PhysicsEntity* entity); /// \return true if doll was added to or is already in the list bool addRagdoll(Ragdoll* doll); @@ -52,7 +52,7 @@ public: private: CollisionList _collisionList; - QVector _entities; + QVector _entities; QVector _dolls; // some stats for performance queries @@ -61,4 +61,4 @@ private: quint64 _enforcementTime; }; -#endif // hifi_SimulationEngine_h +#endif // hifi_PhysicsSimulation diff --git a/libraries/shared/src/Shape.h b/libraries/shared/src/Shape.h index 0a03ae18e3..4926f598ba 100644 --- a/libraries/shared/src/Shape.h +++ b/libraries/shared/src/Shape.h @@ -15,7 +15,7 @@ #include #include -class PhysicalEntity; +class PhysicsEntity; class Shape { public: @@ -32,8 +32,8 @@ public: int getType() const { return _type; } - void setEntity(PhysicalEntity* entity) { _owningEntity = entity; } - PhysicalEntity* getEntity() const { return _owningEntity; } + void setEntity(PhysicsEntity* entity) { _owningEntity = entity; } + PhysicsEntity* getEntity() const { return _owningEntity; } float getBoundingRadius() const { return _boundingRadius; } @@ -58,7 +58,7 @@ protected: void setBoundingRadius(float radius) { _boundingRadius = radius; } int _type; - PhysicalEntity* _owningEntity; + PhysicsEntity* _owningEntity; float _boundingRadius; glm::vec3 _translation; glm::quat _rotation;