You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
892 B
27 lines
892 B
#ifndef BVH_HPP
|
|
#define BVH_HPP
|
|
|
|
#include "aabb.h"
|
|
#include <tinynurbs/tinynurbs.h>
|
|
#include <vector>
|
|
|
|
struct BVHNode {
|
|
AABB bound; // AABB包围盒
|
|
int firstChild, level; // 第一个孩子节点的下标,该结点所在层次
|
|
int idx_u;
|
|
int idx_v;
|
|
};
|
|
|
|
class BVH {
|
|
public:
|
|
int maxLevel; // 树高和结点数量
|
|
const std::vector<std::vector<glm::vec3>> & evaluations;
|
|
std::vector<BVHNode> tree;
|
|
explicit BVH (const std::vector<std::vector<glm::vec3>>& evaluations_);
|
|
void recursiveBuild(int level, int idx, int idx_u, int idx_v);
|
|
void build();
|
|
};
|
|
void recursiveGetOverlapLeafNodes(const BVH &bvh1, const BVH &bvh2, int idx1, int idx2,
|
|
std::vector<std::pair<int, int>> &pairs);
|
|
std::vector<std::pair<std::pair<int, int>, std::pair<int,int>>> getOverlapLeafNodes(const BVH &bvh1, const BVH &bvh2);
|
|
#endif
|