Removes triangle from surface by erasing its three indices from index array.
Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), triangleIndex (triangle number, 0-based).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
meshInt
surfaceInt
triangleIndexInt
Returns
Void
Quick Summary
Removes triangle from surface by erasing its three indices from index array.
Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), triangleIndex (triangle number, 0-based).
Returns nothing.
Technical Exegesis...
Removes triangle from surface by erasing its three indices from index array. Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), triangleIndex (triangle number, 0-based). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, surface index valid, and mesh is locked. Calculates index offset: baseIndex = triangleIndex * 3 (each triangle = 3 indices). Validates baseIndex in range [0, indices.size()-2] (ensures 3 indices exist).
Removes triangle from surface by erasing its three indices from index array. Takes mesh (surface-based mesh entity), surface (surface handle, 0-based), triangleIndex (triangle number, 0-based). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, surface index valid, and mesh is locked. Calculates index offset: baseIndex = triangleIndex * 3 (each triangle = 3 indices). Validates baseIndex in range [0, indices.size()-2] (ensures 3 indices exist). Erases 3 consecutive indices starting at baseIndex from indices array. Sets mesh->needsGPUUpload=true. Silently returns on validation errors. Subsequent triangles shift down - triangle N+1 becomes triangle N after deletion.
This function removes individual triangles from procedural meshes for dynamic geometry editing. Triangle deletion modifies indices array only - vertices remain unchanged (orphaned vertices okay, just not referenced). Index offset calculation: triangle 0 uses indices [0,1,2], triangle 1 uses indices [3,4,5], triangle N uses indices [N*3, N*3+1, N*3+2]. Erasing shifts remaining elements - deleting triangle 5 causes triangle 6 to become triangle 5, triangle 7 becomes 6, etc. Triangle indices invalidated after deletion - if tracking triangle numbers, must decrement those > deleted index. Validation requires locked mesh - modification operations require lock state for safety. Use cases: (1) Mesh surgery (remove polygons from procedural geometry), (2) Culling (remove backfacing/offscreen triangles for optimization), (3) Boolean operations (subtract overlapping triangles during CSG), (4) Damage modeling (remove triangles to create holes/cracks). Orphaned vertices after deletion: vertices not referenced by any triangle remain in vertices array but don't render - waste memory, can compact with vertex welding or manual cleanup. Multiple deletions: deleting triangle indices in reverse order (highest to lowest) prevents index shift issues. Deleting in forward order requires recalculating indices after each deletion. Common workflow: b3dLockMesh(mesh), For i = triangleCount-1 To 0 Step -1 (reverse iteration), If triangle_should_delete Then b3dDeleteTriangle(mesh, surf, i), b3dUnlockMesh(mesh). GPU upload deferred until unlock - deletion fast (CPU array manipulation only). Winding order unchanged - remaining triangles keep original orientation. Deleting all triangles leaves empty surface - still valid, just not renderable. Alternative: rebuild surface from scratch (b3dClearSurface, re-add wanted triangles), create new surface and copy wanted geometry, use boolean mesh operations. Triangle count after deletion: newCount = oldCount - 1. Performance: O(N) where N = indices remaining after deleted triangle - erase operation shifts elements. Deleting many triangles: consider rebuilding surface if deleting >50% for better performance.