natiny_mesh_reload
C
int natiny_mesh_reload(NatinyMesh mesh, NatinyResource mesh_resource);
Replaces the geometry inside an existing mesh. The handle does not change.
Parameters
| Name |
Type |
Description |
mesh |
NatinyMesh |
Live mesh handle from natiny_mesh_load |
mesh_resource |
NatinyResource |
Resource handle containing a glTF or GLB model |
Returns
| Type |
Description |
int |
1 on success, 0 on failure |
Example
C
NatinyMesh mesh = natiny_mesh_load(resource);
natiny_model_set_mesh(model, mesh);
NatinyResource replacement = natiny_resource_load("models/tree.glb");
/* The model keeps its place in the scene and shows the new shape. */
if (!natiny_mesh_reload(mesh, replacement)) {
/* The mesh still contains its previous geometry. */
}
natiny_resource_destroy(replacement);
Notes
- Every model built on this mesh keeps its transform, its material and its
place in the scene, and shows the new shape.
- Whether the mesh is dynamic is a decision the program made, not something
the file says; a reload does not take it back.
- Per-part overrides set with
natiny_model_set_part_material and
natiny_model_set_part_texture are indexed by
part. They survive a reload that keeps the part count and are dropped by one
that changes it, because the indices would otherwise name different parts.
- Returns
0 if mesh is not live or the resource cannot be loaded as glTF
2.0. A failure leaves the mesh exactly as it was.
- The resource data is copied during the call and may be destroyed after a
successful reload.