Unravel Engine C++ Reference
Loading...
Searching...
No Matches
thumbnail_invalidation.h
Go to the documentation of this file.
1#pragma once
2
3#include <uuid/uuid.h>
4
5#include <set>
6
7namespace unravel
8{
9class asset_manager;
10struct thumbnail_manager;
11
12namespace asset_deps
13{
14
15//------------------------------------------------------------------------------
16// Cascade thumbnail regeneration across the in-memory dependency graph.
17//
18// Marks the thumbnail of `changed` for regeneration, and recursively does the
19// same for every currently-loaded asset that (transitively) references it via
20// `asset_deps::find_loaded_dependents`. Materials referencing a changed
21// texture, meshes referencing a changed material, models referencing a
22// changed mesh — all get refreshed.
23//
24// Prefabs are an opaque serialized buffer at runtime, so we don't walk them
25// for individual UUID references. When `mass_invalidate_prefabs` is true,
26// every loaded prefab thumbnail is marked dirty as a conservative
27// catch-all — the thumbnail pipeline only actually re-renders the prefabs
28// the user is currently viewing, so the cost is bounded.
29//
30// Pass `mass_invalidate_prefabs = true` for renderable asset changes
31// (texture / material / mesh / model / animation), false otherwise.
32//------------------------------------------------------------------------------
33void cascade_thumbnail_regen(asset_manager& am,
34 thumbnail_manager& tm,
35 const hpp::uuid& changed,
36 bool mass_invalidate_prefabs);
37
38//------------------------------------------------------------------------------
39// Same cascade, but for *deletions*: the removed assets' own thumbnails are
40// removed (not regenerated, because the assets are gone), while every entry
41// in `dependent_uids` gets regen-flagged. Without this, a material whose
42// texture was just deleted would keep showing its stale thumbnail.
43//
44// The caller MUST compute `dependent_uids` (typically via
45// `asset_deps::find_transitive_loaded_dependents`) BEFORE the removed assets
46// have been unloaded. `asset_manager::unload_asset` clears the shared
47// `asset_link_t`, which causes every other handle that shared it (e.g. a
48// material's texture slot) to report a nil UUID — at that point dependent
49// enumeration would silently miss them. By doing the walk pre-unload the
50// caller captures the still-valid reference chain.
51//
52// `mass_invalidate_prefabs` has the same meaning as for regen.
53//------------------------------------------------------------------------------
54void cascade_thumbnail_remove(asset_manager& am,
55 thumbnail_manager& tm,
56 const std::set<hpp::uuid>& removed_uids,
57 const std::set<hpp::uuid>& dependent_uids,
58 bool mass_invalidate_prefabs);
59
60} // namespace asset_deps
61} // namespace unravel
void cascade_thumbnail_remove(asset_manager &am, thumbnail_manager &tm, const std::set< hpp::uuid > &removed_uids, const std::set< hpp::uuid > &dependent_uids, bool mass_invalidate_prefabs)
void cascade_thumbnail_regen(asset_manager &am, thumbnail_manager &tm, const hpp::uuid &changed, bool mass_invalidate_prefabs)