From 1ec6ee05f39d93b5efa6ae7f9d3a1b47ce838811 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 1 Aug 2014 15:08:21 -0700 Subject: [PATCH] Rename ContactConstraint to ContactPoint --- .../{ContactConstraint.cpp => ContactPoint.cpp} | 12 ++++++------ .../src/{ContactConstraint.h => ContactPoint.h} | 14 +++++++------- libraries/shared/src/PhysicsSimulation.cpp | 10 +++++----- libraries/shared/src/PhysicsSimulation.h | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) rename libraries/shared/src/{ContactConstraint.cpp => ContactPoint.cpp} (88%) rename libraries/shared/src/{ContactConstraint.h => ContactPoint.h} (78%) diff --git a/libraries/shared/src/ContactConstraint.cpp b/libraries/shared/src/ContactPoint.cpp similarity index 88% rename from libraries/shared/src/ContactConstraint.cpp rename to libraries/shared/src/ContactPoint.cpp index d1d12fa771..1f6dbcdb11 100644 --- a/libraries/shared/src/ContactConstraint.cpp +++ b/libraries/shared/src/ContactPoint.cpp @@ -1,5 +1,5 @@ // -// ContactConstraint.cpp +// ContactPoint.cpp // libraries/shared/src // // Created by Andrew Meadows 2014.07.30 @@ -9,15 +9,15 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ContactConstraint.h" +#include "ContactPoint.h" #include "Shape.h" #include "SharedUtil.h" -ContactConstraint::ContactConstraint() : _lastFrame(0), _shapeA(NULL), _shapeB(NULL), +ContactPoint::ContactPoint() : _lastFrame(0), _shapeA(NULL), _shapeB(NULL), _offsetA(0.0f), _offsetB(0.0f), _normal(0.0f) { } -ContactConstraint::ContactConstraint(const CollisionInfo& collision, quint32 frame) : _lastFrame(frame), +ContactPoint::ContactPoint(const CollisionInfo& collision, quint32 frame) : _lastFrame(frame), _shapeA(collision.getShapeA()), _shapeB(collision.getShapeB()), _offsetA(0.0f), _offsetB(0.0f), _normal(0.0f) { _offsetA = collision._contactPoint - _shapeA->getTranslation(); @@ -40,7 +40,7 @@ ContactConstraint::ContactConstraint(const CollisionInfo& collision, quint32 fra } // virtual -float ContactConstraint::enforce() { +float ContactPoint::enforce() { glm::vec3 pointA = _shapeA->getTranslation() + _offsetA; glm::vec3 pointB = _shapeB->getTranslation() + _offsetB; glm::vec3 penetration = pointA - pointB; @@ -65,7 +65,7 @@ float ContactConstraint::enforce() { return 0.0f; } -void ContactConstraint::updateContact(const CollisionInfo& collision, quint32 frame) { +void ContactPoint::updateContact(const CollisionInfo& collision, quint32 frame) { _lastFrame = frame; _offsetA = collision._contactPoint - collision._shapeA->getTranslation(); _offsetB = collision._contactPoint - collision._penetration - collision._shapeB->getTranslation(); diff --git a/libraries/shared/src/ContactConstraint.h b/libraries/shared/src/ContactPoint.h similarity index 78% rename from libraries/shared/src/ContactConstraint.h rename to libraries/shared/src/ContactPoint.h index 1c8b7d1b57..84e15a85ee 100644 --- a/libraries/shared/src/ContactConstraint.h +++ b/libraries/shared/src/ContactPoint.h @@ -1,5 +1,5 @@ // -// ContactConstraint.h +// ContactPoint.h // libraries/shared/src // // Created by Andrew Meadows 2014.07.30 @@ -9,8 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_ContactConstraint_h -#define hifi_ContactConstraint_h +#ifndef hifi_ContactPoint_h +#define hifi_ContactPoint_h #include #include @@ -19,10 +19,10 @@ class Shape; -class ContactConstraint { +class ContactPoint { public: - ContactConstraint(); - ContactConstraint(const CollisionInfo& collision, quint32 frame); + ContactPoint(); + ContactPoint(const CollisionInfo& collision, quint32 frame); virtual float enforce(); @@ -41,4 +41,4 @@ protected: glm::vec3 _normal; // (points from A toward B) }; -#endif // hifi_ContactConstraint_h +#endif // hifi_ContactPoint_h diff --git a/libraries/shared/src/PhysicsSimulation.cpp b/libraries/shared/src/PhysicsSimulation.cpp index 3e3529be10..8bcbb7255a 100644 --- a/libraries/shared/src/PhysicsSimulation.cpp +++ b/libraries/shared/src/PhysicsSimulation.cpp @@ -88,7 +88,7 @@ void PhysicsSimulation::removeEntity(PhysicsEntity* entity) { } } // remove corresponding contacts - QMap::iterator itr = _contacts.begin(); + QMap::iterator itr = _contacts.begin(); while (itr != _contacts.end()) { if (entity == itr.value().getShapeA()->getEntity() || entity == itr.value().getShapeB()->getEntity()) { itr = _contacts.erase(itr); @@ -251,7 +251,7 @@ void PhysicsSimulation::enforceContacts() { if (key == 0) { continue; } - QMap::iterator itr = _contacts.find(key); + QMap::iterator itr = _contacts.find(key); if (itr != _contacts.end()) { if (itr.value().enforce() > 0.0f) { shapes.insert(collision->getShapeA()); @@ -276,9 +276,9 @@ void PhysicsSimulation::updateContacts() { if (key == 0) { continue; } - QMap::iterator itr = _contacts.find(key); + QMap::iterator itr = _contacts.find(key); if (itr == _contacts.end()) { - _contacts.insert(key, ContactConstraint(*collision, _frame)); + _contacts.insert(key, ContactPoint(*collision, _frame)); } else { itr.value().updateContact(*collision, _frame); } @@ -288,7 +288,7 @@ void PhysicsSimulation::updateContacts() { const quint32 MAX_CONTACT_FRAME_LIFETIME = 2; void PhysicsSimulation::pruneContacts() { - QMap::iterator itr = _contacts.begin(); + QMap::iterator itr = _contacts.begin(); while (itr != _contacts.end()) { if (_frame - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) { itr = _contacts.erase(itr); diff --git a/libraries/shared/src/PhysicsSimulation.h b/libraries/shared/src/PhysicsSimulation.h index 6e69e72219..8cbc39b9d3 100644 --- a/libraries/shared/src/PhysicsSimulation.h +++ b/libraries/shared/src/PhysicsSimulation.h @@ -17,7 +17,7 @@ #include #include "CollisionInfo.h" -#include "ContactConstraint.h" +#include "ContactPoint.h" class PhysicsEntity; class Ragdoll; @@ -59,7 +59,7 @@ private: QVector _dolls; QVector _entities; CollisionList _collisions; - QMap _contacts; + QMap _contacts; }; #endif // hifi_PhysicsSimulation