ScummVM API documentation
dgCollisionConvex.h
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #if !defined(AFX_DGCONVEXCOLLISION_H__57E159CE_6B6F_42DE_891C_1F6C38EB9D29__INCLUDED_)
23 #define AFX_DGCONVEXCOLLISION_H__57E159CE_6B6F_42DE_891C_1F6C38EB9D29__INCLUDED_
24 
25 
26 #include "dgCollision.h"
27 
28 
30 public:
31  dgInt32 m_vertex;
32  dgConvexSimplexEdge *m_twin;
33  dgConvexSimplexEdge *m_next;
34  dgConvexSimplexEdge *m_prev;
35 };
36 
37 
38 DG_MSC_VECTOR_ALIGMENT
40  bool RayHitBox(const dgVector &localP0, const dgVector &localP1) const;
41  dgInt32 RayCastClosestFace(dgVector *tetrahedrum, const dgVector &origin, dgFloat32 &pointDist) const;
42 
43 
44 public:
45  virtual void CalcAABB(const dgMatrix &matrix, dgVector &p0, dgVector &p1) const;
46  virtual void CalcAABBSimd(const dgMatrix &matrix, dgVector &p0, dgVector &p1) const;
47  virtual bool OOBBTest(const dgMatrix &matrix, const dgCollisionConvex *const shape, void *const cacheOrder) const;
48 
49  virtual dgFloat32 RayCast(const dgVector &localP0, const dgVector &localP1, dgContactPoint &contactOut, OnRayPrecastAction preFilter, const dgBody *const body, void *const userData) const;
50  virtual dgFloat32 RayCastSimd(const dgVector &localP0, const dgVector &localP1, dgContactPoint &contactOut, OnRayPrecastAction preFilter, const dgBody *const body, void *const userData) const;
51  virtual dgVector SupportVertex(const dgVector &dir) const;
52  virtual dgVector SupportVertexSimd(const dgVector &dir) const;
53 
54  virtual dgInt32 CalculatePlaneIntersection(const dgVector &normal, const dgVector &point, dgVector *const contactsOut) const;
55  virtual dgInt32 CalculatePlaneIntersectionSimd(const dgVector &normal, const dgVector &point, dgVector *const contactsOut) const;
56  dgInt32 GetVertexCount() const {
57  return m_vertexCount;
58  }
59  virtual bool IsTriggerVolume() const;
60 
61 private:
62  dgInt32 SimplifyClipPolygon(dgInt32 count, const dgVector &normal, dgVector *const polygon) const;
63 
64  virtual dgVector CalculateVolumeIntegral(const dgMatrix &globalMatrix, GetBuoyancyPlane bouyancyPlane, void *const context) const;
65  static void CalculateInertia(void *userData, int vertexCount, const dgFloat32 *FaceArray, int faceId);
66  virtual void CalculateInertia(dgVector &inertia, dgVector &origin) const;
67 
68  virtual dgFloat32 GetVolume() const;
69 
70  virtual dgFloat32 GetBoxMinRadius() const;
71  virtual dgFloat32 GetBoxMaxRadius() const;
72 
73 
74 protected:
75  virtual void *GetUserData() const;
76  virtual void SetUserData(void *const userData);
77 
78  dgCollisionConvex(dgMemoryAllocator *const allocator, dgUnsigned32 signature, const dgMatrix &matrix, dgCollisionID id);
79  dgCollisionConvex(dgWorld *const world, dgDeserialize deserialization, void *const userData);
81 
82 
83  virtual void SetAsTriggerVolume(bool mode);
84  virtual void SerializeLow(dgSerialize callback, void *const userData) const;
85 
86  dgVector CalculateVolumeIntegral(const dgPlane &plane) const;
87  dgFloat32 GetDiscretedAngleStep(dgFloat32 radius) const;
88  dgConvexSimplexEdge *GetSupportEdge(const dgVector &dir) const;
89 
90  void SetVolumeAndCG();
91  bool SanityCheck(dgPolyhedra &hull) const;
92  virtual void DebugCollision(const dgMatrix &matrix, OnDebugCollisionMeshCallback callback, void *const userData) const;
93  virtual dgFloat32 CalculateMassProperties(dgVector &inertia, dgVector &crossInertia, dgVector &centerOfMass) const;
94 
95  bool SanityCheck(dgInt32 count, const dgVector &normal, dgVector *const contactsOut) const;
96  dgInt32 RectifyConvexSlice(dgInt32 count, const dgVector &normal, dgVector *const contactsOut) const;
97 
98 
99  dgVector m_volume;
100  dgVector m_boxSize;
101  dgVector m_boxOrigin;
102  dgVector m_size_x;
103  dgVector m_size_y;
104  dgVector m_size_z;
105  dgConvexSimplexEdge *m_supportVertexStarCuadrant[8];
106 
107  void *m_userData;
108  dgVector *m_vertex;
109  dgConvexSimplexEdge *m_simplex;
110 
111  dgFloat32 m_boxMinRadius;
112  dgFloat32 m_boxMaxRadius;
113  dgFloat32 m_simplexVolume;
114  dgUnsigned16 m_edgeCount;
115  dgUnsigned16 m_vertexCount;
116  dgUnsigned32 m_isTriggerVolume : 1;
117 
118  static dgVector m_multiResDir[8];
119  static dgVector m_multiResDir_sse[6];
120 
121  static dgTriplex m_hullDirs[14];
122 
123  static dgInt32 m_iniliazised;
124  static dgInt32 m_rayCastSimplex[4][4];
125 
126  friend class dgWorld;
127  friend class dgMinkowskiConv;
128  friend class dgCollisionCompound;
129  friend class dgBroadPhaseCollision;
130  friend class dgCollisionConvexModifier;
131 } DG_GCC_VECTOR_ALIGMENT;
132 
133 
134 
135 #endif //AFX_DGCONVEXCOLLISION_H__57E159CE_6B6F_42DE_891C_1F6C38EB9D29__INCLUDED_
136 
137 
Definition: dgPlane.h:29
Definition: dgBroadPhaseCollision.h:170
Definition: dgBody.h:85
Definition: dgCollisionConvex.h:29
Definition: dgVector.h:86
Definition: dgContact.h:88
Definition: dgPolyhedra.h:76
Definition: dgCollisionConvex.h:39
Definition: dgCollisionConvexModifier.h:32
Definition: dgCollision.h:178
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgWorld.h:118
Definition: dgTypes.h:70
Definition: dgCollisionCompound.h:31