Newton Dynamics  4.00
ndShapeStaticBVH.h
1 /* Copyright (c) <2003-2019> <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 __D_SHAPE_STATIC_BVH__
23 #define __D_SHAPE_STATIC_BVH__
24 
25 #include "ndCollisionStdafx.h"
26 #include "ndShapeStaticMesh.h"
27 
28 class ndBodyKinematic;
29 class ndShapeStaticBVH;
30 typedef dFloat32 (*dgCollisionBVHUserRayCastCallback) (const ndBodyKinematic* const body, const ndShapeStaticBVH* const collsionShape, dFloat32 interception, dFloat32* normal, dInt32 faceId, void* usedData);
31 
33 {
34  public:
35  D_COLLISION_API ndShapeStaticBVH(const dPolygonSoupBuilder& builder);
36  D_COLLISION_API ndShapeStaticBVH(const nd::TiXmlNode* const xmlNode, const char* const assetPath);
37  D_COLLISION_API virtual ~ndShapeStaticBVH();
38 
39  protected:
40  virtual ndShapeInfo GetShapeInfo() const;
41  virtual void DebugShape(const dMatrix& matrix, ndShapeDebugCallback& debugCallback) const;
42  virtual dFloat32 RayCast(ndRayCastNotify& callback, const dVector& localP0, const dVector& localP1, const ndBody* const body, ndContactPoint& contactOut) const;
43  virtual void GetCollidingFaces(ndPolygonMeshDesc* const data) const;
44 
45  static dFloat32 RayHit(void* const context, const dFloat32* const polygon, dInt32 strideInBytes, const dInt32* const indexArray, dInt32 indexCount);
46  static dIntersectStatus ShowDebugPolygon(void* const context, const dFloat32* const polygon, dInt32 strideInBytes, const dInt32* const indexArray, dInt32 indexCount, dFloat32 hitDistance);
47  static dIntersectStatus GetTriangleCount(void* const context, const dFloat32* const polygon, dInt32 strideInBytes, const dInt32* const indexArray, dInt32 indexCount, dFloat32 hitDistance);
48  static dIntersectStatus GetPolygon(void* const context, const dFloat32* const polygon, dInt32 strideInBytes, const dInt32* const indexArray, dInt32 indexCount, dFloat32 hitDistance);
49  public:
50  D_MSV_NEWTON_ALIGN_32
51  class ndBvhRay: public dFastRayTest
52  {
53  public:
54  ndBvhRay(const dVector& l0, const dVector& l1)
55  :dFastRayTest (l0, l1)
56  {
57  }
58 
59  dMatrix m_matrix;
60  dVector m_normal;
61  dUnsigned32 m_id;
62  dFloat32 m_t;
63  ndRayCastNotify* m_callback;
64  const ndBodyKinematic* m_myBody;
65  const ndShapeStaticBVH* m_me;
66  } D_GCC_NEWTON_ALIGN_32;
67 
68  private:
69  D_COLLISION_API virtual void Save(nd::TiXmlElement* const xmlNode, const char* const assetPath, dInt32 nodeid) const;
70  dInt32 m_trianglesCount;
71 };
72 
73 
74 #endif
dFastRayTest
Definition: dIntersections.h:121
ndShapeStaticBVH
Definition: ndShapeStaticBVH.h:33
ndPolygonMeshDesc
Definition: ndShapeStaticMesh.h:42
nd::TiXmlNode
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:427
dPolygonSoupBuilder
Definition: dPolygonSoupBuilder.h:47
ndShapeStaticMesh
Definition: ndShapeStaticMesh.h:119
ndBody
Definition: ndBody.h:40
ndShapeDebugCallback
Definition: ndShapeInstance.h:37
ndRayCastNotify
Definition: ndRayCastNotify.h:33
ndContactPoint
Definition: ndContact.h:40
nd::TiXmlElement
The element is a container class.
Definition: tinyxml.h:947
ndBodyKinematic
Definition: ndBodyKinematic.h:37
dVector
Definition: dVectorArmNeon.h:1104
dMatrix
Definition: dMatrix.h:39
ndShapeInfo
Definition: ndShape.h:100
ndShapeStaticBVH::ndBvhRay
Definition: ndShapeStaticBVH.h:52
dAabbPolygonSoup
Definition: dAabbPolygonSoup.h:33