Skip to content

Commit ace5e9d

Browse files
committed
apply stateful data refactor to editor crate
1 parent fd87eec commit ace5e9d

4 files changed

Lines changed: 31 additions & 24 deletions

File tree

crates/bevy_animation_graph_editor/src/graph_show.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ use crate::egui_nodes::{
55
pin::{PinSpec, PinType},
66
};
77
use bevy::{asset::AssetId, ecs::resource::Resource, platform::collections::HashMap};
8-
use bevy_animation_graph::core::{
9-
animation_graph::{AnimationGraph, PinId, SourcePin, TargetPin},
10-
animation_node::AnimationNode,
11-
context::{GraphContext, SpecContext},
12-
edge_data::DataSpec,
8+
use bevy_animation_graph::{
9+
core::{
10+
animation_graph::{AnimationGraph, PinId, SourcePin, TargetPin},
11+
animation_node::AnimationNode,
12+
context::SpecContext,
13+
edge_data::DataSpec,
14+
},
15+
prelude::{graph_context::GraphContext, node_states::StateKey},
1316
};
1417
use bevy_inspector_egui::egui::Color32;
1518

@@ -453,18 +456,18 @@ impl GraphReprSpec {
453456
return (None, None, false);
454457
};
455458

456-
let source_pin = SourcePin::NodeTime(node.name.clone());
457459
let time = graph_context
458-
.caches
459-
.get_primary(|c| c.get_time(&source_pin));
460+
.node_states
461+
.get_time(node.name.clone(), StateKey::Default);
460462
let duration = graph_context
461-
.caches
462-
.get_primary(|c| c.get_duration(&source_pin));
463+
.node_caches
464+
.get_duration(node.name.clone(), StateKey::Default)
465+
.ok();
463466
let active = graph_context
464-
.caches
465-
.get_primary(|c| Some(c.is_updated(&node.name)));
467+
.node_caches
468+
.is_updated(node.name.clone(), StateKey::Default);
466469

467-
(time, duration.flatten(), active.unwrap_or(false))
470+
(Some(time), duration.flatten(), active)
468471
}
469472

470473
fn add_nodes(

crates/bevy_animation_graph_editor/src/ui/native_windows/debugger.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ use bevy::{
55
prelude::{Handle, Image, In, Query, Transform, World},
66
};
77
use bevy_animation_graph::{
8-
core::{animation_graph::SourcePin, pose::Pose},
9-
prelude::{AnimatedScene, AnimatedSceneHandle, AnimationGraphPlayer, DataValue},
8+
core::pose::Pose,
9+
prelude::{
10+
AnimatedScene, AnimatedSceneHandle, AnimationGraphPlayer, DataValue, node_states::StateKey,
11+
},
1012
};
1113
use egui_dock::egui;
1214

@@ -94,11 +96,10 @@ impl NativeEditorWindowExtension for DebuggerWindow {
9496
// Now get the selected value and display it!
9597

9698
let Some(val) = new_pin_id.and_then(|pin_id| {
97-
graph_context.caches.get_primary(|c| {
98-
let node_id = active_node.node.clone();
99-
let pin_id = pin_id.clone();
100-
c.get_data(&SourcePin::NodeData(node_id, pin_id)).cloned()
101-
})
99+
graph_context
100+
.node_caches
101+
.get_output_data(active_node.node.clone(), StateKey::Default, pin_id.clone())
102+
.ok()
102103
}) else {
103104
return;
104105
};

crates/bevy_animation_graph_editor/src/ui/native_windows/fsm_editor.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use bevy::{
44
utils::default,
55
};
66
use bevy_animation_graph::{
7-
core::state_machine::high_level::StateMachine, prelude::AnimationGraph,
7+
core::state_machine::{high_level::StateMachine, low_level::FSMState},
8+
prelude::{AnimationGraph, node_states::StateKey},
89
};
910
use egui_dock::egui;
1011

@@ -98,8 +99,10 @@ impl NativeEditorWindowExtension for FsmEditorWindow {
9899
let graph_id = ctx.get_graph_id();
99100
let graph = graph_assets.get(graph_id)?;
100101
let node_id = graph.contains_state_machine(&active_fsm.handle)?;
101-
ctx.caches
102-
.get_primary(|c| c.get_fsm_state(&node_id).cloned())
102+
ctx.node_states
103+
.get::<FSMState>(node_id, StateKey::Default)
104+
.ok()
105+
.cloned()
103106
});
104107

105108
let fsm_repr_spec =

crates/bevy_animation_graph_editor/src/ui/native_windows/inspector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use bevy::{
55
};
66
use bevy_animation_graph::{
77
core::state_machine::high_level::{State, StateMachine, Transition},
8-
prelude::{AnimationGraph, AnimationNode, GraphContext, GraphContextId},
8+
prelude::{AnimationGraph, AnimationNode, GraphContextId, graph_context::GraphContext},
99
};
1010
use bevy_inspector_egui::reflect_inspector::InspectorUi;
1111
use egui_dock::egui;

0 commit comments

Comments
 (0)