|
|
@ -346,6 +346,19 @@ void build(const Scene& scene, const Node& node, std::vector<Node> leaves) |
|
|
|
} |
|
|
|
|
|
|
|
if (any(mark == uvector3(2, 2, 2))) { |
|
|
|
if (all(mark == uvector3(2, 2, 2))) { |
|
|
|
// fully containing cases
|
|
|
|
for (int i = 0; i < CHILD_NUM; ++i) { |
|
|
|
tensor3 subPoly(nullptr, poly.ext()); |
|
|
|
bernstein::deCasteljau(poly, subNodes[i].min, subNodes[i].max, subPoly); |
|
|
|
if (bernstein::uniformSign(subPoly) == -1) { |
|
|
|
subNodes[i].polyFullyContainedIndices.emplace_back(polyIntersectIndex); |
|
|
|
} else { |
|
|
|
subNodes[i].polyIntersectIndices.emplace_back(polyIntersectIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
for (int subIdx = 0; subIdx < CHILD_NUM; ++subIdx) { |
|
|
|
// intermediateNodes[lastIdx + subIdx].polyIntersectIndices.emplace_back(poly);
|
|
|
|
// intermediateNodes[lastIdx + subIdx].min = nowNodeMin;
|
|
|
@ -357,6 +370,8 @@ void build(const Scene& scene, const Node& node, std::vector<Node> leaves) |
|
|
|
int zeroCount = numOfZero<3>(mark); |
|
|
|
if (zeroCount == 0) { |
|
|
|
// mark has -1 or 1 only
|
|
|
|
real nodeMidVal = bernstein::evalBernsteinPoly(poly, nodeMid); |
|
|
|
if (mark(0) == 2 && mark(1) == 1 && mark(2) == 1) {} |
|
|
|
subNodes[binaryToDecimal(mark, -1)].polyIntersectIndices.emplace_back(polyIntersectIndex); |
|
|
|
} else if (zeroCount == 1) { |
|
|
|
// poly related to 2 subcells
|
|
|
@ -371,7 +386,14 @@ void build(const Scene& scene, const Node& node, std::vector<Node> leaves) |
|
|
|
} |
|
|
|
} |
|
|
|
// launch subdivision in subcells
|
|
|
|
for (subIdx = 0; subIdx < CHILD_NUM; ++subIdx) { build(scene, subNodes[subIdx], leaves); } |
|
|
|
for (subIdx = 0; subIdx < CHILD_NUM; ++subIdx) { |
|
|
|
subNodes[subIdx].polyFullyContainedIndices.resize(subNodes[subIdx].polyFullyContainedIndices.size() |
|
|
|
+ node.polyFullyContainedIndices.size()); |
|
|
|
subNodes[subIdx].polyFullyContainedIndices.insert(subNodes[subIdx].polyFullyContainedIndices.end(), |
|
|
|
node.polyFullyContainedIndices.begin(), |
|
|
|
node.polyFullyContainedIndices.end()); |
|
|
|
build(scene, subNodes[subIdx], leaves); |
|
|
|
} |
|
|
|
// TODO: 考虑fully contain 问题
|
|
|
|
} |
|
|
|
}; // namespace algoim::Organizer
|
|
|
|