Newton Dynamics  4.00
ndShapeStatic_bvh.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_BVH__
23 #define __ND_SHAPE_STATIC_BVH__
24 
25 #include "ndCollisionStdafx.h"
26 #include "ndShapeStaticMesh.h"
27 
29 {
30  public:
31  D_CLASS_REFLECTION(ndShapeStatic_bvh);
32  D_COLLISION_API ndShapeStatic_bvh(const ndPolygonSoupBuilder& builder);
33  D_COLLISION_API ndShapeStatic_bvh(const ndLoadSaveBase::ndLoadDescriptor& desc);
34  D_COLLISION_API virtual ~ndShapeStatic_bvh();
35 
36  void *operator new (size_t size);
37  void operator delete (void* ptr);
38 
39  protected:
40  virtual ndShapeInfo GetShapeInfo() const;
41  virtual ndShapeStatic_bvh* GetAsShapeStaticBVH() { return this; }
42  virtual void DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& debugCallback) const;
43  virtual ndFloat32 RayCast(ndRayCastNotify& callback, const ndVector& localP0, const ndVector& localP1, ndFloat32 maxT, const ndBody* const body, ndContactPoint& contactOut) const;
44  virtual void GetCollidingFaces(ndPolygonMeshDesc* const data) const;
45  virtual void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
46 
47  static ndFloat32 RayHit(void* const context, const ndFloat32* const polygon, ndInt32 strideInBytes, const ndInt32* const indexArray, ndInt32 indexCount);
48  static ndIntersectStatus ShowDebugPolygon(void* const context, const ndFloat32* const polygon, ndInt32 strideInBytes, const ndInt32* const indexArray, ndInt32 indexCount, ndFloat32 hitDistance);
49  static ndIntersectStatus GetTriangleCount(void* const context, const ndFloat32* const polygon, ndInt32 strideInBytes, const ndInt32* const indexArray, ndInt32 indexCount, ndFloat32 hitDistance);
50  static ndIntersectStatus GetPolygon(void* const context, const ndFloat32* const polygon, ndInt32 strideInBytes, const ndInt32* const indexArray, ndInt32 indexCount, ndFloat32 hitDistance);
51 
52  private:
53  ndInt32 m_trianglesCount;
54 
55  friend class ndContactSolver;
56 };
57 
58 inline void* ndShapeStatic_bvh::operator new (size_t size)
59 {
60  return ndShapeStaticMesh::operator new (size);
61 }
62 
63 inline void ndShapeStatic_bvh::operator delete (void* ptr)
64 {
65  ndShapeStaticMesh::operator delete(ptr);
66 }
67 
68 
69 #endif
ndPolygonMeshDesc
Definition: ndPolygonMeshDesc.h:35
ndShapeStaticMesh
Definition: ndShapeStaticMesh.h:32
ndBody
Definition: ndBody.h:43
ndContactSolver
Definition: ndContactSolver.h:60
ndRayCastNotify
Definition: ndRayCastNotify.h:31
ndPolygonSoupBuilder
Definition: ndPolygonSoupBuilder.h:48
ndContactPoint
Definition: ndContact.h:39
ndMatrix
Definition: ndMatrix.h:42
ndShapeDebugNotify
Definition: ndShapeInstance.h:38
ndShapeInfo
Definition: ndShape.h:182
ndAabbPolygonSoup
Base class for creating a leafless bounding box hierarchy for queering a polygon list index list mesh...
Definition: ndAabbPolygonSoup.h:55
ndShapeStatic_bvh
Definition: ndShapeStatic_bvh.h:29
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndVector
Definition: ndVectorArmNeon.h:41