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

Transform System Rewrite/Update #403

Merged
merged 8 commits into from Oct 22, 2017

Conversation

Projects
None yet
5 participants
@Aceeri
Member

Aceeri commented Oct 11, 2017

Cleans up the transform system with some new specs features, adds unit tests.

Still plan on adding some tests using quickcheck for some more "fuzzy" testing to catch the odd edge cases.

Fixes #336

examples/05_assets/main.rs
@@ -13,8 +13,8 @@ use amethyst::config::Config;
use amethyst::ecs::World;
use amethyst::ecs::input::InputBundle;
use amethyst::ecs::rendering::{AmbientColor, Factory, LightComponent, MaterialComponent,
- MeshComponent, MeshContext, RenderBundle, TextureComponent,
- TextureContext};
+MeshComponent, MeshContext, RenderBundle, TextureComponent,

This comment has been minimized.

@Rhuagh

Rhuagh Oct 11, 2017

Member

This looks like broken formatting, are you using the latest rustfmt-nightly? And running cargo +nightly fmt --all ?

@Rhuagh

Rhuagh Oct 11, 2017

Member

This looks like broken formatting, are you using the latest rustfmt-nightly? And running cargo +nightly fmt --all ?

This comment has been minimized.

@Aceeri

Aceeri Oct 11, 2017

Member

I don't really know what went on here either, I ran the latest nightly but I'll try again this afternoon.

@Aceeri

Aceeri Oct 11, 2017

Member

I don't really know what went on here either, I ran the latest nightly but I'll try again this afternoon.

src/ecs/transform/systems.rs
+ .with(Transform::default())
+ .build();
+
+ dispatcher.dispatch(&mut world.res);

This comment has been minimized.

@Rhuagh

Rhuagh Oct 11, 2017

Member

Why not just do RunNow on the system? Feels like unnecessary overhead to use a real Dispatcher.

@Rhuagh

Rhuagh Oct 11, 2017

Member

Why not just do RunNow on the system? Feels like unnecessary overhead to use a real Dispatcher.

This comment has been minimized.

@Aceeri

Aceeri Oct 11, 2017

Member

Was just easier to set up, overhead doesn't really matter that much in these tests anyways.

@Aceeri

Aceeri Oct 11, 2017

Member

Was just easier to set up, overhead doesn't really matter that much in these tests anyways.

This comment has been minimized.

@torkleyy

torkleyy Oct 11, 2017

Member

How is it easier? It's more lines.

@torkleyy

torkleyy Oct 11, 2017

Member

How is it easier? It's more lines.

This comment has been minimized.

@Aceeri

Aceeri Oct 11, 2017

Member

Mainly because I know it by memory,.

@Aceeri

Aceeri Oct 11, 2017

Member

Mainly because I know it by memory,.

This comment has been minimized.

@Rhuagh

Rhuagh Oct 11, 2017

Member

system.run_now(&mut world.res) ;)

@Rhuagh

Rhuagh Oct 11, 2017

Member

system.run_now(&mut world.res) ;)

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 14, 2017

Member

How is this coming along? Any progress? Is it done or ?

Member

Rhuagh commented Oct 14, 2017

How is this coming along? Any progress? Is it done or ?

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Oct 14, 2017

Member

@Rhuagh Got held up for a couple days this week, working on it this weekend.

Member

Aceeri commented Oct 14, 2017

@Rhuagh Got held up for a couple days this week, working on it this weekend.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 14, 2017

Member

Cool

Member

Rhuagh commented Oct 14, 2017

Cool

@nchashch nchashch self-requested a review Oct 15, 2017

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Oct 17, 2017

Member

Been fuzzy testing and I think I've fixed all the issues so far, so we will probably be able to merge this by the end of the week. Going to rebase all my changes later this afternoon.

Member

Aceeri commented Oct 17, 2017

Been fuzzy testing and I think I've fixed all the issues so far, so we will probably be able to merge this by the end of the week. Going to rebase all my changes later this afternoon.

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Oct 17, 2017

Member

Seems @nchashch wants to review this before merge.

Member

torkleyy commented Oct 17, 2017

Seems @nchashch wants to review this before merge.

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Oct 17, 2017

Member

Yep, just updating you all on it.

Member

Aceeri commented Oct 17, 2017

Yep, just updating you all on it.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 18, 2017

Member

Did you rebase against your local develop our the upstream develop?

Member

Rhuagh commented Oct 18, 2017

Did you rebase against your local develop our the upstream develop?

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Oct 18, 2017

Member

It would probably be easier to rewrite this PR at this point. Please re-open if you disagree with me @Aceeri

Member

Xaeroxe commented Oct 18, 2017

It would probably be easier to rewrite this PR at this point. Please re-open if you disagree with me @Aceeri

@Xaeroxe Xaeroxe closed this Oct 18, 2017

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Oct 19, 2017

Member

