// // Created by 14727 on 2022/12/11. // #ifndef NURBSEVALUATOR_BVH_CUH #define NURBSEVALUATOR_BVH_CUH #include "device/aabb.cuh" struct BVHNode { AABB bounds; // AABB包围盒 int firstChild = -1, level = 0; // 第一个孩子节点的下标,该结点所在层次 // 曲面片u, v的范围 float u0 = 0., u1 = 0., v0 = 0., v1 = 0.; int idx_u = -1, idx_v = -1; }; /** * 当前层的第一个节点的坐标 * @param layer 层号。根节点为第一层 */ __device__ __host__ int getStartIdxOfLayerN(int layer); /** * 根据u、v参数域中的小矩形的位置,判断它在BVH叶节点层(也就是最后一层)中的位置 */ __device__ int d_getChildNodeIdx(int ix, int iy); __host__ int h_getChildNodeIdx(int ix, int iy); class BVH { public: int maxLevel, size; BVHNode *nodes = nullptr; __host__ void printQuadTree(); }; __global__ void g_buildBvh(const float *k, int level, const glm::vec3 *evaluatedPoints, float lastKnot_u, float lastKnot_v, int sampleCnt_u, int sampleCnt_v, BVHNode *BVH); #endif //NURBSEVALUATOR_BVH_CUH