2
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
4
* Permission to use, copy, modify, distribute and sell this software
5
* and its documentation for any purpose is hereby granted without fee,
6
* provided that the above copyright notice appear in all copies.
7
* Erwin Coumans makes no representations about the suitability
8
* of this software for any purpose.
9
* It is provided "as is" without express or implied warranty.
12
#include "ManifoldResult.h"
13
#include "NarrowPhaseCollision/PersistentManifold.h"
14
#include "Dynamics/RigidBody.h"
16
ManifoldResult::ManifoldResult(RigidBody* body0,RigidBody* body1,PersistentManifold* manifoldPtr)
17
:m_manifoldPtr(manifoldPtr),
23
void ManifoldResult::AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth)
25
if (depth > m_manifoldPtr->GetManifoldMargin())
28
SimdTransform transAInv = m_body0->getCenterOfMassTransform().inverse();
29
SimdTransform transBInv= m_body1->getCenterOfMassTransform().inverse();
30
SimdVector3 pointA = pointInWorld + normalOnBInWorld * depth;
31
SimdVector3 localA = transAInv(pointA );
32
SimdVector3 localB = transBInv(pointInWorld);
33
ManifoldPoint newPt(localA,localB,normalOnBInWorld,depth);
37
int insertIndex = m_manifoldPtr->GetCacheEntry(newPt);
40
m_manifoldPtr->ReplaceContactPoint(newPt,insertIndex);
43
m_manifoldPtr->AddManifoldPoint(newPt);