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

My Project

dgCollisionConvexPolygon.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 _DG_COLLISION_CONVEX_POLYGON_H_
23 #define _DG_COLLISION_CONVEX_POLYGON_H_
24
25 #include "dgCollisionConvexHull.h"
26
27
28 #define DG_CONVEX_POLYGON_MAX_VERTEX_COUNT 64
29
30 DG_MSC_VECTOR_ALIGMENT
31 class dgCollisionConvexPolygon: public dgCollisionConvex
32 {
33 public:
34 class dgClippedFaceEdge
35 {
36 public:
37 dgClippedFaceEdge* m_next;
38 dgClippedFaceEdge* m_twin;
39 dgInt32 m_incidentNormal;
40 dgInt32 m_incidentVertex;
41 };
42
43 public:
44 dgCollisionConvexPolygon (dgMemoryAllocator* const allocator);
45 ~dgCollisionConvexPolygon ();
46
47 virtual dgInt32 CalculateSignature () const;
48 virtual void Serialize(dgSerialize callback, void* const userData) const;
49 virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1);
50 virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const;
51
52 virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const;
53
54 virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut, dgFloat32 normalSign) const;
55
56 virtual dgFloat32 GetVolume () const;
57 virtual dgFloat32 GetBoxMinRadius () const;
58 virtual dgFloat32 GetBoxMaxRadius () const;
59
60 void BeamClipping (const dgVector& origin, dgFloat32 size);
61 void SetFeatureHit (dgInt32 featureCount, const dgInt32* const index);
62 dgInt32 CalculateContactToConvexHullDescrete (dgCollisionParamProxy& proxy, const dgVector& polyInstanceScale, const dgVector& polyInstanceInvScale);
63 dgInt32 CalculateContactToConvexHullContinue (dgCollisionParamProxy& proxy, const dgVector& polyInstanceScale, const dgVector& polyInstanceInvScale);
64
65 // dgVector ClosestDistanceToTriangle (const dgVector& point, const dgVector& p0, const dgVector& p1, const dgVector& p2, bool& isEdge) const;
66 // bool PointToPolygonDistance (const dgVector& point, dgFloat32 radius, dgVector& out, bool& isEdge);
67 // bool DistanceToOrigen (const dgMatrix& matrix, const dgVector& scale, dgFloat32 radius, dgVector& out, bool& isEdge);
68 // dgFloat32 MovingPointToPolygonContact (const dgVector& p0, const dgVector& p1, dgFloat32 radius, dgContactPoint& contact);
69
70 dgVector m_normal;
71 dgVector m_localPoly[DG_CONVEX_POLYGON_MAX_VERTEX_COUNT];
72 dgInt32 m_clippEdgeNormal[DG_CONVEX_POLYGON_MAX_VERTEX_COUNT];
73 dgInt32 m_count;
74 dgInt32 m_paddedCount;
75 dgInt32 m_faceId;
76 dgInt32 m_stride;
77 dgInt32 m_faceNormalIndex;
78 dgInt32 m_closestFeatureType;
79 dgInt32 m_closestFeatureStartIndex;
80 dgFloat32 m_faceClipSize;
81 const dgFloat32* m_vertex;
82 const dgInt32* m_vertexIndex;
83 const dgInt32* m_adjacentFaceEdgeNormalIndex;
84
85 } DG_GCC_VECTOR_ALIGMENT;
86
87 #endif
dgCollisionConvexHull.h
dgCollisionConvexPolygon::BeamClipping
void BeamClipping(const dgVector &origin, dgFloat32 size)
Definition: dgCollisionConvexPolygon.cpp:114
dgCollisionConvexPolygon::GetBoxMinRadius
virtual dgFloat32 GetBoxMinRadius() const
Definition: dgCollisionConvexPolygon.cpp:83
DG_GCC_VECTOR_ALIGMENT
dgCollisionConvexPolygon DG_GCC_VECTOR_ALIGMENT
dgCollisionConvexPolygon::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: dgCollisionConvexPolygon.cpp:70
dgCollisionConvexPolygon::dgClippedFaceEdge::m_next
dgClippedFaceEdge * m_next
Definition: dgCollisionConvexPolygon.h:37
dgCollisionConvexPolygon::GetVolume
virtual dgFloat32 GetVolume() const
Definition: dgCollisionConvexPolygon.cpp:77
dgBody
Definition: dgBody.h:44
dgCollisionConvexPolygon::SetCollisionBBox
virtual void SetCollisionBBox(const dgVector &p0, const dgVector &p1)
Definition: dgCollisionConvexPolygon.cpp:59
dgCollisionConvexPolygon::CalculateContactToConvexHullContinue
dgInt32 CalculateContactToConvexHullContinue(dgCollisionParamProxy &proxy, const dgVector &polyInstanceScale, const dgVector &polyInstanceInvScale)
Definition: dgCollisionConvexPolygon.cpp:515
userData
void *const userData
Definition: dgBroadPhase.h:35
dgCollisionConvexPolygon::CalculateSignature
virtual dgInt32 CalculateSignature() const
Definition: dgCollisionConvexPolygon.cpp:54
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgCollisionConvexPolygon::CalculatePlaneIntersection
virtual dgInt32 CalculatePlaneIntersection(const dgVector &normal, const dgVector &point, dgVector *const contactsOut, dgFloat32 normalSign) const
Definition: dgCollisionConvexPolygon.cpp:340
dgVector
Definition: dgVector.h:639
dgCollisionConvexPolygon::dgClippedFaceEdge::m_twin
dgClippedFaceEdge * m_twin
Definition: dgCollisionConvexPolygon.h:38
dgCollisionConvexPolygon::m_count
dgInt32 m_count
Definition: dgCollisionConvexPolygon.h:73
dgCollisionConvexPolygon::dgClippedFaceEdge
Definition: dgCollisionConvexPolygon.h:34
dgCollisionConvexPolygon::m_faceClipSize
dgFloat32 m_faceClipSize
Definition: dgCollisionConvexPolygon.h:80
dgCollisionConvexPolygon
Definition: dgCollisionConvexPolygon.h:31
dgContactPoint
Definition: dgContact.h:78
dgSerialize
void(dgApi * dgSerialize)(void *const userData, const void *const buffer, size_t size)
Definition: dgTypes.h:280
DG_MSC_VECTOR_ALIGMENT
#define DG_MSC_VECTOR_ALIGMENT
Definition: dgTypes.h:194
dgCollisionConvexPolygon::m_closestFeatureStartIndex
dgInt32 m_closestFeatureStartIndex
Definition: dgCollisionConvexPolygon.h:79
dgCollisionConvexPolygon::m_closestFeatureType
dgInt32 m_closestFeatureType
Definition: dgCollisionConvexPolygon.h:78
dgCollisionConvexPolygon::m_stride
dgInt32 m_stride
Definition: dgCollisionConvexPolygon.h:76
dgCollisionConvexPolygon::m_paddedCount
dgInt32 m_paddedCount
Definition: dgCollisionConvexPolygon.h:74
OnRayPrecastAction
dgUnsigned32(dgApi * OnRayPrecastAction)(const dgBody *const body, const dgCollisionInstance *const collision, void *const userData)
Definition: dgBroadPhase.h:36
dgCollisionConvexPolygon::CalculateContactToConvexHullDescrete
dgInt32 CalculateContactToConvexHullDescrete(dgCollisionParamProxy &proxy, const dgVector &polyInstanceScale, const dgVector &polyInstanceInvScale)
Definition: dgCollisionConvexPolygon.cpp:727
dgCollisionConvexPolygon::~dgCollisionConvexPolygon
~dgCollisionConvexPolygon()
Definition: dgCollisionConvexPolygon.cpp:48
dgCollisionConvex
Definition: dgCollisionConvex.h:42
DG_CONVEX_POLYGON_MAX_VERTEX_COUNT
#define DG_CONVEX_POLYGON_MAX_VERTEX_COUNT
Definition: dgCollisionConvexPolygon.h:28
dgCollisionConvexPolygon::SetFeatureHit
void SetFeatureHit(dgInt32 featureCount, const dgInt32 *const index)
Definition: dgCollisionConvexPolygon.cpp:288
dgCollisionConvexPolygon::Serialize
virtual void Serialize(dgSerialize callback, void *const userData) const
Definition: dgCollisionConvexPolygon.cpp:64
dgCollisionConvexPolygon::dgClippedFaceEdge::m_incidentVertex
dgInt32 m_incidentVertex
Definition: dgCollisionConvexPolygon.h:40
dgCollisionConvexPolygon::m_localPoly
dgVector m_localPoly[DG_CONVEX_POLYGON_MAX_VERTEX_COUNT]
Definition: dgCollisionConvexPolygon.h:71
dgCollisionConvexPolygon::m_adjacentFaceEdgeNormalIndex
const dgInt32 * m_adjacentFaceEdgeNormalIndex
Definition: dgCollisionConvexPolygon.h:83
dgCollisionConvexPolygon::dgCollisionConvexPolygon
dgCollisionConvexPolygon(dgMemoryAllocator *const allocator)
Definition: dgCollisionConvexPolygon.cpp:33
dgCollisionConvexPolygon::GetBoxMaxRadius
virtual dgFloat32 GetBoxMaxRadius() const
Definition: dgCollisionConvexPolygon.cpp:88
dgMemoryAllocator
Definition: dgMemory.h:73
dgCollisionConvexPolygon::m_clippEdgeNormal
dgInt32 m_clippEdgeNormal[DG_CONVEX_POLYGON_MAX_VERTEX_COUNT]
Definition: dgCollisionConvexPolygon.h:72
dgCollisionConvexPolygon::m_vertexIndex
const dgInt32 * m_vertexIndex
Definition: dgCollisionConvexPolygon.h:82
dgCollisionConvexPolygon::SupportVertex
virtual dgVector SupportVertex(const dgVector &dir, dgInt32 *const vertexIndex) const
Definition: dgCollisionConvexPolygon.cpp:95
dgCollisionConvexPolygon::m_faceNormalIndex
dgInt32 m_faceNormalIndex
Definition: dgCollisionConvexPolygon.h:77
dgCollisionConvexPolygon::m_vertex
const dgFloat32 * m_vertex
Definition: dgCollisionConvexPolygon.h:81
dgCollisionParamProxy
Definition: dgContact.h:93
dgCollisionConvexPolygon::dgClippedFaceEdge::m_incidentNormal
dgInt32 m_incidentNormal
Definition: dgCollisionConvexPolygon.h:39
dgCollisionConvexPolygon::m_faceId
dgInt32 m_faceId
Definition: dgCollisionConvexPolygon.h:75
dgCollisionConvexPolygon::m_normal
dgVector m_normal
Definition: dgCollisionConvexPolygon.h:70