-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds: - `ConstEntityPath` - `NormalizeVec3` - `LengthVec3` - `ConstVec3`
- Loading branch information
Showing
9 changed files
with
243 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
crates/bevy_animation_graph/src/nodes/arithmetic/vec3/const_vec3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::core::animation_graph::PinMap; | ||
use crate::core::animation_node::{AnimationNode, AnimationNodeType, NodeLike}; | ||
use crate::core::errors::GraphError; | ||
use crate::core::prelude::DataSpec; | ||
use crate::prelude::{PassContext, SpecContext}; | ||
use bevy::prelude::*; | ||
|
||
#[derive(Reflect, Clone, Debug, Default)] | ||
#[reflect(Default)] | ||
pub struct ConstVec3Node { | ||
pub constant: Vec3, | ||
} | ||
|
||
impl ConstVec3Node { | ||
pub const OUTPUT: &'static str = "out"; | ||
|
||
pub fn new(constant: Vec3) -> Self { | ||
Self { constant } | ||
} | ||
|
||
pub fn wrapped(self, name: impl Into<String>) -> AnimationNode { | ||
AnimationNode::new_from_nodetype(name.into(), AnimationNodeType::ConstVec3(self)) | ||
} | ||
} | ||
|
||
impl NodeLike for ConstVec3Node { | ||
fn display_name(&self) -> String { | ||
"Vec3".into() | ||
} | ||
|
||
fn update(&self, mut ctx: PassContext) -> Result<(), GraphError> { | ||
ctx.set_data_fwd(Self::OUTPUT, self.constant); | ||
Ok(()) | ||
} | ||
|
||
fn data_output_spec(&self, _ctx: SpecContext) -> PinMap<DataSpec> { | ||
[(Self::OUTPUT.into(), DataSpec::Vec3)].into() | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
crates/bevy_animation_graph/src/nodes/arithmetic/vec3/length.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::core::animation_graph::PinMap; | ||
use crate::core::animation_node::{AnimationNode, AnimationNodeType, NodeLike}; | ||
use crate::core::errors::GraphError; | ||
use crate::core::prelude::DataSpec; | ||
use crate::prelude::{PassContext, SpecContext}; | ||
use crate::utils::unwrap::UnwrapVal; | ||
use bevy::prelude::*; | ||
|
||
#[derive(Reflect, Clone, Debug, Default)] | ||
#[reflect(Default)] | ||
pub struct LengthVec3Node {} | ||
|
||
impl LengthVec3Node { | ||
pub const INPUT: &'static str = "in"; | ||
pub const OUTPUT: &'static str = "out"; | ||
|
||
pub fn new() -> Self { | ||
Self {} | ||
} | ||
|
||
pub fn wrapped(self, name: impl Into<String>) -> AnimationNode { | ||
AnimationNode::new_from_nodetype(name.into(), AnimationNodeType::LengthVec3(self)) | ||
} | ||
} | ||
|
||
impl NodeLike for LengthVec3Node { | ||
fn update(&self, mut ctx: PassContext) -> Result<(), GraphError> { | ||
let input: Vec3 = ctx.data_back(Self::INPUT)?.val(); | ||
let output = input.length(); | ||
|
||
ctx.set_data_fwd(Self::OUTPUT, output); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn data_input_spec(&self, _: SpecContext) -> PinMap<DataSpec> { | ||
[(Self::INPUT.into(), DataSpec::Vec3)].into() | ||
} | ||
|
||
fn data_output_spec(&self, _: SpecContext) -> PinMap<DataSpec> { | ||
[(Self::OUTPUT.into(), DataSpec::F32)].into() | ||
} | ||
|
||
fn display_name(&self) -> String { | ||
"Length Vec3".into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
mod const_vec3; | ||
mod from_f32; | ||
mod into_f32; | ||
mod length; | ||
mod lerp; | ||
mod normalize; | ||
mod rotation_arc; | ||
|
||
pub use const_vec3::*; | ||
pub use from_f32::*; | ||
pub use into_f32::*; | ||
pub use length::*; | ||
pub use lerp::*; | ||
pub use normalize::*; | ||
pub use rotation_arc::*; |
47 changes: 47 additions & 0 deletions
47
crates/bevy_animation_graph/src/nodes/arithmetic/vec3/normalize.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::core::animation_graph::PinMap; | ||
use crate::core::animation_node::{AnimationNode, AnimationNodeType, NodeLike}; | ||
use crate::core::errors::GraphError; | ||
use crate::core::prelude::DataSpec; | ||
use crate::prelude::{PassContext, SpecContext}; | ||
use crate::utils::unwrap::UnwrapVal; | ||
use bevy::prelude::*; | ||
|
||
#[derive(Reflect, Clone, Debug, Default)] | ||
#[reflect(Default)] | ||
pub struct NormalizeVec3Node {} | ||
|
||
impl NormalizeVec3Node { | ||
pub const INPUT: &'static str = "in"; | ||
pub const OUTPUT: &'static str = "out"; | ||
|
||
pub fn new() -> Self { | ||
Self {} | ||
} | ||
|
||
pub fn wrapped(self, name: impl Into<String>) -> AnimationNode { | ||
AnimationNode::new_from_nodetype(name.into(), AnimationNodeType::NormalizeVec3(self)) | ||
} | ||
} | ||
|
||
impl NodeLike for NormalizeVec3Node { | ||
fn update(&self, mut ctx: PassContext) -> Result<(), GraphError> { | ||
let input: Vec3 = ctx.data_back(Self::INPUT)?.val(); | ||
let output = input.normalize_or_zero(); | ||
|
||
ctx.set_data_fwd(Self::OUTPUT, output); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn data_input_spec(&self, _: SpecContext) -> PinMap<DataSpec> { | ||
[(Self::INPUT.into(), DataSpec::Vec3)].into() | ||
} | ||
|
||
fn data_output_spec(&self, _: SpecContext) -> PinMap<DataSpec> { | ||
[(Self::OUTPUT.into(), DataSpec::Vec3)].into() | ||
} | ||
|
||
fn display_name(&self) -> String { | ||
"Normalize Vec3".into() | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
crates/bevy_animation_graph/src/nodes/const_entity_path.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::core::animation_clip::EntityPath; | ||
use crate::core::animation_graph::PinMap; | ||
use crate::core::animation_node::{AnimationNode, AnimationNodeType, NodeLike}; | ||
use crate::core::errors::GraphError; | ||
use crate::core::prelude::DataSpec; | ||
use crate::prelude::{DataValue, PassContext, SpecContext}; | ||
use bevy::prelude::*; | ||
|
||
#[derive(Reflect, Clone, Debug, Default)] | ||
#[reflect(Default)] | ||
pub struct ConstEntityPath { | ||
pub path: EntityPath, | ||
} | ||
|
||
impl ConstEntityPath { | ||
pub const OUTPUT: &'static str = "out"; | ||
|
||
pub fn new(path: EntityPath) -> Self { | ||
Self { path } | ||
} | ||
|
||
pub fn wrapped(self, name: impl Into<String>) -> AnimationNode { | ||
AnimationNode::new_from_nodetype(name.into(), AnimationNodeType::ConstEntityPath(self)) | ||
} | ||
} | ||
|
||
impl NodeLike for ConstEntityPath { | ||
fn display_name(&self) -> String { | ||
"Entity Path".into() | ||
} | ||
|
||
fn update(&self, mut ctx: PassContext) -> Result<(), GraphError> { | ||
ctx.set_data_fwd(Self::OUTPUT, DataValue::EntityPath(self.path.clone())); | ||
Ok(()) | ||
} | ||
|
||
fn data_output_spec(&self, _ctx: SpecContext) -> PinMap<DataSpec> { | ||
[(Self::OUTPUT.into(), DataSpec::EntityPath)].into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters