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

Function drain_dirty

native/watchos/src/scene.rs:351–384  ·  view source on GitHub ↗

Delta-sync: emit only nodes whose dirty_flags are non-zero, and clear flags on the nodes we report. Swift calls this once per frame and applies the reported changes — static scenes get O(0) cost, moving scenes scale with the number of actually-changing nodes.

(dst: *mut SceneNodeInfo, max: i64)

Source from the content-addressed store, hash-verified

349/// applies the reported changes — static scenes get O(0) cost, moving
350/// scenes scale with the number of actually-changing nodes.
351pub fn drain_dirty(dst: *mut SceneNodeInfo, max: i64) -> i64 {
352 if dst.is_null() || max <= 0 { return 0; }
353 with(|inner| {
354 let mut written = 0i64;
355 for (i, slot) in inner.nodes.iter_mut().enumerate() {
356 if written >= max { break; }
357 let Some(n) = slot else { continue };
358 if n.dirty_flags == 0 { continue; }
359 let info = SceneNodeInfo {
360 dirty_flags: n.dirty_flags,
361 handle: i as u32,
362 parent: n.parent,
363 visible: if n.visible { 1 } else { 0 },
364 geometry_version: n.geometry_version,
365 color: n.color,
366 roughness: n.roughness,
367 metalness: n.metalness,
368 texture: n.texture,
369 has_geometry: if n.indices.is_empty() { 0 } else { 1 },
370 transform: n.transform,
371 tex_base_color: n.tex_base_color,
372 tex_normal: n.tex_normal,
373 tex_metallic_roughness: n.tex_metallic_roughness,
374 tex_emissive: n.tex_emissive,
375 tex_occlusion: n.tex_occlusion,
376 skin_version: n.skin_version,
377 };
378 unsafe { *dst.add(written as usize) = info; }
379 n.dirty_flags = 0;
380 written += 1;
381 }
382 written
383 })
384}
385
386/// Drain the list of handles destroyed since the last call. Swift pulls
387/// these and removes the matching SCNNodes from its retainedNodes map.

Callers 1

Calls 2

withFunction · 0.85
iter_mutMethod · 0.80

Tested by

no test coverage detected