-
-
Notifications
You must be signed in to change notification settings - Fork 741
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original idea behind wrapping specs
was to be able to swap it for something else. But I do welcome this change!
What are the benefits for doing this? |
The only thing |
Can we add the current usage example to the specs repo, I feel like our example is good for explaining in a short way the possibilities specs provide. |
I think this crate should stay if and only if the default Amethyst components and systems from the core crate are moved into this one. Having all this ECS-related functionality in the top-level crate seems somewhat "messy" to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use
path appear quite long, perhaps change specs_batteries
to just ecs
?. Otherwise looks good.
Just noticed the name aswell, I'd prefer something else. |
@nchashch thanks! please rebase and make sure CI passes |
|
||
/// Contains the included Render Targets | ||
pub mod target; | ||
/// Contains the included Passes | ||
pub mod pass; | ||
|
||
use amethyst_ecs::{Component, VecStorage}; | ||
use self::specs::{Component, VecStorage}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't notice this before, but why are we implementing Component
and VecStorage
over here? Since the renderer is meant to be usable outside of the engine and specs
in general, this functionality should be moved up to the top-level crate under amethyst::ecs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done in order to have a Light
Component
without a wrapper type (the way it was implemented before context rewrite PR), since it isn't possible to impl traits for types defined in an outside crate.
So it is either an amethyst::ecs::components::Light
Component
, which wraps a amethyst_renderer::Light
and no specs
import in amethyst_renderer
or a plain amethyst_renderer::Light
Component
with a specs
import.
I guess returning back to a wrapper type would work, but it is less convenient to access the Light
Component
this way. Instead of getting say light.color
you would have to get light.light.color
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do we really need to wrap it? Can't we implement the Component
trait directly onto the Light
from inside the engine crate instead of the renderer? It seems like the current method causes a circular dependency, which defeats the purpose of having amethyst_renderer
as a separate, modular crate entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I think if we wanted to return Light
wrapper type (or PointLight
/DirectionalLight
wrappers since #166) it would be better to do this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do we really need to wrap it? Can't we implement the Component trait directly onto the Light from inside the engine crate instead of the renderer? It seems like the current method causes a circular dependency, which defeats the purpose of having amethyst_renderer as a separate, modular crate entirely.
Currently it is impossible to directly impl an external trait for an external type (there is rust-lang/rfcs#493, so this might change for private trait impls in the future). AFAIK the only way to do this is to use a wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've messed around with implementing external traits on external types, and there doesn't seem to be any hacks or workarounds. Thanks for directing me to rust-lang/rfcs#493; I'll be following the issue very closely! In the meantime, I don't want to hold up the review process. We'll hopefully revisit this later in the future if and when Rust catches up. You've got my approval! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't DerefMut
fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Emilgardis Indeed, implementing DerefMut
would add some syntactic sugar that makes the code look a little prettier. However, it does not resolve the core problem that we are pulling in specs
as a dependency of amethyst_renderer
when it really doesn't need to be. The only reason the renderer is being kept outside the top-level crate is because it's intended to be usable outside of amethyst and specs. But that's out of the scope of this PR, so I'll open a new issue about it.
* Naming change: Now Processors are called Systems
Changes: * Move world_resources to specs_batteries::resources * Move components module to specs_batteries::components * Move systems module to specs_batteries::systems
Changes:
amethyst_ecs
sub crate.specs
is now used directly.Processor
s are now calledSystem
s.Update:
specs_batteries
module.world_resources
tospecs_batteries::resources
.components
tospecs_batteries::components
.systems
tospecs_batteries::systems
.Update 2:
specs_batteries
toecs
.