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: Add prefab loading #716

Merged
merged 1 commit into from Jun 12, 2018

Conversation

@Rhuagh
Member

Rhuagh commented May 15, 2018


This change is Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy May 15, 2018

Member

Wow could we merge those formatting changes in a separate PR?

Member

torkleyy commented May 15, 2018

Wow could we merge those formatting changes in a separate PR?

@Xaeroxe

Nicely done!

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 16, 2018

Member

This should be cleaner now with the formatting shit out of the way.

Member

Rhuagh commented May 16, 2018

This should be cleaner now with the formatting shit out of the way.

@Xaeroxe Xaeroxe referenced this pull request May 16, 2018

Closed

0.7 release #677

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy May 17, 2018

Member

Is this ready for review?

Member

torkleyy commented May 17, 2018

Is this ready for review?

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy May 17, 2018

Member

Reviewed 7 of 18 files at r1.
Review status: 6 of 17 files reviewed at latest revision, all discussions resolved.


amethyst_assets/Cargo.toml, line 33 at r1 (raw file):

rayon = "1.0.1"
serde = { version = "1", features = ["serde_derive"] }
shred = { version = "0.7" }

Ah, so the strategy with amethyst_core doesn't work everywhere..


amethyst_core/src/transform/components/mod.rs, line 13 at r1 (raw file):

/// Prefab component data for Transform
#[derive(Default, Deserialize, Serialize, Debug, Clone)]
pub struct TransformPrefabData {

Is this extra struct necessary?


examples/prefab/README.md, line 1 at r1 (raw file):

# Prefab Example

I don't see why we'd need a readme in every example directory. It's more important to have them all listed in examples/README.md


examples/prefab/resources/display_config.ron, line 7 at r1 (raw file):

  fullscreen: false,
  multisampling: 0,
  title: "Assets example",

"Prefab example"


examples/prefab/resources/display_config.ron, line 9 at r1 (raw file):

  title: "Assets example",
  visibility: true,
  vsync: true,

This was causing problems on some platforms, I think we turned them off by default because of that. Maybe it's fixed though?


Comments from Reviewable

Member

torkleyy commented May 17, 2018

Reviewed 7 of 18 files at r1.
Review status: 6 of 17 files reviewed at latest revision, all discussions resolved.


amethyst_assets/Cargo.toml, line 33 at r1 (raw file):

rayon = "1.0.1"
serde = { version = "1", features = ["serde_derive"] }
shred = { version = "0.7" }

Ah, so the strategy with amethyst_core doesn't work everywhere..


amethyst_core/src/transform/components/mod.rs, line 13 at r1 (raw file):

/// Prefab component data for Transform
#[derive(Default, Deserialize, Serialize, Debug, Clone)]
pub struct TransformPrefabData {

Is this extra struct necessary?


examples/prefab/README.md, line 1 at r1 (raw file):

# Prefab Example

I don't see why we'd need a readme in every example directory. It's more important to have them all listed in examples/README.md


examples/prefab/resources/display_config.ron, line 7 at r1 (raw file):

  fullscreen: false,
  multisampling: 0,
  title: "Assets example",

"Prefab example"


examples/prefab/resources/display_config.ron, line 9 at r1 (raw file):

