Rename fields and methods in ContactPoint class
This commit is contained in:
parent
ebd715d2e0
commit
4cc024b85e
src
testbed
|
@ -34,8 +34,8 @@ using namespace std;
|
|||
ContactPoint::ContactPoint(const ContactPointInfo* contactInfo)
|
||||
: mNormal(contactInfo->normal),
|
||||
mPenetrationDepth(contactInfo->penetrationDepth),
|
||||
mLocalPointOnBody1(contactInfo->localPoint1),
|
||||
mLocalPointOnBody2(contactInfo->localPoint2),
|
||||
mLocalPointOnShape1(contactInfo->localPoint1),
|
||||
mLocalPointOnShape2(contactInfo->localPoint2),
|
||||
mIsRestingContact(false), mIsObsolete(false), mNext(nullptr), mPrevious(nullptr) {
|
||||
|
||||
assert(mPenetrationDepth > decimal(0.0));
|
||||
|
@ -53,8 +53,8 @@ void ContactPoint::update(const ContactPointInfo* contactInfo) {
|
|||
|
||||
mNormal = contactInfo->normal;
|
||||
mPenetrationDepth = contactInfo->penetrationDepth;
|
||||
mLocalPointOnBody1 = contactInfo->localPoint1;
|
||||
mLocalPointOnBody2 = contactInfo->localPoint2;
|
||||
mLocalPointOnShape1 = contactInfo->localPoint1;
|
||||
mLocalPointOnShape2 = contactInfo->localPoint2;
|
||||
|
||||
mIsObsolete = false;
|
||||
}
|
||||
|
|
|
@ -54,11 +54,11 @@ class ContactPoint {
|
|||
/// Penetration depth
|
||||
decimal mPenetrationDepth;
|
||||
|
||||
/// Contact point on body 1 in local space of body 1
|
||||
Vector3 mLocalPointOnBody1;
|
||||
/// Contact point on proxy shape 1 in local-space of proxy shape 1
|
||||
Vector3 mLocalPointOnShape1;
|
||||
|
||||
/// Contact point on body 2 in local space of body 2
|
||||
Vector3 mLocalPointOnBody2;
|
||||
/// Contact point on proxy shape 2 in local-space of proxy shape 2
|
||||
Vector3 mLocalPointOnShape2;
|
||||
|
||||
/// True if the contact is a resting contact (exists for more than one time step)
|
||||
bool mIsRestingContact;
|
||||
|
@ -121,11 +121,11 @@ class ContactPoint {
|
|||
/// Return the normal vector of the contact
|
||||
Vector3 getNormal() const;
|
||||
|
||||
/// Return the contact local point on body 1
|
||||
Vector3 getLocalPointOnBody1() const;
|
||||
/// Return the contact point on the first proxy shape in the local-space of the proxy shape
|
||||
Vector3 getLocalPointOnShape1() const;
|
||||
|
||||
/// Return the contact local point on body 2
|
||||
Vector3 getLocalPointOnBody2() const;
|
||||
/// Return the contact point on the second proxy shape in the local-space of the proxy shape
|
||||
Vector3 getLocalPointOnShape2() const;
|
||||
|
||||
/// Return the cached penetration impulse
|
||||
decimal getPenetrationImpulse() const;
|
||||
|
@ -156,14 +156,14 @@ inline Vector3 ContactPoint::getNormal() const {
|
|||
return mNormal;
|
||||
}
|
||||
|
||||
// Return the contact point on body 1
|
||||
inline Vector3 ContactPoint::getLocalPointOnBody1() const {
|
||||
return mLocalPointOnBody1;
|
||||
// Return the contact point on the first proxy shape in the local-space of the proxy shape
|
||||
inline Vector3 ContactPoint::getLocalPointOnShape1() const {
|
||||
return mLocalPointOnShape1;
|
||||
}
|
||||
|
||||
// Return the contact point on body 2
|
||||
inline Vector3 ContactPoint::getLocalPointOnBody2() const {
|
||||
return mLocalPointOnBody2;
|
||||
// Return the contact point on the second proxy shape in the local-space of the proxy shape
|
||||
inline Vector3 ContactPoint::getLocalPointOnShape2() const {
|
||||
return mLocalPointOnShape2;
|
||||
}
|
||||
|
||||
// Return the cached penetration impulse
|
||||
|
@ -173,7 +173,7 @@ inline decimal ContactPoint::getPenetrationImpulse() const {
|
|||
|
||||
// Return true if the contact point is similar (close enougth) to another given contact point
|
||||
inline bool ContactPoint::isSimilarWithContactPoint(const ContactPointInfo* localContactPointBody1) const {
|
||||
return (localContactPointBody1->localPoint1 - mLocalPointOnBody1).lengthSquare() <= (PERSISTENT_CONTACT_DIST_THRESHOLD *
|
||||
return (localContactPointBody1->localPoint1 - mLocalPointOnShape1).lengthSquare() <= (PERSISTENT_CONTACT_DIST_THRESHOLD *
|
||||
PERSISTENT_CONTACT_DIST_THRESHOLD);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,8 +157,8 @@ void ContactSolver::initializeForIsland(Island* island) {
|
|||
while (externalContact != nullptr) {
|
||||
|
||||
// Get the contact point on the two bodies
|
||||
Vector3 p1 = shape1->getLocalToWorldTransform() * externalContact->getLocalPointOnBody1();
|
||||
Vector3 p2 = shape2->getLocalToWorldTransform() * externalContact->getLocalPointOnBody2();
|
||||
Vector3 p1 = shape1->getLocalToWorldTransform() * externalContact->getLocalPointOnShape1();
|
||||
Vector3 p2 = shape2->getLocalToWorldTransform() * externalContact->getLocalPointOnShape2();
|
||||
|
||||
new (mContactPoints + mNbContactPoints) ContactPointSolver();
|
||||
mContactPoints[mNbContactPoints].externalContact = externalContact;
|
||||
|
|
|
@ -94,13 +94,13 @@ class ContactManager : public rp3d::CollisionCallback {
|
|||
rp3d::Vector3 normal = contactPoint->getNormal();
|
||||
openglframework::Vector3 contactNormal(normal.x, normal.y, normal.z);
|
||||
|
||||
rp3d::Vector3 point1 = contactPoint->getLocalPointOnBody1();
|
||||
rp3d::Vector3 point1 = contactPoint->getLocalPointOnShape1();
|
||||
point1 = collisionCallbackInfo.proxyShape1->getLocalToWorldTransform() * point1;
|
||||
|
||||
openglframework::Vector3 position1(point1.x, point1.y, point1.z);
|
||||
mContactPoints.push_back(ContactPoint(position1, contactNormal, openglframework::Color::red()));
|
||||
|
||||
rp3d::Vector3 point2 = contactPoint->getLocalPointOnBody2();
|
||||
rp3d::Vector3 point2 = contactPoint->getLocalPointOnShape2();
|
||||
point2 = collisionCallbackInfo.proxyShape2->getLocalToWorldTransform() * point2;
|
||||
openglframework::Vector3 position2(point2.x, point2.y, point2.z);
|
||||
mContactPoints.push_back(ContactPoint(position2, contactNormal, openglframework::Color::blue()));
|
||||
|
|
|
@ -435,7 +435,7 @@ std::vector<ContactPoint> SceneDemo::computeContactPointsOfWorld(const rp3d::Dyn
|
|||
rp3d::ContactPoint* contactPoint = manifold->getContactPoints();
|
||||
while (contactPoint != nullptr) {
|
||||
|
||||
rp3d::Vector3 point = manifold->getShape1()->getLocalToWorldTransform() * contactPoint->getLocalPointOnBody1();
|
||||
rp3d::Vector3 point = manifold->getShape1()->getLocalToWorldTransform() * contactPoint->getLocalPointOnShape1();
|
||||
rp3d::Vector3 normalWorld = contactPoint->getNormal();
|
||||
openglframework::Vector3 normal = openglframework::Vector3(normalWorld.x, normalWorld.y, normalWorld.z);
|
||||
ContactPoint contact(openglframework::Vector3(point.x, point.y, point.z), normal, openglframework::Color::red());
|
||||
|
|
Loading…
Reference in New Issue
Block a user