MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_scene_attach_model

Function bloom_scene_attach_model

native/macos/src/lib.rs:2905–2947  ·  view source on GitHub ↗
(node_handle: f64, model_handle: f64, mesh_index: f64)

Source from the content-addressed store, hash-verified

2903/// Copies the vertex/index data from the model into the scene node.
2904#[no_mangle]
2905pub extern "C" fn bloom_scene_attach_model(node_handle: f64, model_handle: f64, mesh_index: f64) {
2906 let eng = engine();
2907 let mi = mesh_index as usize;
2908
2909 // Get model mesh data
2910 let model_data = match eng.models.models.get(model_handle) {
2911 Some(md) => md,
2912 None => return,
2913 };
2914 if mi >= model_data.meshes.len() { return; }
2915 let mesh = &model_data.meshes[mi];
2916
2917 // Copy vertices and indices to scene node
2918 let vertices = mesh.vertices.clone();
2919 let indices = mesh.indices.clone();
2920 let base_color_tex = mesh.texture_idx;
2921 let normal_tex = mesh.normal_texture_idx;
2922 let mr_tex = mesh.metallic_roughness_texture_idx;
2923 let emissive_tex = mesh.emissive_texture_idx;
2924 let emissive_factor = mesh.emissive_factor;
2925 eng.scene.update_geometry(node_handle, vertices, indices);
2926
2927 // Pipe PBR textures through to the scene node material so the
2928 // renderer's scene pipeline can sample them.
2929 if let Some(tex_idx) = base_color_tex {
2930 eng.scene.set_material_texture(node_handle, tex_idx);
2931 }
2932 if let Some(tex_idx) = normal_tex {
2933 eng.scene.set_material_normal_texture(node_handle, tex_idx);
2934 }
2935 if let Some(tex_idx) = mr_tex {
2936 eng.scene.set_material_metallic_roughness_texture(node_handle, tex_idx);
2937 }
2938 if let Some(tex_idx) = emissive_tex {
2939 eng.scene.set_material_emissive_texture(node_handle, tex_idx);
2940 }
2941 eng.scene.set_material_emissive_factor(
2942 node_handle,
2943 emissive_factor[0],
2944 emissive_factor[1],
2945 emissive_factor[2],
2946 );
2947}
2948
2949// ============================================================
2950// Thread-safe staging (for async asset loading via Perry threads)

Callers

nothing calls this directly

Calls 9

cloneMethod · 0.80
update_geometryMethod · 0.80
set_material_textureMethod · 0.80
engineFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected