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

My Project

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