Sign in to follow this  

Carvelib CSG face normals reversed

Recommended Posts



I'm using Carvelib ( 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 ( 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this