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