CSG returned error code -8

Reproduction Steps
System Information:
CPU: i7-4790k @ 4.2GHz
GPU: NVIDIA GeForce GTX 1080 8GB
RAM: 16GB
OS: Windows 10 Home

Beta Features:
All beta features including CSG Version 3 are enabled except the TerrainTools:ConvertTool Beta.

Reproduction Files:
Attached privately to this bug report.

Expected Behavior
I expect the union operation to succeed.

Actual Behavior
The union operation fails with the following error code:
image

Workaround
Disabling the CSG Version 3 Beta solves this issue, however, using CSG Version 2 makes the union look nothing like it should.

Before using CSG Version 2:
image

After using CSG Version 2:
image

Issue Area: Studio
Issue Type: Other
Impact: Moderate
Frequency: Constantly
Date First Experienced: 2021-10-01 00:10:00 (-04:00)
Date Last Experienced: 2021-10-01 00:10:00 (-04:00)
A private message is associated with this bug report

4 Likes

Hey, thanks for the report! I can’t repro the issue on my side, can you provide a repro file where you first saw the issue?

Hi,

I just opened a fresh baseplate, inserted the file I privately attached to this bug report, and was able to replicate the error again.

Did you attempt to union all 211 parts inside the model, provided with this bug report, together with CSG Version 3 enabled? I am able to replicate this error 100% of the time on my end under the conditions I described.

image

Quick update: I have reproduced the issue and found the root cause.
The problem is that the mesh resulting from the union has too many triangles, even after simplification. In V2, we have an aggressive simplification method that gets us below the limit but at the expense of quality. In V3, we rather decided to give you that cryptic message (I will look into changing that to something that is more meaningful for developers).
Saying that, I am looking into finding why this model can’t be simplified under the limit. My first impression is that we should be able to. I will update this report when I will know more.

6 Likes

@r_r Studio’s last release (503) includes a partial fix for that.
I have improved the way we can simplify the end result and this results in a lower number of triangles for this example. Unfortunately it’s still not enough. The root cause is that each frame is composed of 4 boxes that should align perfectly at the corners. However due to numerical noise in the positions and rotations, it’s not the case. This creates small geometric details that we can’t simplify. I have experimented with clamping the coordinates of the boxes and was able to get a way better result for one frame. I will investigate whether we could do that automatically in our end (the numerical differences we’re talking in that case are so small it’s obvious they’re not desired but it might get more complex in other cases). In the meantime, either union less frames together or make sure the boxes in each frame are perfectly positioned. Don’t hesitate to contact me if you need more details.
Thanks again for reporting this issue.

3 Likes

Heya, I am using CSG Version 3 and I am getting the same error code, trying to union large scale unions.

Hi, could you send me the model? Happy to have a look and find out why we can’t simplify it under 20k. Does it work with CSG V2?

As explained by @Tconnect, the issue is that the CSG result cannot be simplified further while keeping the model’s features. The simplification step is needed to comply with the 20k triangle limit.
In the future, we may increase the 20k limit and modify our simplification algorithm. Such improvements may resolve the above issue. However, we may develop another example that goes beyond the triangle limits again. It is rooted in the challenge of simplifying a triangle mesh comprised of disjoint bodies. It is hard to decrease the number of triangles while keeping the visual fidelity high. So, keeping the disjointed bodies in a model instead of unioning them avoids the above issue.