Newton Dynamics  4.00
ndShapeConvexHull.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_CONVEXHULL_H__
23 #define __ND_SHAPE_CONVEXHULL_H__
24 
25 #include "ndShapeConvex.h"
26 
27 D_MSV_NEWTON_ALIGN_32
29 {
30  class ndConvexBox;
31 
32  public:
33  D_CLASS_REFLECTION(ndShapeConvexHull);
34  D_COLLISION_API ndShapeConvexHull(const ndLoadSaveBase::ndLoadDescriptor& desc);
35  D_COLLISION_API ndShapeConvexHull(ndInt32 count, ndInt32 strideInBytes, ndFloat32 tolerance, const ndFloat32* const vertexArray, ndInt32 maxPointsOut = 0x7fffffff);
36  D_COLLISION_API virtual ~ndShapeConvexHull();
37 
38  protected:
39  ndShapeInfo GetShapeInfo() const;
40  ndBigVector FaceNormal(const ndEdge *face, const ndBigVector* const pool) const;
41  bool RemoveCoplanarEdge(ndPolyhedra& convex, const ndBigVector* const hullVertexArray) const;
42  bool Create(ndInt32 count, ndInt32 strideInBytes, const ndFloat32* const vertexArray, ndFloat32 tolerance, ndInt32 maxPointsOut);
43  virtual ndVector SupportVertex(const ndVector& dir, ndInt32* const vertexIndex) const;
44  D_COLLISION_API virtual void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
45 
46  private:
47  ndVector SupportVertexBruteForce(const ndVector& dir, ndInt32* const vertexIndex) const;
48  ndVector SupportVertexhierarchical(const ndVector& dir, ndInt32* const vertexIndex) const;
49 
50  void DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& debugCallback) const;
51 
52  ndConvexBox* m_supportTree;
53  ndConvexSimplexEdge** m_faceArray;
54  ndVector* m_soa_x;
55  ndVector* m_soa_y;
56  ndVector* m_soa_z;
57  ndVector* m_soa_index;
58 
59  const ndConvexSimplexEdge** m_vertexToEdgeMapping;
60  ndInt32 m_faceCount;
61  ndInt32 m_soaVertexCount;
62  ndInt32 m_supportTreeCount;
63 } D_GCC_NEWTON_ALIGN_32;
64 
65 #endif
66 
ndEdge
Definition: ndPolyhedra.h:44
ndShapeConvexHull::ndConvexBox
Definition: ndShapeConvexHull.cpp:34
ndShapeConvex::ndConvexSimplexEdge
Definition: ndShapeConvex.h:38
ndShapeConvex
Definition: ndShapeConvex.h:34
ndMatrix
Definition: ndMatrix.h:42
ndShapeDebugNotify
Definition: ndShapeInstance.h:38
ndShapeConvexHull
Definition: ndShapeConvexHull.h:29
ndShapeInfo
Definition: ndShape.h:182
ndPolyhedra
Definition: ndPolyhedra.h:60
ndBigVector
Definition: ndVectorArmNeon.h:463
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndVector
Definition: ndVectorArmNeon.h:41