Skip to content

Commit

Permalink
fixed crash; fixed triangulation of invalid polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Aug 27, 2023
1 parent ccceff4 commit 756d9b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ofbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ float DataView::toFloat() const

bool DataView::operator==(const char* rhs) const
{
if (!begin) return false;
const char* c = rhs;
const char* c2 = (const char*)begin;
while (*c && c2 != (const char*)end)
Expand Down Expand Up @@ -2228,6 +2229,15 @@ static void triangulate(
++in_polygon_idx;
if (old_indices[i] < 0)
{
if (in_polygon_idx <= 2) {
// invalid polygon, let's pop it
to_old_vertices->pop_back();
to_old_indices->pop_back();
if (in_polygon_idx == 2) {
to_old_vertices->pop_back();
to_old_indices->pop_back();
}
}
in_polygon_idx = 0;
}
}
Expand Down

0 comments on commit 756d9b2

Please sign in to comment.