Skip to content

Use merged child meshes for more reliable CSG operations#288

Open
tracygardner wants to merge 21 commits intomainfrom
codex/combine-child-meshes-for-csg-operations
Open

Use merged child meshes for more reliable CSG operations#288
tracygardner wants to merge 21 commits intomainfrom
codex/combine-child-meshes-for-csg-operations

Conversation

@tracygardner
Copy link
Contributor

Motivation

  • CSG operations frequently fail on composite GLTF/GLB nodes that have no geometry on the parent but multiple children with geometry. The change aims to reliably prepare those meshes for CSG.
  • Temporary merged meshes should be tracked and cleaned up so they don't pollute the scene or leak memory.
  • Ensure result meshes inherit appropriate material/transform information from a meaningful reference mesh when children carry materials.

Description

  • Enhanced prepareMeshForCSG to merge child meshes into a single temporary mesh for CSG use and tag it with metadata.csgPrepared and metadata.csgSourceName.
  • Updated mergeMeshes, intersectMeshes, createHull, subtractMeshes, subtractMeshesMerge, and subtractMeshesIndividual to use prepareMeshForCSG for inputs, to select a material-bearing referenceMesh (via flock._findFirstDescendantWithMaterial) and to collect tempMeshes created for CSG.
  • Added explicit disposal of temporary prepared meshes (tempMeshes) and conditional disposal of prepared source meshes (metadata.csgPrepared) after CSG operations complete or fail.
  • Preserved original behaviour for applying transforms/materials by using a proper referenceMesh and copying properties via applyResultMeshProperties while avoiding leaking cloned prep meshes.

Testing

  • No automated tests were run for this change.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant