Newton Dynamics  4.00
ndShapeStaticMesh.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_MESH_H__
23 #define __ND_SHAPE_STATIC_MESH_H__
24 
25 #include "ndCollisionStdafx.h"
26 #include "ndShape.h"
27 
28 class ndShapeInstance;
29 class ndPolygonMeshDesc;
30 
32 {
33  public:
34  D_CLASS_REFLECTION(ndShapeStaticMesh);
35  D_COLLISION_API ndShapeStaticMesh(ndShapeID id);
36  D_COLLISION_API ndShapeStaticMesh(const ndLoadSaveBase::ndLoadDescriptor& desc);
37  D_COLLISION_API virtual ~ndShapeStaticMesh();
38 
39  virtual void DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& debugCallback) const;
40  virtual ndFloat32 RayCast(ndRayCastNotify& callback, const ndVector& localP0, const ndVector& localP1, ndFloat32 maxT, const ndBody* const body, ndContactPoint& contactOut) const;
41  virtual void GetCollidingFaces(ndPolygonMeshDesc* const data) const;
42  D_COLLISION_API void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
43 
44  protected:
45  virtual ndFloat32 GetVolume() const;
46  virtual ndFloat32 GetBoxMinRadius() const;
47  virtual ndFloat32 GetBoxMaxRadius() const;
48  virtual ndShapeStaticMesh* GetAsShapeStaticMesh();
49  virtual ndVector SupportVertex(const ndVector& dir, ndInt32* const vertexIndex) const;
50  virtual ndVector SupportVertexSpecial(const ndVector& dir, ndFloat32 skinMargin, ndInt32* const vertexIndex) const;
51  virtual ndVector SupportVertexSpecialProjectPoint(const ndVector& point, const ndVector& dir) const;
52  virtual ndInt32 CalculatePlaneIntersection(const ndVector& normal, const ndVector& point, ndVector* const contactsOut) const;
53  virtual ndVector CalculateVolumeIntegral(const ndMatrix& globalMatrix, const ndVector& plane, const ndShapeInstance& parentScale) const;
54 
55  D_COLLISION_API virtual void CalculateAabb(const ndMatrix& matrix, ndVector& p0, ndVector& p1) const;
56  D_COLLISION_API ndInt32 CalculatePlaneIntersection(const ndFloat32* const vertex, const ndInt32* const index, ndInt32 indexCount, ndInt32 strideInFloat, const ndPlane& localPlane, ndVector* const contactsOut) const;
57 
58  D_MSV_NEWTON_ALIGN_32
60  {
61  public:
62  ndInt32* m_indexList;
63  ndInt32* m_userDataList;
64  ndFloat32* m_veterxArray;
65  ndInt32 m_triangleCount;
66  ndInt32 m_maxIndexCount;
67  ndInt32 m_vertexCount;
68  ndInt32 m_vertexStrideInBytes;
69  } D_GCC_NEWTON_ALIGN_32;
70 };
71 
72 inline ndFloat32 ndShapeStaticMesh::GetVolume() const
73 {
74  return ndFloat32(0.0f);
75 }
76 
77 inline ndFloat32 ndShapeStaticMesh::GetBoxMinRadius() const
78 {
79  return ndFloat32(0.0f);
80 }
81 
82 inline ndFloat32 ndShapeStaticMesh::GetBoxMaxRadius() const
83 {
84  return ndFloat32(0.0f);
85 }
86 
87 inline ndVector ndShapeStaticMesh::SupportVertex(const ndVector&, ndInt32* const) const
88 {
89  ndAssert(0);
90  return ndVector::m_zero;
91 }
92 
93 inline ndVector ndShapeStaticMesh::SupportVertexSpecial(const ndVector& dir, ndFloat32, ndInt32* const vertexIndex) const
94 {
95  ndAssert(0);
96  return SupportVertex(dir, vertexIndex);
97 }
98 
99 inline ndVector ndShapeStaticMesh::SupportVertexSpecialProjectPoint(const ndVector& point, const ndVector&) const
100 {
101  return point;
102 }
103 
104 inline ndInt32 ndShapeStaticMesh::CalculatePlaneIntersection(const ndVector&, const ndVector&, ndVector* const) const
105 {
106  return 0;
107 }
108 
109 inline ndVector ndShapeStaticMesh::CalculateVolumeIntegral(const ndMatrix&, const ndVector&, const ndShapeInstance&) const
110 {
111  return ndVector::m_zero;
112 }
113 
114 inline ndShapeStaticMesh* ndShapeStaticMesh::GetAsShapeStaticMesh()
115 {
116  return this;
117 }
118 
119 
120 inline void ndShapeStaticMesh::DebugShape(const ndMatrix&, ndShapeDebugNotify&) const
121 {
122 }
123 
124 inline ndFloat32 ndShapeStaticMesh::RayCast(ndRayCastNotify&, const ndVector&, const ndVector&, ndFloat32, const ndBody* const, ndContactPoint&) const
125 {
126  return ndFloat32(1.2f);
127 }
128 
129 inline void ndShapeStaticMesh::GetCollidingFaces(ndPolygonMeshDesc* const) const
130 {
131 }
132 
133 #endif
134 
135 
136 
ndPolygonMeshDesc
Definition: ndPolygonMeshDesc.h:35
ndShapeStaticMesh
Definition: ndShapeStaticMesh.h:32
ndBody
Definition: ndBody.h:43
ndShape
Definition: ndShape.h:209
ndShapeStaticMesh::ndMeshVertexListIndexList
Definition: ndShapeStaticMesh.h:60
ndRayCastNotify
Definition: ndRayCastNotify.h:31
ndPlane
Definition: ndPlane.h:35
ndContactPoint
Definition: ndContact.h:39
ndMatrix
Definition: ndMatrix.h:42
ndShapeDebugNotify
Definition: ndShapeInstance.h:38
ndShapeInstance
Definition: ndShapeInstance.h:62
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndVector
Definition: ndVectorArmNeon.h:41