Skip to content

Commit 30cb3c7

Browse files
committed
rewrite FSM editor gui code
1 parent b3a3d9a commit 30cb3c7

17 files changed

Lines changed: 1012 additions & 2575 deletions

File tree

assets/fsm/locomotion.fsm.ron

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
(
22
states: [
33
(
4-
id: "walk",
4+
id: "505e7d48-bbdb-440b-ad3f-5886d332b291",
5+
label: "walk",
56
graph: "animation_graphs/walk.animgraph.ron",
67
global_transition: Some((
78
duration: 1.0,
89
graph: "animation_graphs/walk_to_run.animgraph.ron",
910
)),
1011
),
1112
(
12-
id: "run",
13+
id: "505e7d48-bbdb-440b-ad3f-5886d332b292",
14+
label: "run",
1315
graph: "animation_graphs/run.animgraph.ron",
1416
global_transition: None,
1517
),
1618
],
1719
transitions: [
1820
(
19-
id: Direct("slow_down"),
20-
source: "run",
21-
target: "walk",
21+
id: "505e7d48-bbdb-440b-ad3f-5886d332b293",
22+
variant: Direct(source: "505e7d48-bbdb-440b-ad3f-5886d332b292", target: "505e7d48-bbdb-440b-ad3f-5886d332b291"),
2223
duration: 1.0,
2324
graph: "animation_graphs/walk_to_run.animgraph.ron",
2425
),
2526
(
26-
id: Direct("speed_up"),
27-
source: "walk",
28-
target: "run",
27+
id: "505e7d48-bbdb-440b-ad3f-5886d332b294",
28+
variant: Direct(source: "505e7d48-bbdb-440b-ad3f-5886d332b291", target: "505e7d48-bbdb-440b-ad3f-5886d332b292"),
2929
duration: 1.0,
3030
graph: "animation_graphs/walk_to_run.animgraph.ron",
3131
),
3232
],
33-
start_state: "run",
33+
start_state: "505e7d48-bbdb-440b-ad3f-5886d332b291",
3434
input_data: {
3535
"speed": F32(1.0),
3636
},
3737
extra: (
3838
states: {
39-
"walk": (334.10522, 309.52664),
40-
"run": (552.15, 310.6519),
39+
"505e7d48-bbdb-440b-ad3f-5886d332b291": (300., 230.),
4140
},
4241
),
4342
)

crates/bevy_animation_graph_core/src/plugin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434
definition::Ragdoll, definition_loader::RagdollLoader,
3535
},
3636
skeleton::{Skeleton, loader::SkeletonLoader},
37-
state_machine::high_level::{GlobalTransition, StateMachine, loader::StateMachineLoader},
37+
state_machine::high_level::{StateMachine, loader::StateMachineLoader},
3838
symmetry::{config::SymmetryConfig, serial::SymmetryConfigSerial},
3939
systems::{animation_player, animation_player_deferred_gizmos, apply_animation_to_targets},
4040
};
@@ -195,7 +195,6 @@ impl AnimationGraphCorePlugin {
195195
.register_type::<AnimationNode>()
196196
.register_type::<SymmetryConfig>()
197197
.register_type::<SymmetryConfigSerial>()
198-
.register_type::<GlobalTransition>()
199198
.register_type::<()>()
200199
.register_type_data::<(), ReflectDefault>();
201200
}

crates/bevy_animation_graph_core/src/state_machine/high_level/loader.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bevy::asset::{AssetLoader, LoadContext, io::Reader};
22

3-
use super::{GlobalTransition, State, StateMachine, Transition, serial::StateMachineSerial};
3+
use super::{State, StateMachine, Transition, serial::StateMachineSerial};
44
use crate::errors::AssetLoaderError;
55

66
#[derive(Default)]
@@ -27,23 +27,17 @@ impl AssetLoader for StateMachineLoader {
2727
};
2828

2929
for state_serial in serial.states {
30-
let global_transition_data =
31-
state_serial.global_transition.map(|gt| GlobalTransition {
32-
duration: gt.duration,
33-
graph: load_context.load(gt.graph),
34-
});
3530
fsm.add_state(State {
3631
id: state_serial.id,
3732
graph: load_context.load(state_serial.graph),
38-
global_transition: global_transition_data,
33+
label: state_serial.label,
3934
});
4035
}
4136

4237
for transition_serial in serial.transitions {
43-
fsm.add_transition(Transition {
38+
fsm.add_transition_unchecked(Transition {
4439
id: transition_serial.id,
45-
source: transition_serial.source,
46-
target: transition_serial.target,
40+
variant: transition_serial.variant,
4741
duration: transition_serial.duration,
4842
graph: load_context.load(transition_serial.graph),
4943
});

0 commit comments

Comments
 (0)