Newton Dynamics  4.00
ndShapeConvexPolygon.h
1 /* Copyright (c) <2003-2022> <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 __ND_COLLISION_CONVEX_POLYGON_H__
23 #define __ND_COLLISION_CONVEX_POLYGON_H__
24 
25 #include "ndShapeConvex.h"
26 class ndShapeInstance;
27 
28 #define D_CONVEX_POLYGON_MAX_VERTEX_COUNT 64
29 
30 D_MSV_NEWTON_ALIGN_32
32 {
33  public:
35  {
36  public:
37  dgClippedFaceEdge* m_next;
38  dgClippedFaceEdge* m_twin;
39  ndInt32 m_incidentNormal;
40  ndInt32 m_incidentVertex;
41  };
42 
45 
46  virtual ndShapeConvexPolygon* GetAsShapeAsConvexPolygon();
47 
48  ndVector CalculateGlobalNormal(const ndShapeInstance* const parentMesh, const ndVector& localNormal) const;
49  ndInt32 CalculateContactToConvexHullDescrete(const ndShapeInstance* const parentMesh, ndContactSolver& proxy);
50  ndInt32 CalculateContactToConvexHullContinue(const ndShapeInstance* const parentMesh, ndContactSolver& proxy);
51 
52  virtual ndFloat32 GetVolume() const;
53  virtual ndFloat32 GetBoxMinRadius() const;
54  virtual ndFloat32 GetBoxMaxRadius() const;
55  void GenerateConvexCap(const ndShapeInstance* const parentMesh);
56  virtual ndVector SupportVertex(const ndVector& dir, ndInt32* const vertexIndex) const;
57  bool BeamClipping(const ndVector& origin, ndFloat32 size, const ndShapeInstance* const parentMesh);
58  virtual ndInt32 CalculatePlaneIntersection(const ndVector& normal, const ndVector& point, ndVector* const contactsOut) const;
59 
60  virtual ndFloat32 RayCast(ndRayCastNotify& callback, const ndVector& localP0, const ndVector& localP1, ndFloat32 maxT, const ndBody* const body, ndContactPoint& contactOut) const;
61 
62  virtual ndInt32 Release() const;
63 
64  ndVector m_normal;
65  ndVector m_localPoly[D_CONVEX_POLYGON_MAX_VERTEX_COUNT];
66  ndInt32 m_clippEdgeNormal[D_CONVEX_POLYGON_MAX_VERTEX_COUNT];
67  ndFloat32 m_faceClipSize;
68  ndInt32 m_count;
69  ndInt32 m_paddedCount;
70  ndInt32 m_faceId;
71  ndInt32 m_stride;
72  ndInt32 m_faceNormalIndex;
73 
74  const ndFloat32* m_vertex;
75  const ndInt32* m_vertexIndex;
76  const ndInt32* m_adjacentFaceEdgeNormalIndex;
77 } D_GCC_NEWTON_ALIGN_32;
78 
79 inline ndShapeConvexPolygon* ndShapeConvexPolygon::GetAsShapeAsConvexPolygon()
80 {
81  return this;
82 }
83 
84 inline ndFloat32 ndShapeConvexPolygon::RayCast(ndRayCastNotify&, const ndVector&, const ndVector&, ndFloat32, const ndBody* const, ndContactPoint&) const
85 {
86  return ndFloat32(1.2f);
87 }
88 
89 inline ndFloat32 ndShapeConvexPolygon::GetVolume() const
90 {
91  return ndFloat32(0.0f);
92 }
93 
94 inline ndFloat32 ndShapeConvexPolygon::GetBoxMinRadius() const
95 {
96  return m_faceClipSize;
97 }
98 
99 inline ndFloat32 ndShapeConvexPolygon::GetBoxMaxRadius() const
100 {
101  return GetBoxMinRadius();
102 }
103 
104 #endif
105 
ndShapeConvexPolygon::dgClippedFaceEdge
Definition: ndShapeConvexPolygon.h:35
ndBody
Definition: ndBody.h:43
ndShapeConvexPolygon
Definition: ndShapeConvexPolygon.h:32
ndContactSolver
Definition: ndContactSolver.h:60
ndRayCastNotify
Definition: ndRayCastNotify.h:31
ndShapeConvex
Definition: ndShapeConvex.h:34
ndContactPoint
Definition: ndContact.h:39
ndShapeInstance
Definition: ndShapeInstance.h:62
ndVector
Definition: ndVectorArmNeon.h:41