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

Method draw_model_cached

native/shared/src/renderer/mod.rs:12343–12376  ·  view source on GitHub ↗

Record a cached model draw command. The actual rendering happens in end_frame().

(&mut self, handle_bits: u64, position: [f32; 3], scale: f32, tint: [f32; 4])

Source from the content-addressed store, hash-verified

12341
12342 /// Record a cached model draw command. The actual rendering happens in end_frame().
12343 pub fn draw_model_cached(&mut self, handle_bits: u64, position: [f32; 3], scale: f32, tint: [f32; 4]) {
12344 let mesh_count = match self.model_gpu_cache.get(&handle_bits) {
12345 Some(Some(meshes)) => meshes.len(),
12346 _ => return,
12347 };
12348
12349 for mesh_idx in 0..mesh_count {
12350 let slot = self.next_model_uniform_slot;
12351 self.next_model_uniform_slot += 1;
12352
12353 // Grow uniform pool if needed
12354 self.ensure_model_uniform_slot(slot);
12355
12356 // Compute model MVP: VP * translate(position) * scale(s)
12357 let model_matrix = mat4_multiply(
12358 mat4_translate(IDENTITY_MAT4, position),
12359 mat4_scale(IDENTITY_MAT4, [scale, scale, scale]),
12360 );
12361 let model_mvp = mat4_multiply(self.current_vp_matrix, model_matrix);
12362
12363 // Write uniform for this draw
12364 self.queue.write_buffer(
12365 &self.model_uniform_buffers[slot],
12366 0,
12367 bytemuck::bytes_of(&Uniforms3D { mvp: model_mvp, model: model_matrix, prev_mvp: model_mvp, model_tint: tint }),
12368 );
12369
12370 self.model_draw_commands.push(CachedModelDraw {
12371 uniform_slot: slot,
12372 cache_handle: handle_bits,
12373 mesh_idx,
12374 });
12375 }
12376 }
12377
12378 fn ensure_model_uniform_slot(&mut self, slot: usize) {
12379 while self.model_uniform_buffers.len() <= slot {

Callers 7

bloom_draw_modelFunction · 0.80
bloom_draw_modelFunction · 0.80
bloom_draw_modelFunction · 0.80
bloom_draw_modelFunction · 0.80
bloom_draw_modelFunction · 0.80
bloom_draw_modelFunction · 0.80
bloom_draw_modelFunction · 0.80

Calls 6

mat4_multiplyFunction · 0.85
mat4_translateFunction · 0.85
mat4_scaleFunction · 0.85
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected