Locks mesh for editing (enables vertex/triangle modification operations). Takes mesh (surface-based mesh entity). Returns nothing. Validates mesh exists, type is ENTITY_MESH, and is surface-based. Sets mesh->locked=true. Silently returns on validation errors.
This function enables mesh editing mode for procedural geometry manipulation. Lock/unlock pattern: b3dLockMesh -> modify vertices/triangles -> b3dUnlockMesh. Locked state prevents GPU buffer access (CPU-side editing only).
Locks mesh for editing (enables vertex/triangle modification operations). Takes mesh (surface-based mesh entity). Returns nothing. Validates mesh exists, type is ENTITY_MESH, and is surface-based. Sets mesh->locked=true. Silently returns on validation errors.
This function enables mesh editing mode for procedural geometry manipulation. Lock/unlock pattern: b3dLockMesh -> modify vertices/triangles -> b3dUnlockMesh. Locked state prevents GPU buffer access (CPU-side editing only). Locking required for: b3dAddVertex, b3dAddTriangle, b3dDeleteTriangle, b3dDeleteVertex, b3dVertexCoords, b3dVertexNormal, b3dVertexTexCoords, b3dVertexColor, b3dClearSurface (some functions validate locked state). Lock does not: allocate memory, copy data, block rendering (mesh still renders with existing GPU buffers until unlock rebuilds). Use cases: (1) Before procedural mesh building, (2) Before vertex animation, (3) Before mesh editing, (4) Before topology changes. Common pattern: mesh=b3dCreateMesh(...), b3dLockMesh(mesh), surf=b3dCreateSurface(mesh), add vertices/triangles, b3dUpdateNormals(mesh), b3dUnlockMesh(mesh). Multiple locks: calling b3dLockMesh multiple times harmless (sets locked=true repeatedly), but unlock must be called to apply changes. Mesh state: newly created mesh (b3dCreateMesh) starts unlocked - must lock before editing. Alternative: some functions don't require lock (b3dCreateSurface, b3dCountVertices, b3dVertexX/Y/Z queries), but modification functions do. Performance: lock itself is O(1) flag set, no expensive operations. GPU synchronization: lock doesn't touch GPU - only b3dUnlockMesh uploads changes. Nested editing: single lock suffices for multiple editing operations - unlock once at end. Error handling: if modify operations fail silently, check mesh is locked. Lock duration: keep locked during entire editing session, unlock when done to trigger GPU upload. Loaded meshes: b3dLoadMesh meshes are NOT surface-based (can't lock) - use b3dCopyMesh to convert to editable surface-based mesh if needed.