Duplicates vertices so each triangle has its own unique set of vertices (opposite of welding).
Takes mesh (mesh entity handle).
Returns nothing. Mesh must be locked before calling.
3D Graphics
Parameters & Returns
Parameters
meshInt
Returns
void
Quick Summary
Duplicates vertices so each triangle has its own unique set of vertices (opposite of welding).
Takes mesh (mesh entity handle).
Returns nothing. Mesh must be locked before calling.
Technical Exegesis...
Duplicates vertices so each triangle has its own unique set of vertices (opposite of welding). Takes mesh (mesh entity handle). Returns nothing. Mesh must be locked before calling (use b3dLockMesh). Validates entity exists and type is ENTITY_MESH. Validates mesh is surface-based. Requires mesh to be locked (errors if not locked). For each triangle, duplicates its three vertices into new unique vertices. Updates indices to point to newly duplicated vertices (sequential: 0,1,2,3,4,5...).
Duplicates vertices so each triangle has its own unique set of vertices (opposite of welding). Takes mesh (mesh entity handle). Returns nothing. Mesh must be locked before calling (use b3dLockMesh). Validates entity exists and type is ENTITY_MESH. Validates mesh is surface-based. Requires mesh to be locked (errors if not locked). For each triangle, duplicates its three vertices into new unique vertices. Updates indices to point to newly duplicated vertices (sequential: 0,1,2,3,4,5...). Marks surfaces and mesh as needing GPU update. Prints error and returns if mesh not locked.
This function is the opposite of b3dWeldVertices. While welding merges duplicate vertices at the same position to reduce vertex count, unwelding splits them back apart so each triangle has unique vertices. Essential for: (1) Flat shading after welding (welded vertices share normals which breaks flat shading), (2) Per-triangle normal calculation (each triangle needs its own normals for hard edges), (3) Undoing welding when you need vertex independence, (4) Preparing mesh for flat lighting (architectural geometry, low-poly art).
Important notes: Significantly increases vertex count (each triangle gets 3 unique vertices). For N triangles, creates 3*N vertices. Useful after welding when you discover flat shading is broken. Not needed for already-correct geometry (wastes memory/performance). Weld→Unweld cycle on flat shapes is pointless in practice (just keeps original count). Only use if you need to fix welding damage on flat shapes.
When to use: After b3dWeldVertices broke flat shading on hard-edged geometry. When you need guaranteed vertex independence per triangle. For procedural geometry generation requiring per-face data. When to avoid: On smooth shapes (spheres, organic models - welding is good here). On already-correct flat geometry (cube primitives already have unique verts). When memory/performance is critical (triples vertex count).
Performance: O(n) iteration over triangles. Creates new vertex array with size = triangle_count * 3. Does not trigger GPU operations (deferred until unlock/render). Mesh must be surface-based (not primitive-based). Compare to b3dWeldVertices: Welding merges vertices → reduces count → enables smooth shading. Unwelding splits vertices → increases count → enables flat shading.
Example
Example.bam
; Create a subdivided sphere with duplicate verticesLocal sphere:Int = b3dCreateSphere(1, 0, 0, 16)
b3dLockMesh(sphere)
b3dSubdivideMesh(sphere, 2, 1, 0.5) ; Creates duplicates
; Count before weldingLocal beforeWeld:Int = b3dCountVertices(sphere, 0)
Print("Before weld: " + ToString(beforeWeld) + " vertices")
; Weld to merge duplicates (good for smooth shapes)
b3dWeldVertices(sphere, 0.01)
Local afterWeld:Int = b3dCountVertices(sphere, 0)
Print("After weld: " + ToString(afterWeld) + " vertices")
; If we wanted flat shading instead (unusual for sphere):
b3dUnweldVertices(sphere) ; Split back
b3dUpdateNormalsFlat(sphere) ; Calculate flat normals
Local afterUnweld:Int = b3dCountVertices(sphere, 0)
Print("After unweld: " + ToString(afterUnweld) + " vertices")
b3dUnlockMesh(sphere)
; Result: Sphere now has faceted/low-poly appearance