26 Distance(T0, T1, world0, world1, &cache, minD, point0, point1);
35 if (
debug) std::cout <<
"Distance()" << std::endl;
44 n = tree0->GetNodes()+
i;
46 mId0 = n->GetPrimitive();
51 n = tree1->GetNodes()+
i;
53 mId1 = n->GetPrimitive();
61 _Distance(tree0->GetNodes(), tree1->GetNodes(), minD, p0, p1);
86 return Collide(T0, T1, world0, world1, &cache, tolerance);
92 Pair* cache,
double tolerance)
100 if (
_Collide(tree0->GetNodes(), tree1->GetNodes(), tolerance)){
114 t1 = b0->mAABB.mType;
115 t2 = b1->mAABB.mType;
117 return PssPssDist(b0->mAABB.mRadius, b0->mAABB.mCenter,
118 b1->mAABB.mRadius, b1->mAABB.mCenter);
120 return PssLssDist(b0->mAABB.mRadius, b0->mAABB.mCenter,
121 b1->mAABB.mRadius, b1->mAABB.mPoint0, b1->mAABB.mPoint1);
123 return LssPssDist(b0->mAABB.mRadius, b0->mAABB.mPoint0, b0->mAABB.mPoint1,
124 b1->mAABB.mRadius, b1->mAABB.mCenter);
127 sqrtf(b1->
GetSize()), b1->mAABB.mCenter);
129 std::cerr <<
"this ssv combination is not supported" << std::endl;
137 return (center1-c0).Magnitude() - r0 - r1;
169 if (
debug) std::cout <<
"_Distance()" << std::endl;
180 if(b0->IsLeaf() && b1->IsLeaf()) {
182 d =
PrimDist(b0->GetPrimitive(), b1->GetPrimitive(), p0, p1);
187 mId0 = b0->GetPrimitive();
188 mId1 = b1->GetPrimitive();
193 if(b1->IsLeaf() || (!b0->IsLeaf() && (b0->
GetSize() > b1->
GetSize())))
195 _Distance(b0->GetNeg(), b1, minD, point0, point1);
196 _Distance(b0->GetPos(), b1, minD, point0, point1);
200 _Distance(b0, b1->GetNeg(), minD, point0, point1);
201 _Distance(b0, b1->GetPos(), minD, point0, point1);
215 if(d > tolerance)
return false;
217 if(b0->IsLeaf() && b1->IsLeaf()) {
219 d =
PrimDist(b0->GetPrimitive(), b1->GetPrimitive(), p0, p1);
221 mId0 = b0->GetPrimitive();
222 mId1 = b1->GetPrimitive();
229 if(b1->IsLeaf() || (!b0->IsLeaf() && (b0->
GetSize() > b1->
GetSize())))
231 if (
_Collide(b0->GetNeg(), b1, tolerance))
return true;
232 if (
_Collide(b0->GetPos(), b1, tolerance))
return true;
236 if (
_Collide(b0, b1->GetNeg(), tolerance))
return true;
237 if (
_Collide(b0, b1->GetPos(), tolerance))
return true;
bool _Collide(const AABBCollisionNode *b0, const AABBCollisionNode *b1, double tolerance)
inline_ float GetSize() const
virtual inline_ void InitQuery()
inline_ void GetTriangle(VertexPointers &vp, udword index) const
Matrix3x3 mR0to1
Rotation from object0 to object1.
float PssLssDist(float r0, const Point ¢er0, float r1, const Point &point0, const Point &point1)
compute distance between PSS(Point Swept Sphere) and LSS(Line Swept Sphere)
A generic couple structure.
float LssPssDist(float r0, const Point &point0, const Point &point1, float r1, const Point ¢er0)
compute distance between PSS(Point Swept Sphere) and LSS(Line Swept Sphere)
float SegSegDist(const Point &u0, const Point &u, const Point &v0, const Point &v, Point &cp0, Point &cp1)
compute the minimum distance and the closest points between two line segments
float LssLssDist(float r0, const Point &point0, const Point &point1, float r1, const Point &point2, const Point &point3)
compute distance between LSS(Line Swept Sphere)s
const Model * Model1
Model for second object.
udword id1
Second index of the pair.
inline_ const AABBOptimizedTree * GetTree() const
unsigned int udword
sizeof(udword) must be 4
inline_ BOOL Setup(const MeshInterface *mi0, const MeshInterface *mi1)
float PssPssDist(float r0, const Point ¢er0, float r1, const Point ¢er1)
compute distance between PSS(Point Swept Sphere)
inline_ BOOL IsQuantized() const
const MeshInterface * mIMesh1
User-defined mesh interface for object1.
inline_ void TransformPoint4x3(Point &dest, const Point &source, const Matrix4x4 &rot)
Quickly rotates & translates a vector, using the 4x3 part of a 4x4 matrix.
float SsvSsvDist(const AABBCollisionNode *b0, const AABBCollisionNode *b1)
compute distance between SSV(Swept Sphere Volume)s
const AABBCollisionNode * mNowNode0
udword id0
First index of the pair.
float PointSegDist(const Point &P, const Point &u0, const Point &u1)
compute distance between a point and a line segment
float PrimDist(udword id0, udword id1, Point &point0, Point &point1)
compute distance between primitives(triangles)
const Model * Model0
Model for first object.
inline_ udword GetNbNodes() const
const AABBCollisionNode * mNowNode1
bool Distance(BVTCache &cache, float &minD, Point &point0, Point &point1, const Matrix4x4 *world0=null, const Matrix4x4 *world1=null)
compute the minimum distance and the closest points
inline_ void TransformPoint(Point &dest, const Point &source, const Matrix3x3 &rot, const Point &trans)
Quickly rotates & translates a vector.
void _Distance(const AABBCollisionNode *b0, const AABBCollisionNode *b1, float &minD, Point &point0, Point &point1)
float TriTriDist(const Point &U0, const Point &U1, const Point &U2, const Point &V0, const Point &V1, const Point &V2, Point &cp0, Point &cp1)
compute the minimum distance and the closest points between two triangles
Point mT0to1
Translation from object0 to object1.
inline_ BOOL HasLeafNodes() const
bool Collide(BVTCache &cache, double tolerance, const Matrix4x4 *world0=null, const Matrix4x4 *world1=null)
detect collision between links.
inline_ const MeshInterface * GetMeshInterface() const
SSVTreeCollider()
constructor
const MeshInterface * mIMesh0
User-defined mesh interface for object0.