vhacdRaycastMesh.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef RAYCAST_MESH_H
  2. #define RAYCAST_MESH_H
  3. #include <stdint.h>
  4. namespace VHACD
  5. {
  6. // Very simple brute force raycast against a triangle mesh. Tests every triangle; no hierachy.
  7. // Does a deep copy, always does calculations with full double float precision
  8. class RaycastMesh
  9. {
  10. public:
  11. static RaycastMesh * createRaycastMesh(uint32_t vcount, // The number of vertices in the source triangle mesh
  12. const double *vertices, // The array of vertex positions in the format x1,y1,z1..x2,y2,z2.. etc.
  13. uint32_t tcount, // The number of triangles in the source triangle mesh
  14. const uint32_t *indices); // The triangle indices in the format of i1,i2,i3 ... i4,i5,i6, ...
  15. static RaycastMesh * createRaycastMesh(uint32_t vcount, // The number of vertices in the source triangle mesh
  16. const float *vertices, // The array of vertex positions in the format x1,y1,z1..x2,y2,z2.. etc.
  17. uint32_t tcount, // The number of triangles in the source triangle mesh
  18. const uint32_t *indices); // The triangle indices in the format of i1,i2,i3 ... i4,i5,i6, ...
  19. virtual bool raycast(const double *from, // The starting point of the raycast
  20. const double *to, // The ending point of the raycast
  21. const double *closestToPoint, // The point to match the nearest hit location (can just be the 'from' location of no specific point)
  22. double *hitLocation, // The point where the ray hit nearest to the 'closestToPoint' location
  23. double *hitDistance) = 0; // The distance the ray traveled to the hit location
  24. virtual void release(void) = 0;
  25. protected:
  26. virtual ~RaycastMesh(void) { };
  27. };
  28. } // end of VHACD namespace
  29. #endif