I disagree, the commits earlier are just an error in git and I just have to drop the commits due to duplicates. Currently fixing the history.

Member

Aceeri commented Oct 19, 2017

I disagree, the commits earlier are just an error in git and I just have to drop the commits due to duplicates. Currently fixing the history.

@Aceeri Aceeri reopened this Oct 19, 2017

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Oct 19, 2017

Member

Issue with commits has been fixed.

Member

Aceeri commented Oct 19, 2017

Issue with commits has been fixed.

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Oct 19, 2017

Member

Do you still consider this to be WIP?

Member

Xaeroxe commented Oct 19, 2017

Do you still consider this to be WIP?

@Aceeri

This comment has been minimized.

Show comment
Hide comment
@Aceeri

Aceeri Oct 19, 2017

Member

Not really, it could use some review though, entirely possible I've missed something.

Member

Aceeri commented Oct 19, 2017

Not really, it could use some review though, entirely possible I've missed something.

@Aceeri Aceeri changed the title from [WIP] Transform System Rewrite/Update to Transform System Rewrite/Update Oct 19, 2017

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 19, 2017

Member

I'll take a look later today.

Member

Rhuagh commented Oct 19, 2017

I'll take a look later today.

amethyst_core/src/transform/systems.rs
@@ -169,17 +185,29 @@ impl<'a> System<'a> for TransformSystem {
index += 1;
}
- self.dirty.clear();
+ println!("with parent updated: {:?}", parented);

This comment has been minimized.

@Rhuagh

Rhuagh Oct 19, 2017

Member

Debug prints should be removed?

@Rhuagh

Rhuagh Oct 19, 2017

Member

Debug prints should be removed?

This comment has been minimized.

@Aceeri

Aceeri Oct 19, 2017

Member

whoops

@Aceeri

Aceeri Oct 19, 2017

Member

whoops

self.dead.clear();
- self.swapped.clear();
}
}
#[cfg(test)]

This comment has been minimized.

@Rhuagh

Rhuagh Oct 19, 2017

Member

Yay, tests!

@Rhuagh

Rhuagh Oct 19, 2017

Member

Yay, tests!

@torkleyy

Nice, but I have a few concerns.

