Rename ContactConstraint to ContactPoint

This commit is contained in:
Andrew Meadows 2014-08-01 15:08:21 -07:00
parent 374e89817b
commit 1ec6ee05f3
4 changed files with 20 additions and 20 deletions

View file

@ -1,5 +1,5 @@
// //
// ContactConstraint.cpp // ContactPoint.cpp
// libraries/shared/src // libraries/shared/src
// //
// Created by Andrew Meadows 2014.07.30 // 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 // 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 "Shape.h"
#include "SharedUtil.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) { _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) { _shapeA(collision.getShapeA()), _shapeB(collision.getShapeB()), _offsetA(0.0f), _offsetB(0.0f), _normal(0.0f) {
_offsetA = collision._contactPoint - _shapeA->getTranslation(); _offsetA = collision._contactPoint - _shapeA->getTranslation();
@ -40,7 +40,7 @@ ContactConstraint::ContactConstraint(const CollisionInfo& collision, quint32 fra
} }
// virtual // virtual
float ContactConstraint::enforce() { float ContactPoint::enforce() {
glm::vec3 pointA = _shapeA->getTranslation() + _offsetA; glm::vec3 pointA = _shapeA->getTranslation() + _offsetA;
glm::vec3 pointB = _shapeB->getTranslation() + _offsetB; glm::vec3 pointB = _shapeB->getTranslation() + _offsetB;
glm::vec3 penetration = pointA - pointB; glm::vec3 penetration = pointA - pointB;
@ -65,7 +65,7 @@ float ContactConstraint::enforce() {
return 0.0f; return 0.0f;
} }
void ContactConstraint::updateContact(const CollisionInfo& collision, quint32 frame) { void ContactPoint::updateContact(const CollisionInfo& collision, quint32 frame) {
_lastFrame = frame; _lastFrame = frame;
_offsetA = collision._contactPoint - collision._shapeA->getTranslation(); _offsetA = collision._contactPoint - collision._shapeA->getTranslation();
_offsetB = collision._contactPoint - collision._penetration - collision._shapeB->getTranslation(); _offsetB = collision._contactPoint - collision._penetration - collision._shapeB->getTranslation();

View file

@ -1,5 +1,5 @@
// //
// ContactConstraint.h // ContactPoint.h
// libraries/shared/src // libraries/shared/src
// //
// Created by Andrew Meadows 2014.07.30 // 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 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#ifndef hifi_ContactConstraint_h #ifndef hifi_ContactPoint_h
#define hifi_ContactConstraint_h #define hifi_ContactPoint_h
#include <QtGlobal> #include <QtGlobal>
#include <glm/glm.hpp> #include <glm/glm.hpp>
@ -19,10 +19,10 @@
class Shape; class Shape;
class ContactConstraint { class ContactPoint {
public: public:
ContactConstraint(); ContactPoint();
ContactConstraint(const CollisionInfo& collision, quint32 frame); ContactPoint(const CollisionInfo& collision, quint32 frame);
virtual float enforce(); virtual float enforce();
@ -41,4 +41,4 @@ protected:
glm::vec3 _normal; // (points from A toward B) glm::vec3 _normal; // (points from A toward B)
}; };
#endif // hifi_ContactConstraint_h #endif // hifi_ContactPoint_h

View file

@ -88,7 +88,7 @@ void PhysicsSimulation::removeEntity(PhysicsEntity* entity) {
} }
} }
// remove corresponding contacts // remove corresponding contacts
QMap<quint64, ContactConstraint>::iterator itr = _contacts.begin(); QMap<quint64, ContactPoint>::iterator itr = _contacts.begin();
while (itr != _contacts.end()) { while (itr != _contacts.end()) {
if (entity == itr.value().getShapeA()->getEntity() || entity == itr.value().getShapeB()->getEntity()) { if (entity == itr.value().getShapeA()->getEntity() || entity == itr.value().getShapeB()->getEntity()) {
itr = _contacts.erase(itr); itr = _contacts.erase(itr);
@ -251,7 +251,7 @@ void PhysicsSimulation::enforceContacts() {
if (key == 0) { if (key == 0) {
continue; continue;
} }
QMap<quint64, ContactConstraint>::iterator itr = _contacts.find(key); QMap<quint64, ContactPoint>::iterator itr = _contacts.find(key);
if (itr != _contacts.end()) { if (itr != _contacts.end()) {
if (itr.value().enforce() > 0.0f) { if (itr.value().enforce() > 0.0f) {
shapes.insert(collision->getShapeA()); shapes.insert(collision->getShapeA());
@ -276,9 +276,9 @@ void PhysicsSimulation::updateContacts() {
if (key == 0) { if (key == 0) {
continue; continue;
} }
QMap<quint64, ContactConstraint>::iterator itr = _contacts.find(key); QMap<quint64, ContactPoint>::iterator itr = _contacts.find(key);
if (itr == _contacts.end()) { if (itr == _contacts.end()) {
_contacts.insert(key, ContactConstraint(*collision, _frame)); _contacts.insert(key, ContactPoint(*collision, _frame));
} else { } else {
itr.value().updateContact(*collision, _frame); itr.value().updateContact(*collision, _frame);
} }
@ -288,7 +288,7 @@ void PhysicsSimulation::updateContacts() {
const quint32 MAX_CONTACT_FRAME_LIFETIME = 2; const quint32 MAX_CONTACT_FRAME_LIFETIME = 2;
void PhysicsSimulation::pruneContacts() { void PhysicsSimulation::pruneContacts() {
QMap<quint64, ContactConstraint>::iterator itr = _contacts.begin(); QMap<quint64, ContactPoint>::iterator itr = _contacts.begin();
while (itr != _contacts.end()) { while (itr != _contacts.end()) {
if (_frame - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) { if (_frame - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) {
itr = _contacts.erase(itr); itr = _contacts.erase(itr);

View file

@ -17,7 +17,7 @@
#include <QVector> #include <QVector>
#include "CollisionInfo.h" #include "CollisionInfo.h"
#include "ContactConstraint.h" #include "ContactPoint.h"
class PhysicsEntity; class PhysicsEntity;
class Ragdoll; class Ragdoll;
@ -59,7 +59,7 @@ private:
QVector<Ragdoll*> _dolls; QVector<Ragdoll*> _dolls;
QVector<PhysicsEntity*> _entities; QVector<PhysicsEntity*> _entities;
CollisionList _collisions; CollisionList _collisions;
QMap<quint64, ContactConstraint> _contacts; QMap<quint64, ContactPoint> _contacts;
}; };
#endif // hifi_PhysicsSimulation #endif // hifi_PhysicsSimulation