csgjs-cpp icon indicating copy to clipboard operation
csgjs-cpp copied to clipboard

stuck in infinite loop

Open marc40000 opened this issue 8 years ago • 0 comments

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.

marc40000 avatar Mar 02 '17 10:03 marc40000