Jump to content
  • Advertisement
Sign in to follow this  
DavidBurns

Carvelib CSG face normals reversed

This topic is 1472 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. 

 

I'm using Carvelib (https://code.google.com/p/carve/) to perform some boolean operations on some cubes (actually rectangular prisms). I've wrapped the lib in c#, triangular tessellation is done using Triangle.NET (triangle.codeplex.com/) for each face, and display uses ModelVisual3D in a WPF viewport.

 

There is a problem with my test case where a number of intersecting cubes form a union and have coincident vertices. This causes some faces to flip inside-out. If I offset the cubes (size 10x3x3) by 1E-7 (or larger), then the problem doesn't occur (but I'll then have a hole in my "solid" geometry). Does anyone know why this is happening? Does carvelib have issues with coincident vertices?

 

The attached images are the union of incident cubes (looks good, but will have the hole in the middle), and when offset (some faces appear to be missing, but they're just inside-out and therefore transparent from the viewing direction).

 

The code to create the cubes is below (it has the offset translation present). Basically it just places 8 cubes, each rotated 45 degrees more than the last, in a union.

public static Shape testShape()
{
    Shape myCube = translate(cube(3, 3, 10), 1E-7, 0, 0);  // the translation value here is to stop vertices matching exactly
    return union(
        ForEach(range(0, 45, 7*45),
            ang => rotate(myCube, ang, 0, 1, 0)
        ));
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!