Skip to content

Commit 07978ef

Browse files
panquezBotellaA
authored andcommitted
fix(Rasterize): manage flat triangles
1 parent 677e8ce commit 07978ef

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/geode/mesh/helpers/rasterize.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ namespace
331331
std::vector< geode::GridCellIndices3D > cells;
332332
cells.reserve( max_number_cells( min, max ) );
333333
const auto triangle_edges = get_triangle_edges( triangle );
334-
if( geode::triangle_area( triangle ) < geode::global_epsilon )
334+
const auto normal = triangle.new_normal();
335+
if( !normal )
335336
{
336337
for( const auto e : geode::LRange{ 3 } )
337338
{
@@ -340,14 +341,14 @@ namespace
340341
}
341342
return cells;
342343
}
343-
const auto normal = triangle.normal();
344-
const auto critical_point = compute_critical_point( grid, normal );
344+
const auto critical_point =
345+
compute_critical_point( grid, normal.value() );
345346
const auto xy_params = get_edge_projection( grid, triangle,
346-
triangle_edges, { 0, 1 }, ( normal.value( 2 ) >= 0 ? 1 : -1 ) );
347+
triangle_edges, { 0, 1 }, ( normal->value( 2 ) >= 0 ? 1 : -1 ) );
347348
const auto yz_params = get_edge_projection( grid, triangle,
348-
triangle_edges, { 1, 2 }, ( normal.value( 0 ) >= 0 ? 1 : -1 ) );
349+
triangle_edges, { 1, 2 }, ( normal->value( 0 ) >= 0 ? 1 : -1 ) );
349350
const auto zx_params = get_edge_projection( grid, triangle,
350-
triangle_edges, { 2, 0 }, ( normal.value( 1 ) >= 0 ? 1 : -1 ) );
351+
triangle_edges, { 2, 0 }, ( normal->value( 1 ) >= 0 ? 1 : -1 ) );
351352

352353
for( const auto k : geode::Range( min[2], max[2] + 1 ) )
353354
{

0 commit comments

Comments
 (0)