added initial support for per-triangle material properties in a non-convex mesh. needs testing.
This commit is contained in:
@@ -34,6 +34,9 @@ struct DiscreteCollisionDetectorInterface
|
||||
void operator delete(void* ptr) {};
|
||||
|
||||
virtual ~Result(){}
|
||||
|
||||
///SetShapeIdentifiers provides experimental support for per-triangle material / custom material combiner
|
||||
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1)=0;
|
||||
virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth)=0;
|
||||
};
|
||||
|
||||
|
||||
@@ -35,7 +35,11 @@ m_penetrationDepthSolver(penetrationDepthSolver),
|
||||
m_simplexSolver(simplexSolver),
|
||||
m_minkowskiA(objectA),
|
||||
m_minkowskiB(objectB),
|
||||
m_ignoreMargin(false)
|
||||
m_ignoreMargin(false),
|
||||
m_partId0(-1),
|
||||
m_index0(-1),
|
||||
m_partId1(-1),
|
||||
m_index1(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -207,6 +211,8 @@ int curIter = 0;
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
output.SetShapeIdentifiers(m_partId0,m_index0,m_partId1,m_index1);
|
||||
|
||||
output.AddContactPoint(
|
||||
normalInB,
|
||||
pointOnB,
|
||||
|
||||
@@ -39,9 +39,17 @@ class GjkPairDetector : public DiscreteCollisionDetectorInterface
|
||||
ConvexShape* m_minkowskiA;
|
||||
ConvexShape* m_minkowskiB;
|
||||
bool m_ignoreMargin;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//experimental feature information, per triangle, per convex etc.
|
||||
//'material combiner' / contact added callback
|
||||
int m_partId0;
|
||||
int m_index0;
|
||||
int m_partId1;
|
||||
int m_index1;
|
||||
|
||||
GjkPairDetector(ConvexShape* objectA,ConvexShape* objectB,SimplexSolverInterface* simplexSolver,ConvexPenetrationDepthSolver* penetrationDepthSolver);
|
||||
virtual ~GjkPairDetector() {};
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ class ManifoldPoint
|
||||
m_localPointB( pointB ),
|
||||
m_normalWorldOnB( normal ),
|
||||
m_distance1( distance ),
|
||||
m_combinedFriction(0.f),
|
||||
m_combinedRestitution(0.f),
|
||||
m_userPersistentData(0),
|
||||
m_lifeTime(0)
|
||||
{
|
||||
@@ -57,6 +59,8 @@ class ManifoldPoint
|
||||
SimdVector3 m_normalWorldOnB;
|
||||
|
||||
float m_distance1;
|
||||
float m_combinedFriction;
|
||||
float m_combinedRestitution;
|
||||
|
||||
|
||||
void* m_userPersistentData;
|
||||
|
||||
@@ -32,6 +32,9 @@ struct MyResult : public DiscreteCollisionDetectorInterface::Result
|
||||
float m_depth;
|
||||
bool m_hasResult;
|
||||
|
||||
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
{
|
||||
}
|
||||
void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth)
|
||||
{
|
||||
m_normalOnBInWorld = normalOnBInWorld;
|
||||
|
||||
@@ -19,7 +19,8 @@ subject to the following restrictions:
|
||||
#include <assert.h>
|
||||
|
||||
float gContactBreakingTreshold = 0.02f;
|
||||
ContactDestroyedCallback gContactCallback = 0;
|
||||
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
||||
|
||||
|
||||
|
||||
PersistentManifold::PersistentManifold()
|
||||
@@ -75,9 +76,9 @@ void PersistentManifold::ClearUserCache(ManifoldPoint& pt)
|
||||
assert(occurance<=0);
|
||||
#endif //DEBUG_PERSISTENCY
|
||||
|
||||
if (pt.m_userPersistentData && gContactCallback)
|
||||
if (pt.m_userPersistentData && gContactDestroyedCallback)
|
||||
{
|
||||
(*gContactCallback)(pt.m_userPersistentData);
|
||||
(*gContactDestroyedCallback)(pt.m_userPersistentData);
|
||||
pt.m_userPersistentData = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ struct CollisionResult;
|
||||
extern float gContactBreakingTreshold;
|
||||
|
||||
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
||||
extern ContactDestroyedCallback gContactDestroyedCallback;
|
||||
|
||||
extern ContactDestroyedCallback gContactCallback;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ struct PointCollector : public DiscreteCollisionDetectorInterface::Result
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||
{
|
||||
//??
|
||||
}
|
||||
|
||||
virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth)
|
||||
{
|
||||
if (depth< m_distance)
|
||||
|
||||
Reference in New Issue
Block a user