pub struct SceneModel {
pub kind: SceneKind,
pub format: Option<u8>,
pub uid: Option<SmolStr>,
pub script_class: Option<SmolStr>,
pub resource_type: Option<SmolStr>,
pub ext_resources: FxHashMap<ExtId, ExtResource>,
pub sub_resources: FxHashMap<ExtId, SubResource>,
pub nodes: Vec<SceneNode>,
pub root: Option<NodeIdx>,
pub by_path: FxHashMap<SmolStr, NodeIdx>,
pub unique_nodes: FxHashMap<SmolStr, NodeIdx>,
pub problems: Vec<SceneProblem>,
/* private fields */
}Expand description
One parsed .tscn/.tres. Produced by crate::parse_scene; never an Err — every
malformed/binary/unknown form degrades to an empty-or-partial model plus a SceneProblem.
PartialEq/Eq so it can be a backdated salsa query result (Arc<SceneModel>) in M1.
Fields§
§kind: SceneKindScene vs resource (from the header tag).
format: Option<u8>The format= version: >=3 is the Godot-4.x family, 2 is 3.x, None if absent.
uid: Option<SmolStr>The scene/resource uid="uid://…", if present.
script_class: Option<SmolStr>The header script_class="…" shortcut — the root/resource’s class_name without resolving
the script file.
resource_type: Option<SmolStr>A .tres’s own resource class (gd_resource type="…").
ext_resources: FxHashMap<ExtId, ExtResource>id → ext_resource (external scripts, packed scenes, textures, …).
sub_resources: FxHashMap<ExtId, SubResource>id → sub_resource type (the value body is skipped — we keep only the declared type).
nodes: Vec<SceneNode>Every node, in file order (which is tree pre-order for siblings). index = NodeIdx.0.
root: Option<NodeIdx>The single parent-less node, if the scene has one.
by_path: FxHashMap<SmolStr, NodeIdx>Full name-path from the root ("Panel/VBox/StartButton", root name excluded) → node.
unique_nodes: FxHashMap<SmolStr, NodeIdx>unique_name_in_owner nodes: bare name → node (the %Name lookup; scene-wide in the slice).
problems: Vec<SceneProblem>Non-fatal problems found while parsing (the parser never errors).
Implementations§
Source§impl SceneModel
impl SceneModel
Sourcepub fn resolve_path(&self, path: &str) -> Option<NodeIdx>
pub fn resolve_path(&self, path: &str) -> Option<NodeIdx>
Walk a name-path from the scene root. ""/"." ⇒ the root. None ⇒ no such node (M1 reads
that as “degrade to Node”, never an error). A leading / (absolute) or a .. segment is
out of the slice and yields None.
Sourcepub fn resolve_path_from(&self, base: NodeIdx, path: &str) -> Option<NodeIdx>
pub fn resolve_path_from(&self, base: NodeIdx, path: &str) -> Option<NodeIdx>
Walk a name-path from an arbitrary base node (the node a script attaches to — $X is
relative to that node, which is usually but not always the root). A %Name segment is a
unique-name lookup (scene-wide, owner-relative), so the idiomatic Foo/%Bar and the
string forms $"%Bar" / get_node("%Bar") resolve like the engine; a plain segment is a
child lookup.
Sourcepub fn resolve_unique(&self, path: &str) -> Option<NodeIdx>
pub fn resolve_unique(&self, path: &str) -> Option<NodeIdx>
Resolve a %-sigil path (%Name / %Name/Child/…). The leading segment is a unique name
even though the % sigil was a separate token (so it isn’t in path); subsequent segments
walk as normal children. Delegates to the %-aware resolve_path_from.
Sourcepub fn node_with_script(&self, script_path: &str) -> Option<NodeIdx>
pub fn node_with_script(&self, script_path: &str) -> Option<NodeIdx>
The node whose body script = ExtResource(id) resolves (via ext_resources[id].path) to
script_path — the per-scene half of the script↔scene association.
Sourcepub fn children_of(
&self,
idx: Option<NodeIdx>,
) -> impl Iterator<Item = (NodeIdx, &SceneNode)>
pub fn children_of( &self, idx: Option<NodeIdx>, ) -> impl Iterator<Item = (NodeIdx, &SceneNode)>
The child nodes of idx (None ⇒ the root’s children), in file order.
Sourcepub fn classify_path_from(
&self,
base: NodeIdx,
path: &str,
) -> NodePathResolution
pub fn classify_path_from( &self, base: NodeIdx, path: &str, ) -> NodePathResolution
Resolve a name-path from base, distinguishing the reason a path doesn’t resolve — so a
caller can warn on a genuine Missing node while staying
silent on an Escaped (../absolute) or an
IntoInstance override (the M1 typing uses
resolve_path_from; this is for the INVALID_NODE_PATH decision).
Sourcepub fn classify_unique(&self, path: &str) -> NodePathResolution
pub fn classify_unique(&self, path: &str) -> NodePathResolution
Resolve a %-sigil path (%Name / %Name/Child). The leading segment is a unique name
(the % sigil was a separate token, so it isn’t in path); subsequent segments walk as
children. A missing leading unique name is genuinely Missing
(no instance ambiguity — % is scene-wide).
Trait Implementations§
Source§impl Clone for SceneModel
impl Clone for SceneModel
Source§fn clone(&self) -> SceneModel
fn clone(&self) -> SceneModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SceneModel
impl Debug for SceneModel
impl Eq for SceneModel
Source§impl PartialEq for SceneModel
impl PartialEq for SceneModel
Source§fn eq(&self, other: &SceneModel) -> bool
fn eq(&self, other: &SceneModel) -> bool
self and other values to be equal, and is used by ==.