mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
Rename ContactConstraint to ContactPoint
This commit is contained in:
parent
374e89817b
commit
1ec6ee05f3
4 changed files with 20 additions and 20 deletions
|
@ -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();
|
|
@ -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 <QtGlobal>
|
||||
#include <glm/glm.hpp>
|
||||
|
@ -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
|
|
@ -88,7 +88,7 @@ void PhysicsSimulation::removeEntity(PhysicsEntity* entity) {
|
|||
}
|
||||
}
|
||||
// remove corresponding contacts
|
||||
QMap<quint64, ContactConstraint>::iterator itr = _contacts.begin();
|
||||
QMap<quint64, ContactPoint>::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<quint64, ContactConstraint>::iterator itr = _contacts.find(key);
|
||||
QMap<quint64, ContactPoint>::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<quint64, ContactConstraint>::iterator itr = _contacts.find(key);
|
||||
QMap<quint64, ContactPoint>::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<quint64, ContactConstraint>::iterator itr = _contacts.begin();
|
||||
QMap<quint64, ContactPoint>::iterator itr = _contacts.begin();
|
||||
while (itr != _contacts.end()) {
|
||||
if (_frame - itr.value().getLastFrame() > MAX_CONTACT_FRAME_LIFETIME) {
|
||||
itr = _contacts.erase(itr);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <QVector>
|
||||
|
||||
#include "CollisionInfo.h"
|
||||
#include "ContactConstraint.h"
|
||||
#include "ContactPoint.h"
|
||||
|
||||
class PhysicsEntity;
|
||||
class Ragdoll;
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
QVector<Ragdoll*> _dolls;
|
||||
QVector<PhysicsEntity*> _entities;
|
||||
CollisionList _collisions;
|
||||
QMap<quint64, ContactConstraint> _contacts;
|
||||
QMap<quint64, ContactPoint> _contacts;
|
||||
};
|
||||
|
||||
#endif // hifi_PhysicsSimulation
|
||||
|
|
Loading…
Reference in a new issue