Skip to content

Commit

Permalink
Work around evaluator disagreements
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Oct 22, 2017
1 parent eb6c22c commit 5f89d8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ao/src/render/brep/xtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,15 @@ XTree<N>::XTree(XTreeEvaluator* eval, Region<N> region,

for (unsigned e=0; e < target_count; ++e)
{
for (unsigned j=0; j < POINTS_PER_SEARCH; ++j)
// Skip one point, because the very first point is
// already known to be inside the shape (but sometimes,
// due to numerical issues, it registers as outside!)
for (unsigned j=1; j < POINTS_PER_SEARCH; ++j)
{
const unsigned i = j + e*POINTS_PER_SEARCH;
if (out[i] > 0)
{
assert(i > 0);
targets[e] = {ps.col(i - 1), ps.col(i)};
break;
}
Expand All @@ -410,10 +414,19 @@ XTree<N>::XTree(XTreeEvaluator* eval, Region<N> region,
if (!eval->feature.isInside(
pos.template cast<float>()))
{
assert(i > 0);
targets[e] = {ps.col(i - 1), ps.col(i)};
break;
}
}
// Special-case for final point in the search, working
// around numerical issues where different evaluators
// disagree with whether points are inside or outside.
else if (j == POINTS_PER_SEARCH - 1)
{
targets[e] = {ps.col(i - 1), ps.col(i)};
break;
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions ao/test/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ TEST_CASE("Mesh::render (face count in rectangular prism)")
REQUIRE(m->verts.size() == 9); // index 0 is unused
REQUIRE(m->branes.size() == 12);
}

TEST_CASE("Mesh::render (sphere)")
{
auto s = sphere(1);
auto m = Mesh::render(s, Region<3>({-1.6, -1, -8}, {1.6, 1, 1}),
1/32.0f, pow(10, -3));
REQUIRE(true);
}

0 comments on commit 5f89d8a

Please sign in to comment.