perf(scene): keep draw_depth_map warm across move/edit (phase 5)
draw_depth_map rebuilt on every geometry_epoch bump — an O(document) walk (all objects for SortEntitiesTable, all entities grouped-by-block and ranked), ~45ms per edit on a 788k-entity drawing, and it runs on every viewport snapshot. But draw order depends only on each block`s entity COUNT (the rank denominator), the entities` handles, and the SortEntitiesTable — none of which a Modify (move / rotate / scale / colour / hide) changes (owner and type are preserved, and the map ignores visibility). Gate the cache on the journal: an all-Modified edit keeps the map; only Add / Remove (count change) or a table change (a `full` delta) rebuilds it. So the common move/edit now skips the walk entirely. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
95ef3b3890
commit
f12100d783
1 changed files with 24 additions and 4 deletions
|
|
@ -2976,11 +2976,31 @@ impl Scene {
|
||||||
/// entities of different types order correctly against each other.
|
/// entities of different types order correctly against each other.
|
||||||
pub(super) fn draw_depth_map(&self) -> Arc<HashMap<u64, f32>> {
|
pub(super) fn draw_depth_map(&self) -> Arc<HashMap<u64, f32>> {
|
||||||
{
|
{
|
||||||
|
// Draw order depends on each block's entity COUNT (the rank
|
||||||
|
// denominator) and the entities' handles / SortEntitiesTable — none of
|
||||||
|
// which a Modify (move / rotate / scale / colour / hide) touches. So an
|
||||||
|
// all-Modified edit keeps the map; only Add / Remove (count change) or
|
||||||
|
// a table change (which arrives as a `full` delta) rebuilds it.
|
||||||
|
let reuse = {
|
||||||
let cache = self.draw_depth_cache.borrow();
|
let cache = self.draw_depth_cache.borrow();
|
||||||
if let Some((epoch, ref arc)) = *cache {
|
match *cache {
|
||||||
if epoch == self.geometry_epoch {
|
Some((epoch, ref arc))
|
||||||
return Arc::clone(arc);
|
if epoch == self.geometry_epoch
|
||||||
|
|| matches!(
|
||||||
|
self.replay_since(epoch),
|
||||||
|
Some(ref d) if d.iter().all(|&(_, k)| k == ChangeKind::Modified)
|
||||||
|
) =>
|
||||||
|
{
|
||||||
|
Some(Arc::clone(arc))
|
||||||
}
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(arc) = reuse {
|
||||||
|
if let Some((ref mut e, _)) = *self.draw_depth_cache.borrow_mut() {
|
||||||
|
*e = self.geometry_epoch;
|
||||||
|
}
|
||||||
|
return arc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use acadrust::objects::ObjectType;
|
use acadrust::objects::ObjectType;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue