New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generic animation system #558

Merged
merged 1 commit into from Feb 9, 2018

Conversation

Projects
None yet
4 participants
@Rhuagh
Member

Rhuagh commented Feb 1, 2018

Taking a stab at making animation generic.

  • Base types
  • Sampling system
  • Animation control system
  • LocalTransform added back in
  • GLTF loading
  • Examples

This change is Reviewable

@Rhuagh Rhuagh changed the title from [WIP] feat: Generic animation system to feat: Generic animation system Feb 2, 2018

@Rhuagh Rhuagh added status: ready and removed status: working labels Feb 2, 2018

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 2, 2018

Member

Ready for review.

Member

Rhuagh commented Feb 2, 2018

Ready for review.

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Feb 3, 2018

Member

This is great :)


Reviewed 19 of 19 files at r1.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


amethyst_animation/src/bundle.rs, line 16 at r1 (raw file):

              SamplerProcessor};

const DEP: [&str; 0] = [];

Why are you using a constant here? Isn't a reference to a ZST 'static automatically?


amethyst_animation/src/bundle.rs, line 59 at r1 (raw file):

/// Bundle for only the sampler interpolation.
///
/// Will add `SamplerInterpolationSystem` with name `sampler_interpolation_system`.

sampler_processor isn't listed here


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

        builder: DispatcherBuilder<'a, 'b>,
    ) -> Result<DispatcherBuilder<'a, 'b>> {
        if !world

I think we have added an Entry API for this.


amethyst_animation/src/resources.rs, line 15 at r1 (raw file):

pub trait AnimationSampling {
    /// The channel type
    type Channel;

Maybe add the Send + Sync + 'static bounds here?


amethyst_animation/src/resources.rs, line 23 at r1 (raw file):

    /// Get the current sample for a channel
    fn get_current_sample(&self, channel: &Self::Channel) -> SamplerPrimitive<Self::Scalar>;

Should be current_sample


amethyst_animation/src/resources.rs, line 264 at r1 (raw file):

        command: AnimationCommand,
    ) -> Self {
        Self {

Please use AnimationControl for the construction


Comments from Reviewable

Member

torkleyy commented Feb 3, 2018

This is great :)


Reviewed 19 of 19 files at r1.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


amethyst_animation/src/bundle.rs, line 16 at r1 (raw file):

              SamplerProcessor};

const DEP: [&str; 0] = [];

Why are you using a constant here? Isn't a reference to a ZST 'static automatically?


amethyst_animation/src/bundle.rs, line 59 at r1 (raw file):

/// Bundle for only the sampler interpolation.
///
/// Will add `SamplerInterpolationSystem` with name `sampler_interpolation_system`.

sampler_processor isn't listed here


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

        builder: DispatcherBuilder<'a, 'b>,
    ) -> Result<DispatcherBuilder<'a, 'b>> {
        if !world

I think we have added an Entry API for this.


amethyst_animation/src/resources.rs, line 15 at r1 (raw file):

pub trait AnimationSampling {
    /// The channel type
    type Channel;

Maybe add the Send + Sync + 'static bounds here?


amethyst_animation/src/resources.rs, line 23 at r1 (raw file):

    /// Get the current sample for a channel
    fn get_current_sample(&self, channel: &Self::Channel) -> SamplerPrimitive<Self::Scalar>;

Should be current_sample


amethyst_animation/src/resources.rs, line 264 at r1 (raw file):

        command: AnimationCommand,
    ) -> Self {
        Self {

Please use AnimationControl for the construction


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 3, 2018

Member

Review status: all files reviewed at latest revision, 6 unresolved discussions.


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I think we have added an Entry API for this.

Released?


Comments from Reviewable

Member

Rhuagh commented Feb 3, 2018

Review status: all files reviewed at latest revision, 6 unresolved discussions.


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I think we have added an Entry API for this.

Released?


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 3, 2018

Member

Review status: all files reviewed at latest revision, 6 unresolved discussions.


amethyst_animation/src/bundle.rs, line 16 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Why are you using a constant here? Isn't a reference to a ZST 'static automatically?

Done.


amethyst_animation/src/bundle.rs, line 59 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

sampler_processor isn't listed here

Done.


amethyst_animation/src/resources.rs, line 15 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Maybe add the Send + Sync + 'static bounds here?

Done.


amethyst_animation/src/resources.rs, line 23 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Should be current_sample

Done.


amethyst_animation/src/resources.rs, line 264 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Please use AnimationControl for the construction

Done.


Comments from Reviewable

Member

Rhuagh commented Feb 3, 2018

Review status: all files reviewed at latest revision, 6 unresolved discussions.


amethyst_animation/src/bundle.rs, line 16 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Why are you using a constant here? Isn't a reference to a ZST 'static automatically?

Done.


amethyst_animation/src/bundle.rs, line 59 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

sampler_processor isn't listed here

Done.


amethyst_animation/src/resources.rs, line 15 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Maybe add the Send + Sync + 'static bounds here?

Done.


amethyst_animation/src/resources.rs, line 23 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Should be current_sample

Done.


amethyst_animation/src/resources.rs, line 264 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Please use AnimationControl for the construction

Done.


Comments from Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Feb 4, 2018

Member

Reviewed 8 of 8 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Released?

Yep, https://docs.rs/shred/0.5.2/shred/struct.Resources.html#method.entry


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

///
/// Will add `SamplerInterpolationSystem<T>` with the given name.
/// Will also add `SamplerProcessor<T::Scalar>` if it has not been added yet.

I think you misunderstood the usage of add(sys, "", dependencies). It does not check if it's already added, it will just add the same system twice.


Comments from Reviewable

Member

torkleyy commented Feb 4, 2018

Reviewed 8 of 8 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Released?

Yep, https://docs.rs/shred/0.5.2/shred/struct.Resources.html#method.entry


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

///
/// Will add `SamplerInterpolationSystem<T>` with the given name.
/// Will also add `SamplerProcessor<T::Scalar>` if it has not been added yet.

I think you misunderstood the usage of add(sys, "", dependencies). It does not check if it's already added, it will just add the same system twice.


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 5, 2018

Member

Review status: 6 of 19 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Yep, https://docs.rs/shred/0.5.2/shred/struct.Resources.html#method.entry

Done


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I think you misunderstood the usage of add(sys, "", dependencies). It does not check if it's already added, it will just add the same system twice.

Ah, no, I just messed up the docs


Comments from Reviewable

Member

Rhuagh commented Feb 5, 2018

Review status: 6 of 19 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


amethyst_animation/src/bundle.rs, line 93 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Yep, https://docs.rs/shred/0.5.2/shred/struct.Resources.html#method.entry

Done


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I think you misunderstood the usage of add(sys, "", dependencies). It does not check if it's already added, it will just add the same system twice.

Ah, no, I just messed up the docs


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 5, 2018

Member

Review status: 6 of 19 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


amethyst_animation/src/resources.rs, line 62 at r3 (raw file):

/// Only required for animations which target more than a single node.
#[derive(Debug, Clone)]
pub struct AnimationHierarchy {

This should probably be generic on T aswell


Comments from Reviewable

Member

Rhuagh commented Feb 5, 2018

Review status: 6 of 19 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


amethyst_animation/src/resources.rs, line 62 at r3 (raw file):

/// Only required for animations which target more than a single node.
#[derive(Debug, Clone)]
pub struct AnimationHierarchy {

This should probably be generic on T aswell


Comments from Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Feb 5, 2018

Member

Reviewed 13 of 13 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Ah, no, I just messed up the docs

Please correct it to "with the given name"


amethyst_animation/src/bundle.rs, line 97 at r3 (raw file):

            .res
            .entry()
            .or_insert_with(|| AssetStorage::<Sampler<T::Primitive>>::new());

Can coerce the new function to a closure.


Comments from Reviewable

Member

torkleyy commented Feb 5, 2018

Reviewed 13 of 13 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Ah, no, I just messed up the docs

Please correct it to "with the given name"


amethyst_animation/src/bundle.rs, line 97 at r3 (raw file):

            .res
            .entry()
            .or_insert_with(|| AssetStorage::<Sampler<T::Primitive>>::new());

Can coerce the new function to a closure.


Comments from Reviewable

@omni-viral omni-viral self-requested a review Feb 6, 2018

@Xaeroxe

Xaeroxe approved these changes Feb 7, 2018

Impressive work! LGTM! I got a couple nits but I don't consider either of them blockers.

+ Self {
+ animation_name,
+ sampling_name,
+ dep: &[],

This comment has been minimized.

@Xaeroxe

Xaeroxe Feb 7, 2018

Member

I don't see anywhere this could be something other than &[] so why not just inline that and remove this member variable?

@Xaeroxe

Xaeroxe Feb 7, 2018

Member

I don't see anywhere this could be something other than &[] so why not just inline that and remove this member variable?

This comment has been minimized.

@Rhuagh

Rhuagh Feb 7, 2018

Member

The with_dep function is hidden in the block below :)

@Rhuagh

Rhuagh Feb 7, 2018

Member

The with_dep function is hidden in the block below :)

This comment has been minimized.

@Xaeroxe

Xaeroxe Feb 7, 2018

Member

Gotcha, thanks, feel free to ignore.

@Xaeroxe

Xaeroxe Feb 7, 2018

Member

Gotcha, thanks, feel free to ignore.

amethyst_animation/src/resources.rs
@@ -55,21 +69,30 @@ impl Component for AnimationHierarchy {
/// Defines a single animation.
/// Defines relationships between the node index in `AnimationHierarchy` and a `Sampler` handle.
-/// If the animation only targets a single node index, `AnimationHierarchy` is not required.
+/// If the animation only target a single node index, `AnimationHierarchy` is not required.

This comment has been minimized.

@Xaeroxe

Xaeroxe Feb 7, 2018

Member

targets is the correct word here because this sentence is present tense.

@Xaeroxe

Xaeroxe Feb 7, 2018

Member

targets is the correct word here because this sentence is present tense.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 7, 2018

Member

Review status: 15 of 19 files reviewed at latest revision, 5 unresolved discussions.


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Please correct it to "with the given name"

Done.


amethyst_animation/src/bundle.rs, line 97 at r3 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Can coerce the new function to a closure.

Done.


amethyst_animation/src/resources.rs, line 62 at r3 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

This should probably be generic on T aswell

Done.


amethyst_animation/src/resources.rs, line 72 at r3 (raw file):

Previously, Xaeroxe (Jacob Kiesel) wrote…

targets is the correct word here because this sentence is present tense.

Done.


Comments from Reviewable

Member

Rhuagh commented Feb 7, 2018

Review status: 15 of 19 files reviewed at latest revision, 5 unresolved discussions.


amethyst_animation/src/bundle.rs, line 57 at r2 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Please correct it to "with the given name"

Done.


amethyst_animation/src/bundle.rs, line 97 at r3 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Can coerce the new function to a closure.

Done.


amethyst_animation/src/resources.rs, line 62 at r3 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

This should probably be generic on T aswell

Done.


amethyst_animation/src/resources.rs, line 72 at r3 (raw file):

Previously, Xaeroxe (Jacob Kiesel) wrote…

targets is the correct word here because this sentence is present tense.

Done.


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 7, 2018

Member

All comments addressed now I believe.


Review status: 15 of 19 files reviewed at latest revision, 5 unresolved discussions.


Comments from Reviewable

Member

Rhuagh commented Feb 7, 2018

All comments addressed now I believe.


Review status: 15 of 19 files reviewed at latest revision, 5 unresolved discussions.


Comments from Reviewable

@omni-viral

This is great.
Sorry for late review.
Only few nits.

amethyst_gltf/src/format/mod.rs
- .collect::<Result<Vec<(usize, Sampler)>, GltfError>>()?
- .into_iter()
- .unzip();
+ .collect::<Result<Vec<(usize, LocalTransformChannel, Sampler<SamplerPrimitive<f32>>)>, GltfError>>()?;

This comment has been minimized.

@omni-viral

omni-viral Feb 8, 2018

Member

Consider to use Result<Vec<_>, _> and let the rest to be inferred.

@omni-viral

omni-viral Feb 8, 2018

Member

Consider to use Result<Vec<_>, _> and let the rest to be inferred.

amethyst_gltf/src/format/mod.rs
let output = AccessorIter::<[f32; 4]>::new(sampler.output(), buffers)
- .map(|q| [q[3], q[0], q[1], q[2]])
+ .map(|q| SamplerPrimitive::Vec4([q[3], q[0], q[1], q[2]]))

This comment has been minimized.

@omni-viral

omni-viral Feb 8, 2018

Member

Could it be handled by From trait?

@omni-viral

omni-viral Feb 8, 2018

Member

Could it be handled by From trait?

This comment has been minimized.

@Rhuagh

Rhuagh Feb 8, 2018

Member

No, because it needs to be swizzled

@Rhuagh

Rhuagh Feb 8, 2018

Member

No, because it needs to be swizzled

This comment has been minimized.

@Rhuagh

Rhuagh Feb 8, 2018

Member

Or hmm, it might

@Rhuagh

Rhuagh Feb 8, 2018

Member

Or hmm, it might

amethyst_gltf/src/systems.rs
.samplers
.iter()
.cloned()
- .map(|sampler| {
- loader.load_from_data(sampler, (), &*sampler_storage)
+ .map(|(node_index, channel, ref sampler)| {

This comment has been minimized.

@omni-viral

omni-viral Feb 8, 2018

Member

Why ref sampled if it is cloned?
sampler now cloned two times.

@omni-viral

omni-viral Feb 8, 2018

Member

Why ref sampled if it is cloned?
sampler now cloned two times.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Feb 8, 2018

Member

Review status: 15 of 19 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


amethyst_gltf/src/systems.rs, line 234 at r4 (raw file):

Previously, omni-viral (Zakarum) wrote…

Why ref sampled if it is cloned?
sampler now cloned two times.

Done.


amethyst_gltf/src/format/mod.rs, line 187 at r4 (raw file):

Previously, omni-viral (Zakarum) wrote…

Consider to use Result<Vec<_>, _> and let the rest to be inferred.

Done.


amethyst_gltf/src/format/mod.rs, line 229 at r4 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Or hmm, it might

Done.


Comments from Reviewable

Member

Rhuagh commented Feb 8, 2018

Review status: 15 of 19 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


amethyst_gltf/src/systems.rs, line 234 at r4 (raw file):

Previously, omni-viral (Zakarum) wrote…

Why ref sampled if it is cloned?
sampler now cloned two times.

Done.


amethyst_gltf/src/format/mod.rs, line 187 at r4 (raw file):

Previously, omni-viral (Zakarum) wrote…

Consider to use Result<Vec<_>, _> and let the rest to be inferred.

Done.


amethyst_gltf/src/format/mod.rs, line 229 at r4 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Or hmm, it might

Done.


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment

:shipit: is implicit approval

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Feb 9, 2018

Member

amethyst_animation/src/resources.rs, line 67 at r5 (raw file):

}

macro_rules! hashmap {

Cool macro! We should consider moving this to core.


Comments from Reviewable

Member

Xaeroxe commented Feb 9, 2018

amethyst_animation/src/resources.rs, line 67 at r5 (raw file):

}

macro_rules! hashmap {

Cool macro! We should consider moving this to core.


Comments from Reviewable

@Xaeroxe

Xaeroxe approved these changes Feb 9, 2018

:shipit: !

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Feb 9, 2018

Member

:lgtm:

bors r+


Reviewed 3 of 4 files at r4, 2 of 2 files at r5.
Review status: all files reviewed at latest revision, all discussions resolved.


amethyst_animation/src/resources.rs, line 67 at r5 (raw file):

Previously, Xaeroxe (Jacob Kiesel) wrote…

Cool macro! We should consider moving this to core.

There is some crate that exposes such a macro..


Comments from Reviewable

Member

torkleyy commented Feb 9, 2018

:lgtm:

bors r+


Reviewed 3 of 4 files at r4, 2 of 2 files at r5.
Review status: all files reviewed at latest revision, all discussions resolved.


amethyst_animation/src/resources.rs, line 67 at r5 (raw file):

Previously, Xaeroxe (Jacob Kiesel) wrote…

Cool macro! We should consider moving this to core.

There is some crate that exposes such a macro..


Comments from Reviewable

bors bot added a commit that referenced this pull request Feb 9, 2018

Merge #558
558: feat: Generic animation system r=torkleyy a=Rhuagh

Taking a stab at making animation generic. 

- [X] Base types
- [X] Sampling system
- [x] Animation control system
- [X] LocalTransform added back in
- [x] GLTF loading
- [x] Examples

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/amethyst/amethyst/558)
<!-- Reviewable:end -->
@bors

This comment has been minimized.

Show comment
Hide comment
Contributor

bors bot commented Feb 9, 2018

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Feb 9, 2018

Member

bors r+

Member

torkleyy commented Feb 9, 2018

bors r+

bors bot added a commit that referenced this pull request Feb 9, 2018

Merge #558
558: feat: Generic animation system r=torkleyy a=Rhuagh

Taking a stab at making animation generic. 

- [X] Base types
- [X] Sampling system
- [x] Animation control system
- [X] LocalTransform added back in
- [x] GLTF loading
- [x] Examples

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/amethyst/amethyst/558)
<!-- Reviewable:end -->
@bors

This comment has been minimized.

Show comment
Hide comment

@bors bors bot merged commit 5cec9de into amethyst:develop Feb 9, 2018

4 checks passed

bors Build succeeded
code-review/reviewable 19 files reviewed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Xaeroxe Xaeroxe referenced this pull request Feb 9, 2018

Merged

Rename transforms #563

@Rhuagh Rhuagh deleted the Rhuagh:feature/animation-generic branch Feb 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment