Fixed: Windows target Subsystem was fixed for demos in CMake to match changes in...
[ode.git] / OPCODE / OPC_LSSCollider.h
blobb4d0893edf9915dd620977e83fa2c9c8824d12e6
1 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 /*
3 * OPCODE - Optimized Collision Detection
4 * Copyright (C) 2001 Pierre Terdiman
5 * Homepage: http://www.codercorner.com/Opcode.htm
6 */
7 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10 /**
11 * Contains code for an LSS collider.
12 * \file OPC_LSSCollider.h
13 * \author Pierre Terdiman
14 * \date December, 28, 2002
16 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19 // Include Guard
20 #ifndef __OPC_LSSCOLLIDER_H__
21 #define __OPC_LSSCOLLIDER_H__
23 struct OPCODE_API LSSCache : VolumeCache
25 LSSCache()
27 Previous.mP0 = Point(0.0f, 0.0f, 0.0f);
28 Previous.mP1 = Point(0.0f, 0.0f, 0.0f);
29 Previous.mRadius = 0.0f;
30 FatCoeff = 1.1f;
33 // Cached faces signature
34 LSS Previous; //!< LSS used when performing the query resulting in cached faces
35 // User settings
36 float FatCoeff; //!< mRadius2 multiplier used to create a fat LSS
39 class OPCODE_API LSSCollider : public VolumeCollider
41 public:
42 // Constructor / Destructor
43 LSSCollider();
44 virtual ~LSSCollider();
46 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
47 /**
48 * Generic collision query for generic OPCODE models. After the call, access the results:
49 * - with GetContactStatus()
50 * - with GetNbTouchedPrimitives()
51 * - with GetTouchedPrimitives()
53 * \param cache [in/out] an lss cache
54 * \param lss [in] collision lss in local space
55 * \param model [in] Opcode model to collide with
56 * \param worldl [in] lss world matrix, or null
57 * \param worldm [in] model's world matrix, or null
58 * \return true if success
59 * \warning SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only.
61 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62 bool Collide(LSSCache& cache, const LSS& lss, const Model& model, const Matrix4x4* worldl=null, const Matrix4x4* worldm=null);
63 //
64 bool Collide(LSSCache& cache, const LSS& lss, const AABBTree* tree);
65 protected:
66 // LSS in model space
67 Segment mSeg; //!< Segment
68 float mRadius2; //!< LSS radius squared
69 // Internal methods
70 void _Collide(const AABBCollisionNode* node);
71 void _Collide(const AABBNoLeafNode* node);
72 void _Collide(const AABBQuantizedNode* node);
73 void _Collide(const AABBQuantizedNoLeafNode* node);
74 void _Collide(const AABBTreeNode* node);
75 void _CollideNoPrimitiveTest(const AABBCollisionNode* node);
76 void _CollideNoPrimitiveTest(const AABBNoLeafNode* node);
77 void _CollideNoPrimitiveTest(const AABBQuantizedNode* node);
78 void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
79 // Overlap tests
80 inline_ BOOL LSSContainsBox(const Point& bc, const Point& be);
81 inline_ BOOL LSSAABBOverlap(const Point& center, const Point& extents);
82 inline_ BOOL LSSTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2);
83 // Init methods
84 BOOL InitQuery(LSSCache& cache, const LSS& lss, const Matrix4x4* worldl=null, const Matrix4x4* worldm=null);
87 class OPCODE_API HybridLSSCollider : public LSSCollider
89 public:
90 // Constructor / Destructor
91 HybridLSSCollider();
92 virtual ~HybridLSSCollider();
94 bool Collide(LSSCache& cache, const LSS& lss, const HybridModel& model, const Matrix4x4* worldl=null, const Matrix4x4* worldm=null);
95 protected:
96 Container mTouchedBoxes;
99 #endif // __OPC_LSSCOLLIDER_H__