• 3D
  • "Cannot get CSGBrush" error

Just to check whether this is a bug or me doing something stupid:

I have a CSG shape which is periodically made to vanish by a script setting its visible property false. This works, but generates an error:

E 0:00:02.185   _update_shape: Cannot get CSGBrush.
  <C++ Error>   Condition "!n" is true.
  <C++ Source>  modules/csg/csg_shape.cpp:280 @ _update_shape()

If the shape is a CSGContainer containing the actual geometry, the error happens with every visible = false, otherwise just once on the first call.

From what I can tell after poking around in the source a bit on GitHub, it looks like the issue is caused by the _get_brush function. The error in particular is triggered when the CSG mesh updates, and the _get_brush function returns null when the brush is not visible and there are no other CSG children, from what I can gather. Does the node parent of the CSG node that is turned invisible only have a single child? From what I can tell looking at the code, that might be causing it (not sure if its a bug or not though).

@TwistedTwigleg said: [ ... ] Does the node parent of the CSG node that is turned invisible only have a single child? From what I can tell looking at the code, that might be causing it (not sure if its a bug or not though).

Hm. Played around with this idea a bit, and it's complicated. Looks more like it's siblings that matter: I get the error making a CSGCombiner parent of two children invisible, or the only child of a CSGCombiner, or one of two CSG objects with no explicit CSGCombiner parent, but not when it's one of two children of a CSGCombiner.

If I'm not doing anything obviously wrong, I'll report it as a bug.

@sarrowsmith said: If I'm not doing anything obviously wrong, I'll report it as a bug.

And today's lesson is: if you think it's a bug, the first thing to do is check the issue tracker, in case it's already been reported. There's a bunch of items in this area, at least one change in 3.2.4, and a couple of open pull requests. So I'll hold off that report for now (and implement a work-around in my project).