#include <OPC_RayCollider.h>
Contains a ray-vs-tree collider. This class performs a stabbing query on an AABB tree, i.e. does a ray-mesh collision.
HIGHER DISTANCE BOUND:
If P0 and P1 are two 3D points, let's define:
Then we can define a general "ray" as:
struct Ray { Point Origin; Point Direction; };
But it actually maps three different things:
In Opcode, we support segment queries, which yield half-line queries by setting d = +infinity. We don't support line-queries. If you need them, shift the origin along the ray by an appropriate margin.
In short, the lower bound is always 0, and you can setup the higher bound "d" with RayCollider::SetMaxDist().
Query |segment |half-line |line --------|-------------------|---------------|---------------- Usages |-shadow feelers |-raytracing |- |-sweep tests |-in/out tests |
FIRST CONTACT:
TEMPORAL COHERENCE:
CLOSEST HIT:
BACKFACE CULLING:
Definition at line 63 of file OPC_RayCollider.h.
virtual RayCollider::~RayCollider | ( | ) | [virtual] |
void RayCollider::_RayStab | ( | const AABBCollisionNode * | node | ) | [protected] |
void RayCollider::_RayStab | ( | const AABBNoLeafNode * | node | ) | [protected] |
void RayCollider::_RayStab | ( | const AABBQuantizedNode * | node | ) | [protected] |
void RayCollider::_RayStab | ( | const AABBQuantizedNoLeafNode * | node | ) | [protected] |
void RayCollider::_RayStab | ( | const AABBTreeNode * | node, |
Container & | box_indices | ||
) | [protected] |
void RayCollider::_SegmentStab | ( | const AABBCollisionNode * | node | ) | [protected] |
void RayCollider::_SegmentStab | ( | const AABBNoLeafNode * | node | ) | [protected] |
void RayCollider::_SegmentStab | ( | const AABBQuantizedNode * | node | ) | [protected] |
void RayCollider::_SegmentStab | ( | const AABBQuantizedNoLeafNode * | node | ) | [protected] |
void RayCollider::_SegmentStab | ( | const AABBTreeNode * | node, |
Container & | box_indices | ||
) | [protected] |
bool RayCollider::Collide | ( | const Ray & | world_ray, |
const Model & | model, | ||
const Matrix4x4 * | world = null , |
||
udword * | cache = null |
||
) |
Generic stabbing query for generic OPCODE models. After the call, access the results:
world_ray | [in] stabbing ray in world space |
model | [in] Opcode model to collide with |
world | [in] model's world matrix, or null |
cache | [in] a possibly cached face index, or null |
inline_ udword RayCollider::GetNbIntersections | ( | ) | const [inline] |
Stats: gets the number of intersection found after a collision query. Can be used for in/out tests.
Definition at line 168 of file OPC_RayCollider.h.
inline_ udword RayCollider::GetNbRayBVTests | ( | ) | const [inline] |
Stats: gets the number of Ray-BV overlap tests after a collision query.
Definition at line 147 of file OPC_RayCollider.h.
inline_ udword RayCollider::GetNbRayPrimTests | ( | ) | const [inline] |
Stats: gets the number of Ray-Triangle overlap tests after a collision query.
Definition at line 157 of file OPC_RayCollider.h.
BOOL RayCollider::InitQuery | ( | const Ray & | world_ray, |
const Matrix4x4 * | world = null , |
||
udword * | face_id = null |
||
) | [protected] |
RayCollider::override | ( | Collider | ) | const |
Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider.
inline_ BOOL RayCollider::RayAABBOverlap | ( | const Point & | center, |
const Point & | extents | ||
) | [protected] |
Computes a ray-AABB overlap test using the separating axis theorem. Ray is cached within the class.
Definition at line 40 of file OPC_RayAABBOverlap.h.
inline_ BOOL RayCollider::RayTriOverlap | ( | const Point & | vert0, |
const Point & | vert1, | ||
const Point & | vert2 | ||
) | [protected] |
Computes a ray-triangle intersection test. Original code from Tomas Möller's "Fast Minimum Storage Ray-Triangle Intersection". It's been optimized a bit with integer code, and modified to return a non-intersection if distance from ray origin to triangle is negative.
vert0 | [in] triangle vertex |
vert1 | [in] triangle vertex |
vert2 | [in] triangle vertex |
Definition at line 16 of file OPC_RayTriOverlap.h.
inline_ BOOL RayCollider::SegmentAABBOverlap | ( | const Point & | center, |
const Point & | extents | ||
) | [protected] |
Computes a segment-AABB overlap test using the separating axis theorem. Segment is cached within the class.
Definition at line 15 of file OPC_RayAABBOverlap.h.
inline_ void RayCollider::SetClosestHit | ( | bool | flag | ) | [inline] |
Settings: enable or disable "closest hit" mode.
flag | [in] true to report closest hit only |
Definition at line 99 of file OPC_RayCollider.h.
inline_ void RayCollider::SetCulling | ( | bool | flag | ) | [inline] |
Settings: enable or disable backface culling.
flag | [in] true to enable backface culling |
Definition at line 110 of file OPC_RayCollider.h.
inline_ void RayCollider::SetDestination | ( | CollisionFaces * | cf | ) | [inline] |
Settings: sets the destination array for stabbed faces.
cf | [in] destination array, filled during queries |
Definition at line 136 of file OPC_RayCollider.h.
inline_ void RayCollider::SetMaxDist | ( | float | max_dist = MAX_FLOAT | ) | [inline] |
Settings: sets the higher distance bound.
max_dist | [in] higher distance bound. Default = maximal value, for ray queries (else segment) |
Definition at line 121 of file OPC_RayCollider.h.
Point RayCollider::mCenterCoeff [protected] |
Definition at line 198 of file OPC_RayCollider.h.
bool RayCollider::mClosestHit [protected] |
Report closest hit only.
Definition at line 203 of file OPC_RayCollider.h.
bool RayCollider::mCulling [protected] |
Stab culled faces or not.
Definition at line 205 of file OPC_RayCollider.h.
Point RayCollider::mData [protected] |
Definition at line 183 of file OPC_RayCollider.h.
Point RayCollider::mData2 [protected] |
Definition at line 183 of file OPC_RayCollider.h.
Point RayCollider::mDir [protected] |
Ray direction (normalized)
Definition at line 181 of file OPC_RayCollider.h.
Point RayCollider::mExtentsCoeff [protected] |
Definition at line 199 of file OPC_RayCollider.h.
Point RayCollider::mFDir [protected] |
fabsf(mDir)
Definition at line 182 of file OPC_RayCollider.h.
float RayCollider::mMaxDist [protected] |
Valid segment on the ray.
Definition at line 201 of file OPC_RayCollider.h.
udword RayCollider::mNbIntersections [protected] |
Number of valid intersections.
Definition at line 196 of file OPC_RayCollider.h.
udword RayCollider::mNbRayBVTests [protected] |
Number of Ray-BV tests.
Definition at line 193 of file OPC_RayCollider.h.
udword RayCollider::mNbRayPrimTests [protected] |
Number of Ray-Primitive tests.
Definition at line 194 of file OPC_RayCollider.h.
Point RayCollider::mOrigin [protected] |
Ray origin.
Definition at line 180 of file OPC_RayCollider.h.
CollisionFace RayCollider::mStabbedFace [protected] |
Current stabbed face.
Definition at line 185 of file OPC_RayCollider.h.
CollisionFaces* RayCollider::mStabbedFaces [protected] |
List of stabbed faces.
Definition at line 190 of file OPC_RayCollider.h.