Introducing: CSG2

I saw some uv related code in the pr, so does it mean that CSG2 added uv remapping on top of Manifold, and meshes with uv mappings would work correctly after booleans?

2 Likes

Yes:)

6 Likes

It seems every toMesh call makes a new material here. Is it possible to make an option that makes toMesh reuse existing material, instead of making new one every time? Maybe a material: BABYLON.Material | BABYLON.MultiMaterial | undefined option

WoW. Kudos to you :clap:. After all this time, I didn’t think anyone would have the ‘guts’ :mechanical_arm:to dig into this ‘blackhole’ :new_moon:… and then, come up with this :stuck_out_tongue: :heart_eyes: This is not an evolution, it’s a R-evolution. Pure force unleashed. Watch as X is coming :joy: It’s gonna strike hard :stuck_out_tongue_closed_eyes:

ToMesh only creates a new material if it mixes different meshes with different materials. In that case it produce a new multi material

I think it’s so nice :star_struck: !


Sorry but I had to STRESS TEST this boolean with my Dude Walking on Snow :joy:


Here is the playground using this new CSG2

I had several issues :

Whatever, cool stuff ! :sunglasses:

2 Likes

RTFM? :slight_smile:

Walking on Snow V3 (HARD boolean) | Babylon.js Playground

await BABYLON.InitializeCSG2Async();
4 Likes

Works but:

Yeah this is really brute force lol. The mesh gets more complex until it becomes unusable

1 Like

Try this: https://playground.babylonjs.com/?snapshot=refs/pull/15713/merge#IW43EB#24

3 Likes

Your skills are commendable trooper, but remember, discretion is as vital as strength. You serve the Sith, not your own ego. Do not let your triumphs overshadow our mission or draw the ire of the Overlord. Next time, tread more carefully!

:rofl: :rofl: :rofl:

Ok, jokes aside, amazing optimization! :smiling_face_with_three_hearts:

3 Likes

I attempted to update my old CSG sample to use the new CSG2. However, it seems that something is not working correctly. I would appreciate any advice.

CSG sample:

CSG2 sample:

So the only possible case is that all meshes in operations share the exactly same material, if not, a new material would be created every time toMesh being called. Should there be a way if user knows what materials in use and want to reuse the material?

Also, I saw usages of uniqueId of material, and there seems to be a limit of 65536, but uniqueId is globally generated, a scene is very unlikely to have more than 65535 materials, but could have more than 65535 of all sums of meshes, instances, transformnodes, textures, what could happen in this case?

1 Like

:joy: :joy: :joy:

1 Like

Assign materials to the boxes as well.

5 Likes

Thank you very much for your very helpful advice.

2 Likes

So for 65536: this is the range I’m reserving inside CSG2 not the other way around :slight_smile:
For the material here is the PR:
Allow user to specify material for csg2 by deltakosh · Pull Request #15731 · BabylonJS/Babylon.js

3 Likes

Does this mean if I have meshes which material has a uniqueId greater than 65535, nothing would break if I put it into CSG2?

Yes: Babylon.js Playground

3 Likes

A nice optimisation would be to split the ground into separate meshes into grid of certain size, so that number of vertices for boolean does not just grow indefinitely.

this complicates it a bit, as you may have 1,2,3,4 meshes that need to be used to do the boolean, depending if steps bounding box is inside single cell, or on intersection of multiple cells.

1 Like