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