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

  • 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.