My Project
RayCollider.h
1 #pragma once
2 
3 #include "Collider.h"
4 #include "ShapeAABB.h"
5 #include "ShapeRay.h"
6 #include "ShapeOBB.h"
7 
8 namespace ParaEngine
9 {
73  class CRayCollider : public Collider
74  {
75  public:
76  CRayCollider(void);
77  ~CRayCollider(void);
78  public:
91  bool Collide(const CShapeRay& world_ray, const CShapeAABB& world_AABB, const Matrix4* world=NULL);
92  bool Collide(const CShapeRay& world_ray, const CShapeOBB& world_oob);
97  bool Intersect(const CShapeRay& world_ray, const CShapeAABB& world_AABB, float * pDist, const Matrix4* world=NULL);
98  bool Intersect(const CShapeRay& world_ray, const CShapeOBB& world_oob, float * pDist);
106  void SetCulling(bool flag);
107 
114  void SetMaxDist(float max_dist);
115 
116  protected:
117  // Ray in local space
121  Vector3 mData, mData2;
122 
123  // Dequantization coeffs
124  Vector3 mCenterCoeff;
125  Vector3 mExtentsCoeff;
126  // Settings
127  float mMaxDist;
128  bool mCulling;
129 
130  // Overlap tests
131 
138  bool RayAABBOverlap(const Vector3& center, const Vector3& extents);
139 
146  bool SegmentAABBOverlap(const Vector3& center, const Vector3& extents);
147  // TODO:
148  bool RayTriOverlap(const Vector3& vert0, const Vector3& vert1, const Vector3& vert2);
149 
161  bool InitQuery(const CShapeRay& world_ray, const Matrix4* world=NULL);
162  };
163 
164 }
bool Intersect(const CShapeRay &world_ray, const CShapeAABB &world_AABB, float *pDist, const Matrix4 *world=NULL)
Definition: RayCollider.cpp:168
base class for all colliders.
Definition: Collider.h:20
virtual void InitQuery()
Initializes a query.
Definition: Collider.h:107
different physics engine has different winding order.
Definition: EventBinding.h:32
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
bool RayAABBOverlap(const Vector3 &center, const Vector3 &extents)
Computes a ray-AABB overlap test using the separating axis theorem.
Definition: RayCollider.cpp:124
AABB-related code.
Definition: ShapeAABB.h:11
void SetMaxDist(float max_dist)
Settings: sets the higher distance bound.
Definition: RayCollider.cpp:59
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
bool Collide(const CShapeRay &world_ray, const CShapeAABB &world_AABB, const Matrix4 *world=NULL)
Generic stabbing query for generic OPCODE models.
Definition: RayCollider.cpp:138
AABB with orientation by a matrix.
Definition: ShapeOBB.h:11
void SetCulling(bool flag)
Settings: enable or disable back face culling.
Definition: RayCollider.cpp:54
float mMaxDist
Valid segment on the ray.
Definition: RayCollider.h:127
Vector3 mOrigin
Ray origin.
Definition: RayCollider.h:118
Contains a ray-vs-shape collider.
Definition: RayCollider.h:73
A ray is a half-line P(t) = mOrig + mDir * t, with 0 <= t <= +infinity.
Definition: ShapeRay.h:11
Vector3 mFDir
fabsf(mDir)
Definition: RayCollider.h:120
bool SegmentAABBOverlap(const Vector3 &center, const Vector3 &extents)
Computes a segment-AABB overlap test using the separating axis theorem.
Definition: RayCollider.cpp:110
Vector3 mDir
Ray direction (normalized)
Definition: RayCollider.h:119
bool mCulling
Stab culled faces or not.
Definition: RayCollider.h:128