From 081e9a7ffbb795e27a7328b04e9088e5913e0d33 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Tue, 6 Sep 2022 22:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArchitectureColoredPainting/BvhTree.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ArchitectureColoredPainting/BvhTree.h b/ArchitectureColoredPainting/BvhTree.h index 0292602..4bc5e2e 100644 --- a/ArchitectureColoredPainting/BvhTree.h +++ b/ArchitectureColoredPainting/BvhTree.h @@ -9,13 +9,13 @@ #include #include #include -#define bvhPtr std::tr1::shared_ptr +using std::tr1::shared_ptr; // BvhTree 节点 struct BvhNode { GLuint lab; QVector4D bound; - bvhPtr child[2]; + shared_ptr 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 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& children, std::vector& 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& children, std::vector& bounds); // 获得 Bvh (rootBvh部分)的 children 数组,包围盒数组 vector 传输 void getBvhArray(std::vector& children, std::vector& bounds); // 获得 BvhTree 中节点总数