miho / JCSG

Java implementation of BSP based CSG (Constructive Solid Geometry)
Other
177 stars 52 forks source link

Pyramids with top radius of 0 cause any shape to be differenced to fail #25

Closed madhephaestus closed 7 years ago

madhephaestus commented 8 years ago

If you create a pyramid by making a cylinder with a radius of zero, then triangulation function fails when doing a difference operation between this object and any other.

CSG torso = new Cylinder( 30, // Radius at the bottom 0, // Radius at the top 60, // Height (int)4 //resolution ).toCSG()//convert to CSG to display

CSG cover = new Cube( 200,// X dimention 200,// Y dimention 200// Z dimention ).toCSG()

Both of these shapes are valid.

This operation however will fail:

cover.difference(torso);

Changing the top radius to a small number is a hack to fix this issue:

CSG torso = new Cylinder( 30, // Radius at the bottom 0.001, // Radius at the top 60, // Height (int)4 //resolution ).toCSG()//convert to CSG to display

This bug is related to #15 in that it originates in the triangulation function falling off the front surface and ending up inverting the surfaces.

miho commented 7 years ago

Sorry, but we don't want hacky ;) The problem is that your pyramid will still be a cylinder/truncated-cone with a very small top polygon. Rather than that, I'd introduce a primitive class that creates proper pyramids.

madhephaestus commented 7 years ago

I agree. I think #15 is the deeper root cause though, and if that were solved, this issue may never have manifested?

(on a side note, I'd love to have a video call to show you some cool things I'v done with your awesome library!)