@Sean seeing something surprising and could use your insight. When working with meshing in Goliath, I was seeing dark meshes that appear to be due to the faces being flipped. After a lot of digging, I boiled down a case independent of the meshing itself: http://brlcad.org/~starseeker/oflip.g
What I'm seeing - both of these combs are using the same BoT solid, and placing it in different locations via matrices. One of them shows the correct orientation in space, but the other is inside out. The only thing I can figure is that the matrix is turning the mesh inside out when its being read in during the tree walk, but a) should it be able to do that at all and b) if that's OK, shouldn't we be detecting it somehow and flipping the orientation flag for the internal representation?
The value that turns it inside out is element 5 (counting from 0-15) in the matrix (-1 is inside out vs 1 being normal)
@starseeker That sounds like a reflection matrix.
I'm guessing introduced by the mirror command or some similar procedure.
I do believe the ray tracing path handles it correctly already just because there's a bit of code both in the boolean evaluator and in the ray tracer that detects when normals are going the wrong way and they get flipped on the fly.
For facetization, though, that is a conundrum. I would probably expect the tree walking code to detect it -- since that's where the matrix is defined and applied. NOT flipping the orientation flag as the primitive itself is not flipped, only the instance via comb.
That's more or less what I ended up doing - at least for the Goliath test case, I did get facetize to work. However, there is an issue with that matrix and BoT primitives for raytracing - IIRC the CSG version of that comb does raytrace, but replacing it with a BoT geometry it vanishes.
https://github.com/BRL-CAD/brlcad/commit/38c20325acac1e4192199b63866e9ad0d4a2b564 commit comment has more details on which part of Goliath in what configurations triggers the issue.
starseeker said:
https://github.com/BRL-CAD/brlcad/commit/38c20325acac1e4192199b63866e9ad0d4a2b564 commit comment has more details on which part of Goliath in what configurations triggers the issue.
Last updated: Jan 09 2025 at 00:46 UTC