更新了代码

dev-VirtualTexture
yang.yongquan 2022-09-06 22:16:04 +08:00
parent fa112820cc
commit 081e9a7ffb
1 changed files with 7 additions and 4 deletions

View File

@ -9,13 +9,13 @@
#include <memory>
#include <vector>
#include <cmath>
#define bvhPtr std::tr1::shared_ptr<BvhNode>
using std::tr1::shared_ptr;
// BvhTree 节点
struct BvhNode {
GLuint lab;
QVector4D bound;
bvhPtr child[2];
shared_ptr<BvhNode> child[2];
static bool x_compare(QVector4D a, QVector4D b) {
return a.x() < b.x();
}
@ -43,13 +43,18 @@ struct BvhNode {
~BvhNode() {}
};
typedef std::tr1::shared_ptr<BvhNode> bvhPtr;
class BvhTree
{
private:
GLuint tot;
bvhPtr root;
static QVector4D calcBound(QVector4D initBound[], int l, int r);
static QVector4D Union(QVector4D a, QVector4D b);
bvhPtr subBvhTree(QVector4D initBound[], int l, int r);
void traverseBvhTree(bvhPtr now, std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
public:
BvhTree() {
tot = 0;
@ -57,8 +62,6 @@ public:
}
// 根据底层包围盒生成bvh树
void buildBvhTree(QVector4D initBound[], int len);
bvhPtr subBvhTree(QVector4D initBound[], int l, int r);
void traverseBvhTree(bvhPtr now, std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
// 获得 Bvh rootBvh部分的 children 数组,包围盒数组 vector 传输
void getBvhArray(std::vector<GLuint>& children, std::vector<QVector4D>& bounds);
// 获得 BvhTree 中节点总数