Go to the documentation of this file.
122 #define SET_CONTACT(prim_index, flag) \
123 mNbIntersections++; \
127 mStabbedFace.mFaceID = prim_index;
129 #ifdef OPC_RAYHIT_CALLBACK
131 #define HANDLE_CONTACT(prim_index, flag) \
132 SET_CONTACT(prim_index, flag) \
134 if(mHitCallback) (mHitCallback)(mStabbedFace, mUserData);
136 #define UPDATE_CACHE \
137 if(cache && GetContactStatus()) \
139 *cache = mStabbedFace.mFaceID; \
143 #define HANDLE_CONTACT(prim_index, flag) \
144 SET_CONTACT(prim_index, flag) \
150 if(!mClosestHit || !mStabbedFaces->GetNbFaces()) \
152 mStabbedFaces->AddFace(mStabbedFace); \
157 CollisionFace* Current = const_cast<CollisionFace*>(mStabbedFaces->GetFaces()); \
158 if(Current && mStabbedFace.mDistance<Current->mDistance) \
160 *Current = mStabbedFace; \
165 #define UPDATE_CACHE \
166 if(cache && GetContactStatus() && mStabbedFaces) \
168 const CollisionFace* Current = mStabbedFaces->GetFaces(); \
169 if(Current) *cache = Current->mFaceID; \
170 else *cache = INVALID_ID; \
174 #define SEGMENT_PRIM(prim_index, flag) \
176 VertexPointers VP; mIMesh->GetTriangle(VP, prim_index); \
179 if(RayTriOverlap(*VP.Vertex[0], *VP.Vertex[1], *VP.Vertex[2])) \
183 if(IR(mStabbedFace.mDistance)<IR(mMaxDist)) \
185 HANDLE_CONTACT(prim_index, flag) \
189 #define RAY_PRIM(prim_index, flag) \
191 VertexPointers VP; mIMesh->GetTriangle(VP, prim_index); \
194 if(RayTriOverlap(*VP.Vertex[0], *VP.Vertex[1], *VP.Vertex[2])) \
196 HANDLE_CONTACT(prim_index, flag) \
210 mStabbedFaces (
null),
214 mNbIntersections (0),
240 if(
mMaxDist<0.0
f)
return "Higher distance bound must be positive!";
242 #ifndef OPC_RAYHIT_CALLBACK
246 if(
SkipPrimitiveTests())
return "SkipPrimitiveTests not possible for RayCollider ! (not implemented)";
267 if(!
Setup(&model))
return false;
270 if(
InitQuery(world_ray, world, cache))
return true;
346 #ifndef OPC_RAYHIT_CALLBACK
387 #ifndef OPC_RAYHIT_CALLBACK
408 #ifndef OPC_RAYHIT_CALLBACK
475 if(!tree)
return false;
555 if(node->HasPosLeaf())
563 if(node->HasNegLeaf())
586 if(node->HasPosLeaf())
594 if(node->HasNegLeaf())
611 Point Center, Extents;
612 node->GetAABB()->GetCenter(Center);
613 node->GetAABB()->GetExtents(Extents);
636 if(!
RayAABBOverlap(node->mAABB.mCenter, node->mAABB.mExtents))
return;
691 if(!
RayAABBOverlap(node->mAABB.mCenter, node->mAABB.mExtents))
return;
693 if(node->HasPosLeaf())
701 if(node->HasNegLeaf())
724 if(node->HasPosLeaf())
732 if(node->HasNegLeaf())
749 Point Center, Extents;
750 node->GetAABB()->GetCenter(Center);
751 node->GetAABB()->GetExtents(Extents);
761 _RayStab(node->GetPos(), box_indices);
762 _RayStab(node->GetNeg(), box_indices);
udword mNbRayBVTests
Number of Ray-BV tests.
CollisionFace mStabbedFace
Current stabbed face.
inline_ BOOL IsQuantized() const
inline_ BOOL FirstContactEnabled() const
const inline_ udword * GetPrimitives() const
inline_ void GetTriangle(VertexPointers &vp, udword index) const
inline_ BOOL TemporalCoherenceEnabled() const
Point mDir
Ray direction (normalized)
udword mNbRayPrimTests
Number of Ray-Primitive tests.
@ OPC_CONTACT
Final contact status after a collision query.
virtual inline_ void InitQuery()
inline_ BOOL ContactFound() const
inline_ BOOL RayAABBOverlap(const Point ¢er, const Point &extents)
unsigned int udword
sizeof(udword) must be 4
inline_ BOOL HasLeafNodes() const
int BOOL
Another boolean type.
#define IEEE_MAX_FLOAT
integer representation of MAX_FLOAT
inline_ udword GetNbPrimitives() const
inline_ BOOL RayTriOverlap(const Point &vert0, const Point &vert1, const Point &vert2)
uword mExtents[3]
Quantized extents.
#define OPC_RAYHIT_CALLBACK
Use a callback in the ray collider.
virtual const char * ValidateSettings()=0
udword mFaceID
Index of touched face.
const BaseModel * mCurrentModel
Current model for collision query (owner of touched faces)
float mDistance
Distance from collider to hitpoint.
ICEMATHS_API void InvertPRMatrix(Matrix4x4 &dest, const Matrix4x4 &src)
inline_ BOOL SkipPrimitiveTests() const
#define IR(x)
Integer representation of a floating-point value.
#define SEGMENT_PRIM(prim_index, flag)
Point mDir
Normalized direction.
float mMaxDist
Valid segment on the ray.
inline_ BOOL HasSingleNode() const
udword mNbIntersections
Number of valid intersections.
bool mClosestHit
Report closest hit only.
const inline_ AABBOptimizedTree * GetTree() const
inline_ BOOL Setup(const BaseModel *model)
#define INVALID_ID
Invalid dword ID (counterpart of null pointers)
bool Collide(const Ray &world_ray, const Model &model, const Matrix4x4 *world=null, udword *cache=null)
inline_ BOOL GetContactStatus() const
#define MAX_FLOAT
max possible float value
#define RAY_PRIM(prim_index, flag)
const MeshInterface * mIMesh
User-defined mesh interface.
CollisionFaces * mStabbedFaces
List of stabbed faces.
void _SegmentStab(const AABBCollisionNode *node)
inline_ void AddFace(const CollisionFace &face)
sword mCenter[3]
Quantized center.
void _RayStab(const AABBCollisionNode *node)
inline_ BOOL SegmentAABBOverlap(const Point ¢er, const Point &extents)
#define null
our own NULL pointer
openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04