ScummVM API documentation
dgCollisionSphere.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_DGCOLLISIONSPHERE_H__4969D514_69A9_4D96_82B2_E5B0EA3D413F__INCLUDED_)
23 #define AFX_DGCOLLISIONSPHERE_H__4969D514_69A9_4D96_82B2_E5B0EA3D413F__INCLUDED_
24 
25 
26 #include "dgCollisionConvex.h"
27 
28 #define DG_SPHERE_VERTEX_COUNT 18
29 
31 public:
32  dgCollisionSphere(dgMemoryAllocator *allocator, dgUnsigned32 signature, dgFloat32 radius, const dgMatrix &offsetMatrix);
33  dgCollisionSphere(dgWorld *const world, dgDeserialize deserialization, void *const userData);
34  virtual ~dgCollisionSphere();
35 
36 
37 protected:
38  void Init(dgFloat32 radius, dgMemoryAllocator *allocator);
39  virtual dgVector SupportVertex(const dgVector &dir) const;
40  virtual dgVector SupportVertexSimd(const dgVector &dir) const;
41 
42  virtual void CalcAABB(const dgMatrix &matrix, dgVector &p0, dgVector &p1) const;
43 // virtual void DebugCollision (const dgBody& myBody, DebugCollisionMeshCallback callback) const;
44  virtual void DebugCollision(const dgMatrix &matrix, OnDebugCollisionMeshCallback callback, void *const userData) const;
45  virtual dgFloat32 RayCast(const dgVector &localP0, const dgVector &localP1, dgContactPoint &contactOut, OnRayPrecastAction preFilter, const dgBody *const body, void *const userData) const;
46  virtual dgFloat32 RayCastSimd(const dgVector &localP0, const dgVector &localP1, dgContactPoint &contactOut, OnRayPrecastAction preFilter, const dgBody *const body, void *const userData) const;
47 
48  void TesselateTriangle(dgInt32 level, const dgVector &p0, const dgVector &p1, const dgVector &p2, dgInt32 &count, dgVector *ouput) const;
49 
50 // private:
51  virtual dgInt32 CalculateSignature() const;
52  virtual void SetCollisionBBox(const dgVector &p0, const dgVector &p1);
53  virtual dgFloat32 CalculateMassProperties(dgVector &inertia, dgVector &crossInertia, dgVector &centerOfMass) const;
54 
55  virtual dgInt32 CalculatePlaneIntersection(const dgVector &normal, const dgVector &point, dgVector *const contactsOut) const;
56  virtual dgInt32 CalculatePlaneIntersectionSimd(const dgVector &normal, const dgVector &point, dgVector *const contactsOut) const;
57 
58  virtual void GetCollisionInfo(dgCollisionInfo *info) const;
59  virtual void Serialize(dgSerialize callback, void *const userData) const;
60 
61  dgFloat32 m_radius;
62  dgFloat32 m_radiusStep;
63 
64 // dgFloat32 m_tethaStep;
65 // dgFloat32 m_tethaStepInv;
66 // dgFloat32 m_delCosTetha;
67 // dgFloat32 m_delSinTetha;
68  dgVector m_vertex[DG_SPHERE_VERTEX_COUNT];
69 
70  static dgInt32 m_shapeRefCount;
71  static dgVector m_unitSphere[];
72  static dgConvexSimplexEdge m_edgeArray[];
73 
74  friend class dgWorld;
75 };
76 
77 
79 public:
80  dgCollisionPoint(dgMemoryAllocator *const allocator)
81  : dgCollisionSphere(allocator, 0x12344321, dgFloat32(0.25f), dgGetIdentityMatrix()) {
82  }
83 
84  virtual dgFloat32 GetVolume() const;
85  virtual void CalculateInertia(dgVector &inertia, dgVector &origin) const;
86 
87  virtual dgVector SupportVertex(const dgVector &dir) const;
88  virtual dgVector SupportVertexSimd(const dgVector &dir) const;
89 };
90 
91 #endif // !defined(AFX_DGCOLLISIONSPHERE_H__4969D514_69A9_4D96_82B2_E5B0EA3D413F__INCLUDED_)
92 
Definition: dgCollisionSphere.h:30
Definition: dgCollision.h:73
Definition: dgBody.h:85
Definition: dgCollisionConvex.h:29
Definition: dgVector.h:86
Definition: dgContact.h:88
Definition: dgCollisionConvex.h:39
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgWorld.h:118
Definition: dgCollisionSphere.h:78