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

Refactoring Camera as a Component #440

Merged
merged 2 commits into from Oct 23, 2017

Conversation

@Rhuagh
Member

Rhuagh commented Oct 21, 2017

Render pass use Transform of Camera entity to compute the view matrix.

@torkleyy

..and is great, too!

@@ -138,7 +140,8 @@ where
..
} = self;
- let camera = &camera;
+ // TODO: multiple cameras
+ let camera = (&camera, &global).join().next();

This comment has been minimized.

@torkleyy

torkleyy Oct 21, 2017

Member

Maybe log an error in case next().is_some()

@torkleyy

torkleyy Oct 21, 2017

Member

Maybe log an error in case next().is_some()

This comment has been minimized.

@torkleyy

torkleyy Oct 21, 2017

Member

But then again I'm not sure if we should do this everywhere

@torkleyy

torkleyy Oct 21, 2017

Member

But then again I'm not sure if we should do this everywhere

@minecrawler

This comment has been minimized.

Show comment
Hide comment
@minecrawler

minecrawler Oct 21, 2017

Contributor

Hey, that's half my PR, however you cleared up one of my major pain points, so that's really awesome :D

  1. If possible, could you add the ActiveCamera component we talked about over there, so multiple cameras are possible? Only always take the first ActiveCamera!
  2. Shouldn't a camera have both, Transform and LocalTransform, for example in case you want the camera to follow a mesh? (I hope I got the purpose of LocalTransform right this time)
Contributor

minecrawler commented Oct 21, 2017

Hey, that's half my PR, however you cleared up one of my major pain points, so that's really awesome :D

  1. If possible, could you add the ActiveCamera component we talked about over there, so multiple cameras are possible? Only always take the first ActiveCamera!
  2. Shouldn't a camera have both, Transform and LocalTransform, for example in case you want the camera to follow a mesh? (I hope I got the purpose of LocalTransform right this time)
@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 21, 2017

Member

For 2. That's up to the user, a LocalTransform will always be converted to a Transform before arriving in the renderer, this is done by Transformsystem.

Member

Rhuagh commented Oct 21, 2017

For 2. That's up to the user, a LocalTransform will always be converted to a Transform before arriving in the renderer, this is done by Transformsystem.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 21, 2017

Member

For 1. I'm still debating solutions to this problem

Member

Rhuagh commented Oct 21, 2017

For 1. I'm still debating solutions to this problem

@omni-viral

Nice!

@omni-viral

This comment has been minimized.

Show comment
Hide comment
@omni-viral

omni-viral Oct 21, 2017

Member

ActiveCamera as optional resource is better. Otherwise changing active camera will have more boilerplate.

Member

omni-viral commented Oct 21, 2017

ActiveCamera as optional resource is better. Otherwise changing active camera will have more boilerplate.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 21, 2017

Member

I think I'm gonna add ActiveViewport in a later PR

Member

Rhuagh commented Oct 21, 2017

I think I'm gonna add ActiveViewport in a later PR

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 21, 2017

Member

I will add the active camera resource for now, as optional, fallback to first camera if its not set, and fallback to identity from that

Member

Rhuagh commented Oct 21, 2017

I will add the active camera resource for now, as optional, fallback to first camera if its not set, and fallback to identity from that

+ .and_then(|a| {
+ let cam = camera.get(a.entity);
+ let transform = global.get(a.entity);
+ cam.into_iter().zip(transform.into_iter()).next()

This comment has been minimized.

@omni-viral

omni-viral Oct 21, 2017

Member

This is unusual but good alternative to cam.and_then(|cam| transform.map(|transform| (cam, transform))) 😄

@omni-viral

omni-viral Oct 21, 2017

Member

This is unusual but good alternative to cam.and_then(|cam| transform.map(|transform| (cam, transform))) 😄

This comment has been minimized.

@Rhuagh

Rhuagh Oct 22, 2017

Member

That one doesn't work because of borrow rules.

@Rhuagh

Rhuagh Oct 22, 2017

Member

That one doesn't work because of borrow rules.

@Xaeroxe

I love it! This was how it should have been all along imo.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
Member

Rhuagh commented Oct 22, 2017

r? @Aceeri

Rhuagh added some commits Oct 21, 2017

Add as an optional resources to control which camera to use for rende…
…ring. Will fallback to the first camera in the component list if the resource does not exist.
@Aceeri

Aceeri approved these changes Oct 23, 2017

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Oct 23, 2017

Member

bors r+

Member

Rhuagh commented Oct 23, 2017

bors r+

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

Merge #440
440: Refactoring Camera as a Component r=Rhuagh a=Rhuagh

 Render pass use Transform of Camera entity to compute the view matrix.
@bors

This comment has been minimized.

Show comment
Hide comment

@bors bors bot merged commit 475b692 into amethyst:develop Oct 23, 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

@Rhuagh Rhuagh deleted the Rhuagh:refactor-camera branch Oct 23, 2017

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