Skip to content

Commit

Permalink
Merge branch 'master' into feat/dynamic-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
aecsocket committed Oct 3, 2024
2 parents 4be23a0 + b9435c5 commit 87e0703
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 539 deletions.
94 changes: 93 additions & 1 deletion crates/bevy_animation_graph/src/core/edge_data/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ pub enum DataSpec {

#[derive(Serialize, Deserialize, Reflect, Clone, Debug)]
pub enum DataValue {
// trivial copy
F32(f32),
Bool(bool),
Vec3(Vec3),
EntityPath(EntityPath),
Quat(Quat),
// non-trivial copy
EntityPath(EntityPath),
BoneMask(BoneMask),
Pose(Pose),
EventQueue(EventQueue),
Expand All @@ -64,6 +66,96 @@ impl Default for DataValue {
}
}

impl DataValue {
// trivial copy

#[must_use]
pub const fn as_f32(&self) -> Option<f32> {
match self {
&Self::F32(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_f32(self) -> Option<f32> {
self.as_f32()
}

#[must_use]
pub const fn as_bool(&self) -> Option<bool> {
match self {
&Self::Bool(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_bool(self) -> Option<bool> {
self.as_bool()
}

#[must_use]
pub const fn as_vec3(&self) -> Option<Vec3> {
match self {
&Self::Vec3(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_vec3(self) -> Option<Vec3> {
self.as_vec3()
}

#[must_use]
pub const fn as_quat(&self) -> Option<Quat> {
match self {
&Self::Quat(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_quat(self) -> Option<Quat> {
self.as_quat()
}

// non-trivial copy

#[must_use]
pub fn into_entity_path(self) -> Option<EntityPath> {
match self {
Self::EntityPath(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_bone_mask(self) -> Option<BoneMask> {
match self {
Self::BoneMask(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_pose(self) -> Option<Pose> {
match self {
Self::Pose(x) => Some(x),
_ => None,
}
}

#[must_use]
pub fn into_event_queue(self) -> Option<EventQueue> {
match self {
Self::EventQueue(x) => Some(x),
_ => None,
}
}
}

impl UnwrapVal<f32> for DataValue {
fn val(self) -> f32 {
match self {
Expand Down
5 changes: 0 additions & 5 deletions old_assets/animated_scenes/fox.animscn.ron

This file was deleted.

5 changes: 0 additions & 5 deletions old_assets/animated_scenes/human.animscn.ron

This file was deleted.

5 changes: 0 additions & 5 deletions old_assets/animated_scenes/human_ik.animscn.ron

This file was deleted.

66 changes: 0 additions & 66 deletions old_assets/animation_graphs/fox.animgraph.ron

This file was deleted.

144 changes: 0 additions & 144 deletions old_assets/animation_graphs/human.animgraph.ron

This file was deleted.

Loading

0 comments on commit 87e0703

Please sign in to comment.