Skip to content

stuck in infinite loop #3

@marc40000

Description

@marc40000

Hi !

I experienced csgjs to get stuck in build trying to split one polygon against itself over and over because the coplanar test fails in splitPolygon() because of precision issues. I was able to enhance it by making epsilon larger. But what solved it for me was not trying to split the polygon against itself at all. So in csgjs_csgnode::build() I replaced

	for (size_t i = 1; i < list.size(); i++)
		me->plane.splitPolygon(list[i], me->polygons, me->polygons, list_front, list_back);

with

	me->polygons.push_back(list[0]);
	for (size_t i = 1; i < list.size(); i++)
		me->plane.splitPolygon(list[i], me->polygons, me->polygons, list_front, list_back);

splitPolygons() would theoretically add the polygon list[0] to me->polygons if there weren't precision errors. So I just do this upfront and start with i = 1. I'm not sure if this breaks somethign else but it still looks good to me and I don't get these infinite loops.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions