修改了Boud的计算方式

dev-VirtualTexture
yang.yongquan 2022-08-07 23:38:35 +08:00
parent 82e2d51855
commit 5e4a893af1
1 changed files with 3 additions and 3 deletions

View File

@ -20,7 +20,7 @@ QVector4D BvhTree::Union(QVector4D a, QVector4D b) {
QVector4D BvhTree::calcBound(QVector4D initBound[], int l, int r) { QVector4D BvhTree::calcBound(QVector4D initBound[], int l, int r) {
QVector4D res = initBound[l]; QVector4D res = initBound[l];
for (int i = l + 1; i < r; i++) { for (int i = l + 1; i <= r; i++) {
res = Union(res, initBound[i]); res = Union(res, initBound[i]);
} }
return res; return res;
@ -34,9 +34,9 @@ bvhPtr BvhTree::subBvhTree(QVector4D initBound[], int l, int r) {
if (l == r) return p; if (l == r) return p;
int dim = p.get()->maximumBound(); int dim = p.get()->maximumBound();
if (dim == 0) { if (dim == 0) {
std::sort(initBound + l, initBound + r, BvhNode::x_compare); std::sort(initBound + l, initBound + r+1, BvhNode::x_compare);
} else { } else {
std::sort(initBound + l, initBound + r, BvhNode::y_compare); std::sort(initBound + l, initBound + r+1, BvhNode::y_compare);
} }
int mid = (l + r) >> 1; int mid = (l + r) >> 1;
p.get()->child[0] = subBvhTree(initBound, l, mid); p.get()->child[0] = subBvhTree(initBound, l, mid);