Newton Dynamics  4.00
ndShapeStaticProceduralMesh.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_SHAPE_STATIC_PROCEDURAL_MESH__
23 #define __ND_SHAPE_STATIC_PROCEDURAL_MESH__
24 
25 #include "ndCollisionStdafx.h"
26 #include "ndShapeStaticMesh.h"
27 
29 {
30  public:
31  class ndEdge
32  {
33  public:
34  ndEdge();
35  ndEdge(ndInt32 i0, ndInt32 i1, const ndPlane& plane, ndInt32 testIndex);
36 
37  bool operator< (const ndEdge& edge) const;
38  bool operator> (const ndEdge& edge) const;
39 
40  ndPlane m_plane;
41  ndInt32 m_testIndex;
42  union
43  {
44  ndUnsigned64 m_key;
45  struct
46  {
47  ndInt32 m_i0;
48  ndInt32 m_i1;
49  };
50  };
51  };
52 
53  class ndEdgeMap : public ndTree<ndInt32, ndEdge, ndContainersFreeListAlloc<ndInt32>>
54  {
55  public:
56  ndEdgeMap();
57  };
58 
59  D_CLASS_REFLECTION(ndShapeStaticProceduralMesh);
61  D_COLLISION_API ndShapeStaticProceduralMesh(ndFloat32 sizex, ndFloat32 sizey, ndFloat32 sizez);
62  D_COLLISION_API virtual ~ndShapeStaticProceduralMesh();
63  D_COLLISION_API virtual ndShapeInfo GetShapeInfo() const;
64  D_COLLISION_API virtual void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
65 
66  virtual ndShapeStaticProceduralMesh* GetAsShapeStaticProceduralMesh() { return this; }
67  virtual void GetCollidingFaces(const ndVector& minBox, const ndVector& maxBox, ndArray<ndVector>& vertex, ndArray<ndInt32>& faceList, ndArray<ndInt32>& faceMaterial, ndArray<ndInt32>& indexListList) const;
68 
69  protected:
70  D_COLLISION_API virtual void GetCollidingFaces(ndPolygonMeshDesc* const data) const;
71 
72  private:
73  void CalculateLocalObb();
74 
75  ndVector m_minBox;
76  ndVector m_maxBox;
77  friend class ndContactSolver;
78 };
79 
80 inline void ndShapeStaticProceduralMesh::GetCollidingFaces(const ndVector&, const ndVector&, ndArray<ndVector>&, ndArray<ndInt32>&, ndArray<ndInt32>&, ndArray<ndInt32>&) const
81 {
82  ndAssert(0);
83 }
84 
85 inline ndShapeStaticProceduralMesh::ndEdge::ndEdge()
86 {
87 }
88 
89 inline ndShapeStaticProceduralMesh::ndEdge::ndEdge(ndInt32 i0, ndInt32 i1,
90  const ndPlane& plane, ndInt32 testIndex)
91  :m_plane(plane)
92  ,m_testIndex(testIndex)
93  ,m_i0(i0)
94  ,m_i1(i1)
95 {
96 }
97 
98 inline bool ndShapeStaticProceduralMesh::ndEdge::operator< (const ndEdge& edge) const
99 {
100  return m_key < edge.m_key;
101 }
102 
103 inline bool ndShapeStaticProceduralMesh::ndEdge::operator> (const ndEdge& edge) const
104 {
105  return m_key > edge.m_key;
106 }
107 
108 inline ndShapeStaticProceduralMesh::ndEdgeMap::ndEdgeMap()
109  :ndTree<ndInt32, ndEdge, ndContainersFreeListAlloc<ndInt32>>()
110 {
111 }
112 
113 #endif
ndEdge
Definition: ndPolyhedra.h:44
ndPolygonMeshDesc
Definition: ndPolygonMeshDesc.h:35
ndShapeStaticProceduralMesh::ndEdge
Definition: ndShapeStaticProceduralMesh.h:32
ndArray< ndVector >
ndShapeStaticMesh
Definition: ndShapeStaticMesh.h:32
ndTree
Definition: ndTree.h:82
ndShapeStaticProceduralMesh
Definition: ndShapeStaticProceduralMesh.h:29
ndShapeStaticProceduralMesh::ndEdgeMap
Definition: ndShapeStaticProceduralMesh.h:54
ndContactSolver
Definition: ndContactSolver.h:60
ndPlane
Definition: ndPlane.h:35
ndShapeInfo
Definition: ndShape.h:182
ndContainersFreeListAlloc
Definition: ndContainersAlloc.h:60
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndVector
Definition: ndVectorArmNeon.h:41