My Project: dynamics.mod/NewtonDynamics/source/physics/dgCollisionCylinder.h Source File

My Project

dgCollisionCylinder.h
Go to the documentation of this file.
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 #ifndef _DGCOLLISION_CYLINDER_H__
23 #define _DGCOLLISION_CYLINDER_H__
24
25 #include "dgCollisionConvex.h"
26
27 #define DG_CYLINDER_SEGMENTS 8
28
29
30 class dgCollisionCylinder: public dgCollisionConvex
31 {
32 public:
33 dgCollisionCylinder(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 radius, dgFloat32 height);
34 dgCollisionCylinder(dgWorld* const world, dgDeserialize deserialization, void* const userData);
35 virtual ~dgCollisionCylinder();
36
37
38 private:
39 void Init (dgFloat32 radius, dgFloat32 height);
40 virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const;
41
42 virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const;
43
44 virtual void MassProperties ();
45 virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const;
46
47 virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut, dgFloat32 normalSign) const;
48
49 virtual dgInt32 CalculateSignature () const;
50 virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1);
51
52 virtual dgFloat32 GetSkinThickness () const;
53
54 virtual void GetCollisionInfo(dgCollisionInfo* const info) const;
55 virtual void Serialize(dgSerialize callback, void* const userData) const;
56
57 static dgInt32 CalculateSignature (dgFloat32 radius, dgFloat32 height);
58
59
60 // special feature based contact calculation for conics convex (ex spheres, capsules, tapered capsules, and chamfered cylinders)
61 // in newton we only deal with sub set of conic function, that can be expressed by the equation
62 // ((x - x0) / a)^2 + ((y - y0) / b)^2 + ((z - z0) / c)^2 = 1 and possible a linear or circular sweep of the same equation
63 // this preclude parabolic and hyperbolic conics
64 virtual dgVector ConvexConicSupporVertex (const dgVector& dir) const;
65 virtual dgVector ConvexConicSupporVertex (const dgVector& point, const dgVector& dir) const;
66 virtual dgInt32 CalculateContacts (const dgVector& point, const dgVector& normal, dgCollisionParamProxy& proxy, dgVector* const contactsOut) const;
67
68
69 dgVector m_profile[4];
70 dgVector m_vertex[DG_CYLINDER_SEGMENTS * 2];
71 dgFloat32 m_height;
72 dgFloat32 m_radius;
73 dgFloat32 m_skinthickness;
74
75 static dgInt32 m_shapeRefCount;
76 static dgConvexSimplexEdge m_edgeArray[];
77
78 friend class dgWorld;
79 };
80
81 #endif
82
dgCollision::OnDebugCollisionMeshCallback
void(dgApi * OnDebugCollisionMeshCallback)(void *userData, int vertexCount, const dgFloat32 *FaceArray, int faceId)
Definition: dgCollision.h:220
dgCollisionInfo
Definition: dgCollision.h:82
dgBody
Definition: dgBody.h:44
userData
void *const userData
Definition: dgBroadPhase.h:35
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgConvexSimplexEdge
Definition: dgCollisionConvex.h:31
dgVector
Definition: dgVector.h:639
dgCollisionCylinder::dgCollisionCylinder
dgCollisionCylinder(dgMemoryAllocator *const allocator, dgUnsigned32 signature, dgFloat32 radius, dgFloat32 height)
Definition: dgCollisionCylinder.cpp:39
DG_CYLINDER_SEGMENTS
#define DG_CYLINDER_SEGMENTS
Definition: dgCollisionCylinder.h:27
dgContactPoint
Definition: dgContact.h:78
dgSerialize
void(dgApi * dgSerialize)(void *const userData, const void *const buffer, size_t size)
Definition: dgTypes.h:280
dgDeserialize
void(dgApi * dgDeserialize)(void *const userData, void *buffer, size_t size)
Definition: dgTypes.h:279
dgCollisionCylinder::~dgCollisionCylinder
virtual ~dgCollisionCylinder()
Definition: dgCollisionCylinder.cpp:132
OnRayPrecastAction
dgUnsigned32(dgApi * OnRayPrecastAction)(const dgBody *const body, const dgCollisionInstance *const collision, void *const userData)
Definition: dgBroadPhase.h:36
dgCollisionCylinder
Definition: dgCollisionCylinder.h:30
dgUnsigned32
unsigned dgUnsigned32
Definition: dgTypes.h:219
dgCollisionConvex
Definition: dgCollisionConvex.h:42
dgMatrix
Definition: dgMatrix.h:40
dgMemoryAllocator
Definition: dgMemory.h:73
dgWorld
Definition: dgWorld.h:129
dgCollisionConvex.h
dgCollisionParamProxy
Definition: dgContact.h:93