  title: "Assets example",
  visibility: true,
  vsync: true,

This was causing problems on some platforms, I think we turned them off by default because of that. Maybe it's fixed though?


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 17, 2018

Member

You can review, but it's not even close to complete :)

Member

Rhuagh commented May 17, 2018

You can review, but it's not even close to complete :)

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 17, 2018

Member

Review status: 6 of 17 files reviewed at latest revision, 4 unresolved discussions.


amethyst_core/src/transform/components/mod.rs, line 13 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Is this extra struct necessary?

Not really, no, I could make the impl PrefabData for Transform add GlobalTransform::default() instead, and just use Transform directly.


examples/prefab/README.md, line 1 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I don't see why we'd need a readme in every example directory. It's more important to have them all listed in examples/README.md

I just copied the assets example, not cleaned up yet, but I agree.


examples/prefab/resources/display_config.ron, line 9 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

This was causing problems on some platforms, I think we turned them off by default because of that. Maybe it's fixed though?

They're still on in most examples? If you don't use vsync some platforms get thread starvation problems I believe.


Comments from Reviewable

Member

Rhuagh commented May 17, 2018

Review status: 6 of 17 files reviewed at latest revision, 4 unresolved discussions.


amethyst_core/src/transform/components/mod.rs, line 13 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Is this extra struct necessary?

Not really, no, I could make the impl PrefabData for Transform add GlobalTransform::default() instead, and just use Transform directly.


examples/prefab/README.md, line 1 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

I don't see why we'd need a readme in every example directory. It's more important to have them all listed in examples/README.md

I just copied the assets example, not cleaned up yet, but I agree.


examples/prefab/resources/display_config.ron, line 9 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

This was causing problems on some platforms, I think we turned them off by default because of that. Maybe it's fixed though?

They're still on in most examples? If you don't use vsync some platforms get thread starvation problems I believe.


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 17, 2018

Member

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


Comments from Reviewable

Member

Rhuagh commented May 17, 2018

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


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 17, 2018

Member

Review status: 11 of 17 files reviewed at latest revision, 4 unresolved discussions.


amethyst_assets/Cargo.toml, line 33 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Ah, so the strategy with amethyst_core doesn't work everywhere..

No, derive requires it to be at base level :/ We should look at how serde do derive for shred.


Comments from Reviewable

Member

Rhuagh commented May 17, 2018

Review status: 11 of 17 files reviewed at latest revision, 4 unresolved discussions.


amethyst_assets/Cargo.toml, line 33 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

Ah, so the strategy with amethyst_core doesn't work everywhere..

No, derive requires it to be at base level :/ We should look at how serde do derive for shred.


Comments from Reviewable

@omni-viral

I like it mostly. But it seems a bit more complex than necessary.

+
+/// Prefab component data for Transform
+#[derive(Default, Deserialize, Serialize, Debug, Clone)]
+pub struct TransformPrefabData {

This comment has been minimized.

@omni-viral

omni-viral May 17, 2018

Member

Can't you implement PrefabData for Transform directly?

@omni-viral

omni-viral May 17, 2018

Member

Can't you implement PrefabData for Transform directly?

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 17, 2018

Member

The complexity needs to be there I believe, I will demonstrate later why. The first prefab data entries are simple to load, the animation stuff as an example is much more complex

Member

Rhuagh commented May 17, 2018

The complexity needs to be there I believe, I will demonstrate later why. The first prefab data entries are simple to load, the animation stuff as an example is much more complex

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy May 26, 2018

Member

👍 I really love this PR, looks like a lot of work to review though. This will be really helpful for the usability of the engine. Please tell me if there's any part of this that can be reviewed already.

Member

torkleyy commented May 26, 2018

👍 I really love this PR, looks like a lot of work to review though. This will be really helpful for the usability of the engine. Please tell me if there's any part of this that can be reviewed already.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 26, 2018

Member

I believe most of this is ready for review now. I'm gonna add a chapter to the book as part of the PR also. Will write that tomorrow hopefully.


Review status: 1 of 81 files reviewed at latest revision, 5 unresolved discussions.


examples/prefab/resources/display_config.ron, line 7 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

"Prefab example"

Done.


Comments from Reviewable

Member

Rhuagh commented May 26, 2018

I believe most of this is ready for review now. I'm gonna add a chapter to the book as part of the PR also. Will write that tomorrow hopefully.


Review status: 1 of 81 files reviewed at latest revision, 5 unresolved discussions.


examples/prefab/resources/display_config.ron, line 7 at r1 (raw file):

Previously, torkleyy (Thomas Schaller) wrote…

"Prefab example"

Done.


Comments from Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy May 27, 2018

Member

Review status: 7 of 81 files reviewed at latest revision, 5 unresolved discussions.


Comments from Reviewable

Member

torkleyy commented May 27, 2018

Review status: 7 of 81 files reviewed at latest revision, 5 unresolved discussions.


Comments from Reviewable

@torkleyy

A book chapter would be tops :)

@omni-viral

Could you write how loading of complex prefab will look like?

amethyst_animation/src/prefab.rs
+pub struct AnimationPrefab<T>
+where
+ T: AnimationSampling,
+ T::Channel: for<'a> Deserialize<'a> + Serialize,

This comment has been minimized.

@omni-viral

omni-viral May 28, 2018

Member

Please, minimize trait bounds on struct and enum definitions.
Those for<'a> Deserialize<'a> + Serialize seems unnecessary here.

@omni-viral

omni-viral May 28, 2018

Member

Please, minimize trait bounds on struct and enum definitions.
Those for<'a> Deserialize<'a> + Serialize seems unnecessary here.

This comment has been minimized.

@Rhuagh

Rhuagh May 28, 2018

Member

They are required for deriving Deserialize/Serialize, without them it won't build.

@Rhuagh

Rhuagh May 28, 2018

Member

They are required for deriving Deserialize/Serialize, without them it won't build.

amethyst_animation/src/prefab.rs
+impl<'a, T> PrefabData<'a> for AnimationPrefab<T>
+where
+ T: AnimationSampling,
+ T::Channel: for<'b> Deserialize<'b> + Serialize,

This comment has been minimized.

@omni-viral

omni-viral May 28, 2018

Member

Maybe DeserializeOwned?

@omni-viral

omni-viral May 28, 2018

Member

Maybe DeserializeOwned?

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

That would probably be preferable as for<'b> Deserialize<'b> is effectively synonymous with DeserializeOwned. You can't meet that criteria without meeting DeserializeOwned.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

That would probably be preferable as for<'b> Deserialize<'b> is effectively synonymous with DeserializeOwned. You can't meet that criteria without meeting DeserializeOwned.

amethyst_assets/src/prefab/mod.rs
+ type HandleStorage = FlaggedStorage<Handle<Self>, DenseVecStorage<Handle<Self>>>;
+}
+
+impl<T> Into<Result<Prefab<T>, Error>> for Prefab<T> {

This comment has been minimized.

@omni-viral

omni-viral May 28, 2018

Member

This confuses me.
Why not perform conversion manually?

@omni-viral

omni-viral May 28, 2018

Member

This confuses me.
Why not perform conversion manually?

This comment has been minimized.

@Rhuagh

Rhuagh May 28, 2018

Member

Not sure if this is actually required anymore, it's a remnant of the old gltf loader system.

@Rhuagh

Rhuagh May 28, 2018

Member

Not sure if this is actually required anymore, it's a remnant of the old gltf loader system.

+ .load_prefab(
+ self.entities[index],
+ &mut prefab_system_data,
+ &self.entities,

This comment has been minimized.

@omni-viral

omni-viral May 28, 2018

Member

How exactly PrefabData must know how to interpret those entities?

@omni-viral

omni-viral May 28, 2018

Member

How exactly PrefabData must know how to interpret those entities?

This comment has been minimized.

@Rhuagh

Rhuagh May 28, 2018

Member

This should be documented on Prefab and PrefabData. If not, I need to add it.

@Rhuagh

Rhuagh May 28, 2018

Member

This should be documented on Prefab and PrefabData. If not, I need to add it.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 30, 2018

Member

Most of the features needed are in place now, the big glaring weaknesses are that it's not possible to target existing entities from inside a prefab (except for the entity the prefab handle is placed on), and there's no caching of assets for the most part. Some of the prefab impls can cache internally, but not all of them. I'd also like to consolidate some of the assets prefab implementations.

But all of those can be deferred for later PRs, the system is possible to work with now.

Member

Rhuagh commented May 30, 2018

Most of the features needed are in place now, the big glaring weaknesses are that it's not possible to target existing entities from inside a prefab (except for the entity the prefab handle is placed on), and there's no caching of assets for the most part. Some of the prefab impls can cache internally, but not all of them. I'd also like to consolidate some of the assets prefab implementations.

But all of those can be deferred for later PRs, the system is possible to work with now.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 30, 2018

Member

Conceptually, a prefab is a list of entities, where the first entry in the list refers to the "main" entity, i.e. the entity the prefab handle is placed. All other entries in the list will spawn a new entity when instantiated.

Each entry in the list contains an optional parent index and an optional data container. The data container is a generic type that implement PrefabData.

When a prefab is loaded it is processed in two stages:

Sub asset loading:

This is kicked off during AssetStorage::process in the PrefabLoaderSystem, and basically do a depth first visit in the data container and starts any secondary asset loading needed, such as reading other assets from disc, or transferring data to GPU memory etc. When doing so it creates an internal ProgressCounter, and if any secondary loads were started, it will not finish the process, but instead return a result that signifies to the storage that it needs to reprocessed at a later stage. During this visit walk, the data can morph inside the prefab, as an example, if there are AssetPrefabs inside, it will trigger a load of the asset, and replace itself with the returned handle.

Once all sub loading has completed (it will use the internally created ProgressCounter to track this), it will signal done to AssetStorage::process, which in turn will update the progress tracker on the higher level prefab load etc up to the user requested level. Once this is complete all data has been read from disc, and resides somewhere in memory (either on gfx card or ram).

Prefab instantiation:

This happens when a prefab handle is added onto an Entity, and at this point the data in the prefab is basically cloned and an entity hierarchy is created with the main entity as the root. The prefab data is immutable at this point.

Member

Rhuagh commented May 30, 2018

Conceptually, a prefab is a list of entities, where the first entry in the list refers to the "main" entity, i.e. the entity the prefab handle is placed. All other entries in the list will spawn a new entity when instantiated.

Each entry in the list contains an optional parent index and an optional data container. The data container is a generic type that implement PrefabData.

When a prefab is loaded it is processed in two stages:

Sub asset loading:

This is kicked off during AssetStorage::process in the PrefabLoaderSystem, and basically do a depth first visit in the data container and starts any secondary asset loading needed, such as reading other assets from disc, or transferring data to GPU memory etc. When doing so it creates an internal ProgressCounter, and if any secondary loads were started, it will not finish the process, but instead return a result that signifies to the storage that it needs to reprocessed at a later stage. During this visit walk, the data can morph inside the prefab, as an example, if there are AssetPrefabs inside, it will trigger a load of the asset, and replace itself with the returned handle.

Once all sub loading has completed (it will use the internally created ProgressCounter to track this), it will signal done to AssetStorage::process, which in turn will update the progress tracker on the higher level prefab load etc up to the user requested level. Once this is complete all data has been read from disc, and resides somewhere in memory (either on gfx card or ram).

Prefab instantiation:

This happens when a prefab handle is added onto an Entity, and at this point the data in the prefab is basically cloned and an entity hierarchy is created with the main entity as the root. The prefab data is immutable at this point.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh May 31, 2018

Member

After #760 .

Member

Rhuagh commented May 31, 2018

After #760 .

@Rhuagh Rhuagh added status: ready and removed status: working labels Jun 8, 2018

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jun 8, 2018

Member

This is now ready, this is just the first stage, I have atleast 4 followup PRs that add additional things on top of this:

  • Convert GLTF loader to use this
  • UI specific ron based format
  • Shape prefabs
  • Basic scene utility prefabs
  • Examples improvements
Member

Rhuagh commented Jun 8, 2018

This is now ready, this is just the first stage, I have atleast 4 followup PRs that add additional things on top of this:

  • Convert GLTF loader to use this
  • UI specific ron based format
  • Shape prefabs
  • Basic scene utility prefabs
  • Examples improvements
@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

This looks great! Thanks!

I've got a few doc nits here and there. My biggest concern with this as it stands is that the prefab interpretation requires advance knowledge on the component types in the prefab files. I don't have a good solution for this right now so I can't block on it but I'd really like to be able to create a loader that can "discover" the type of the component as it goes, even for custom user components.

I'm aware this isn't a reasonable ask at this time though. I'll probably refactor this as soon as I come up with a viable way to do this.

amethyst_animation/src/prefab.rs
+ }
+}
+
+/// `PrefaData` for loading `Animation`s as part of an `AnimationSet`.

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

Missed a "b"

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

Missed a "b"

amethyst_animation/src/prefab.rs
+impl<'a, T> PrefabData<'a> for AnimationPrefab<T>
+where
+ T: AnimationSampling,
+ T::Channel: for<'b> Deserialize<'b> + Serialize,

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

That would probably be preferable as for<'b> Deserialize<'b> is effectively synonymous with DeserializeOwned. You can't meet that criteria without meeting DeserializeOwned.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

That would probably be preferable as for<'b> Deserialize<'b> is effectively synonymous with DeserializeOwned. You can't meet that criteria without meeting DeserializeOwned.

amethyst_renderer/src/formats/mtl.rs
+ pub caveat_id: Option<u64>,
+ /// Set material as `Transparent`
+ pub transparent: bool,
+ ///

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

Missing doc

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

Missing doc

amethyst_renderer/src/shape.rs
@@ -1,8 +1,8 @@
use amethyst_assets::{AssetStorage, Loader, Progress};
use amethyst_core::cgmath::{InnerSpace, Vector3};
use amethyst_core::specs::prelude::{Read, ReadExpect};
-use genmesh::generators::{/*Circle, */Cone, Cube, Cylinder, IcoSphere, IndexedPolygon, Plane,
- SharedVertex, SphereUv, Torus};
+use genmesh::generators::{/*Circle, */ Cone, Cube, Cylinder, IcoSphere, IndexedPolygon,

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

Remove commented out code please

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

Remove commented out code please

+`Prefab` refers to this `Entity`. All other entries in the list will spawn a new `Entity` on
+instantiation.
+
+NOTE: This means that we currently cannot target multiple existing entities from a single `Prefab`.

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

What does it take to remove this restriction? It's pretty easy to run into this in say an RTS game.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

What does it take to remove this restriction? It's pretty easy to run into this in say an RTS game.

This comment has been minimized.

@Rhuagh

Rhuagh Jun 12, 2018

Member

I don't know at this point, I've not thought about it a lot. You'll need some kind of persistent addressing scheme for the entities, probably Marker from saveload. It is also fairly simple to cause UB with that, because you can easily create hierarchy loops.

@Rhuagh

Rhuagh Jun 12, 2018

Member

I don't know at this point, I've not thought about it a lot. You'll need some kind of persistent addressing scheme for the entities, probably Marker from saveload. It is also fairly simple to cause UB with that, because you can easily create hierarchy loops.

examples/prefab/main.rs
+}
+
+/// Wrapper around the main, so we can return errors easily.
+fn run() -> Result<(), Error> {

This comment has been minimized.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

This run function is no longer necessary, main() can return results. This should mimic the other examples.

@Xaeroxe

Xaeroxe Jun 12, 2018

Member

This run function is no longer necessary, main() can return results. This should mimic the other examples.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jun 12, 2018

Member

@Xaeroxe i don't see a way to do dynamic loading. At some point you'll need to insert into component storage and there you will need the type, and there's no way to create types at runtime. You'd need to do things completely unsafe, transmuting raw pointers most likely.

Member

Rhuagh commented Jun 12, 2018

@Xaeroxe i don't see a way to do dynamic loading. At some point you'll need to insert into component storage and there you will need the type, and there's no way to create types at runtime. You'd need to do things completely unsafe, transmuting raw pointers most likely.

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Jun 12, 2018

Member

@Rhuagh I was thinking more along the lines of trait objects and a HashMap between a type identifier string and the function required to insert the component. Said function would have to take a Deserializer parameter and perform its own deserialization of the data. Since the type can't be predicted in advance it'd probably rely on lazy updates very heavily. I'm not sure how many problems I'd run into while trying to implement this but it's such a big add-on to the existing work that I'd rather not block this PR on it.

Member

Xaeroxe commented Jun 12, 2018

@Rhuagh I was thinking more along the lines of trait objects and a HashMap between a type identifier string and the function required to insert the component. Said function would have to take a Deserializer parameter and perform its own deserialization of the data. Since the type can't be predicted in advance it'd probably rely on lazy updates very heavily. I'm not sure how many problems I'd run into while trying to implement this but it's such a big add-on to the existing work that I'd rather not block this PR on it.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jun 12, 2018

Member

That would make it difficult to deserialize the data in advance of usage I believe.

Member

Rhuagh commented Jun 12, 2018

That would make it difficult to deserialize the data in advance of usage I believe.

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Jun 12, 2018

Member

That's true. So perhaps what you'd want to do instead is deserialize it using similar techniques but rather than inserting the components you keep them in the prefab structure wrapped in a Vec of Box<Fn(&LazyUpdate, Entity)> where each Fn(&LazyUpdate, Entity) is a closure that captures the component and inserts it with LazyUpdate when the closure is called.

Member

Xaeroxe commented Jun 12, 2018

That's true. So perhaps what you'd want to do instead is deserialize it using similar techniques but rather than inserting the components you keep them in the prefab structure wrapped in a Vec of Box<Fn(&LazyUpdate, Entity)> where each Fn(&LazyUpdate, Entity) is a closure that captures the component and inserts it with LazyUpdate when the closure is called.

@Xaeroxe

LGTM! Thanks!

feat: Core support for prefab loading
feat: Add book chapter about prefabs
@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Jun 12, 2018

Member

bors r+

Member

Xaeroxe commented Jun 12, 2018

bors r+

bors bot added a commit that referenced this pull request Jun 12, 2018

Merge #716
716: feat: Add prefab loading r=Xaeroxe a=Rhuagh


<!-- 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/716)
<!-- Reviewable:end -->


Co-authored-by: Simon Rönnberg <seamonr@gmail.com>
@bors

This comment has been minimized.

Show comment
Hide comment

@bors bors bot merged commit a9bed44 into amethyst:develop Jun 12, 2018

3 of 4 checks passed

code-review/reviewable 43 files, 14 discussions left (omni-viral, Rhuagh, torkleyy, Xaeroxe)
Details
bors Build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

Make the engine more data-driven automation moved this from In progress to Done Jun 12, 2018

@Rhuagh Rhuagh deleted the Rhuagh:feature/prefab-loading branch Jun 13, 2018

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