- let _ = entities.delete(entity);
- self.dead.insert(entity);
+ {
+ for (entity, parent) in (&*entities, parents.open().1).join() {

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

We need retain!

@torkleyy

torkleyy Oct 19, 2017

Member

We need retain!

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

But isn't this too heavy given that it would be very rare?

@torkleyy

torkleyy Oct 19, 2017

Member

But isn't this too heavy given that it would be very rare?

This comment has been minimized.

@Aceeri

Aceeri Oct 19, 2017

Member

It is only running on modified parents, so I don't think it should be that heavy.

@Aceeri

Aceeri Oct 19, 2017

Member

It is only running on modified parents, so I don't think it should be that heavy.

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

I'm not sure yet if FlaggedStorage is user friendly enough tbh.

@torkleyy

torkleyy Oct 19, 2017

Member

I'm not sure yet if FlaggedStorage is user friendly enough tbh.

This comment has been minimized.

@Aceeri

Aceeri Oct 19, 2017

Member

Yeah, the issue is you'd have to expose the underlying UnprotectedStorage methods onto Storage if you wanted it to be more straightforward.

@Aceeri

Aceeri Oct 19, 2017

Member

Yeah, the issue is you'd have to expose the underlying UnprotectedStorage methods onto Storage if you wanted it to be more straightforward.

amethyst_core/src/transform/systems.rs
+ initted.push(entity.id());
+ }
+
+ println!("Initialized: {:?}", initted);

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

Another debugging println

@torkleyy

torkleyy Oct 19, 2017

Member

Another debugging println

amethyst_core/src/transform/systems.rs
+ for (_entity, local, global, _) in (&*entities, locals_flagged, &mut globals, !&parents).join() {
+ global.0 = local.matrix();
+ noparents.push(_entity.id());
+ #[cfg(debug_assertions)]

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

Should use debug_assert and global.0.is_finite().

@torkleyy

torkleyy Oct 19, 2017

Member

Should use debug_assert and global.0.is_finite().

amethyst_core/src/transform/systems.rs
+ (&mut locals).open().1.clear_flags();
+ (&mut parents).open().1.clear_flags();
+
+ for bit in (&self.frame_init).iter() {

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

No need for .iter() I think

@torkleyy

torkleyy Oct 19, 2017

Member

No need for .iter() I think

This comment has been minimized.

@Aceeri

Aceeri Oct 20, 2017

Member

Our BitSetLikes don't implement IntoIterator, but they probably should so: slide-rs/hibitset#18

@Aceeri

Aceeri Oct 20, 2017

Member

Our BitSetLikes don't implement IntoIterator, but they probably should so: slide-rs/hibitset#18

+
+use specs::{Component, DenseVecStorage, Entity, FlaggedStorage};
+
+/// Component for defining a parent entity.

This comment has been minimized.

@torkleyy

torkleyy Oct 19, 2017

Member

This documentation should exactly document on which entity one has to place the component. (It's confusing whether this is a "has" relation or an "is parent of").

@torkleyy

torkleyy Oct 19, 2017

Member

This documentation should exactly document on which entity one has to place the component. (It's confusing whether this is a "has" relation or an "is parent of").

This comment has been minimized.

@Rhuagh

Rhuagh Oct 19, 2017

Member

Rename it to HasParent maybe ?

@Rhuagh

Rhuagh Oct 19, 2017

Member

Rename it to HasParent maybe ?

This comment has been minimized.

@omni-viral

omni-viral Oct 21, 2017

Member

Or ChildOf

@omni-viral

omni-viral Oct 21, 2017

Member

Or ChildOf

This comment has been minimized.

@Xaeroxe

Xaeroxe Oct 22, 2017

Member

This was addressed.

@Xaeroxe

Xaeroxe Oct 22, 2017

Member

This was addressed.

amethyst_core/src/transform/systems.rs
// Swap took place, re-try this index.
continue;
}
}
- if local.is_dirty() || child.is_dirty() || self.dirty.contains(&child.parent())
- {
+ // Kill the entity is the parent is dead.

This comment has been minimized.

@torkleyy

torkleyy Oct 21, 2017

Member

"is" should be if

@torkleyy

torkleyy Oct 21, 2017

Member

"is" should be if

amethyst_core/src/transform/systems.rs
- }
+ for (_entity, local, global, _) in (&*entities, locals_flagged, &mut globals, !&parents).join() {
+ global.0 = local.matrix();
+ debug_assert!(global.0 == global.0, format!("Entity {:?} had NaN transform.", _entity));
}

This comment has been minimized.

@torkleyy

torkleyy Oct 21, 2017

Member

Should be is_finite

@torkleyy

torkleyy Oct 21, 2017

Member

Should be is_finite

This comment has been minimized.

@Aceeri

Aceeri Oct 21, 2017

Member

I don't think [[f32; 4]; 4] has methods implemented by default? f32 has is_finite, but not this.

@Aceeri

Aceeri Oct 21, 2017

Member

I don't think [[f32; 4]; 4] has methods implemented by default? f32 has is_finite, but not this.

This comment has been minimized.

@torkleyy

torkleyy Oct 21, 2017

Member

Ah right. I wonder if this is valid then? I'm not sure if the total equality check catches everything is_finite does

@torkleyy

torkleyy Oct 21, 2017

Member

Ah right. I wonder if this is valid then? I'm not sure if the total equality check catches everything is_finite does

This comment has been minimized.

@Aceeri

Aceeri Oct 21, 2017

Member

It doesn't check for Infinity, but I'm not sure if it matters if we allow that or not.

@Aceeri

Aceeri Oct 21, 2017

Member

It doesn't check for Infinity, but I'm not sure if it matters if we allow that or not.

This comment has been minimized.

@torkleyy

torkleyy Oct 21, 2017

Member

If that's the case this check doesn't make too much sense.

@torkleyy

torkleyy Oct 21, 2017

Member

If that's the case this check doesn't make too much sense.

@Rhuagh

Rhuagh approved these changes Oct 22, 2017

@torkleyy

I think this is great!

@Xaeroxe

#403 (comment)

#403 (comment)

I'd just like to re-iterate @torkleyy 's expressed concerns. Even if he's approved the PR I'm still requesting these changes be made.

@Xaeroxe

LGTM, Thanks!

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 22, 2017

Member

Also needs some fixes in the GLTF system (it uses Child atm, needs to be changed to Parent).

Member

Rhuagh commented Oct 22, 2017

Also needs some fixes in the GLTF system (it uses Child atm, needs to be changed to Parent).

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 22, 2017

Member

bors r+

Member

Rhuagh commented Oct 22, 2017

bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors bot Oct 22, 2017

Contributor

👎 Rejected by label

Contributor

bors bot commented Oct 22, 2017

👎 Rejected by label

@Rhuagh Rhuagh removed the status: working label Oct 22, 2017

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 22, 2017

Member

bors r+

Member

Rhuagh commented Oct 22, 2017

bors r+

bors bot added a commit that referenced this pull request Oct 22, 2017

Merge #403
403: Transform System Rewrite/Update r=Rhuagh a=Aceeri

Cleans up the transform system with some new specs features, adds unit tests.

Still plan on adding some tests using `quickcheck` for some more "fuzzy" testing to catch the odd edge cases.

Fixes #336
@bors

This comment has been minimized.

Show comment
Hide comment

@bors bors bot merged commit 8db08a8 into amethyst:develop Oct 22, 2017

3 checks passed

bors Build succeeded
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment