Post by Admin on Jul 16, 2016 3:47:49 GMT
Maxim Zaks @mzaks Aug 09 2015 06:42
@bcatcho very cool. Looking forward to read all the posts
Brandon Catcho @bcatcho Aug 09 2015 10:12
Does anyone have any good examples of working with multiple pools? I have some entities that don’t need to be apart of a Lock-Step simulation and can be run in a LateUpdate. I feel like they should be in a separate pool (though they would share many of the same components and possibly a few systems).
I’m trying to wrap my head around how to organize and impliment this?
Brandon Catcho @bcatcho Aug 09 2015 11:52
Ok after noticing the menu in Unity's preference pane (https://github.com/sschmid/Entitas-CSharp/wiki/Generate-your-first-component) I figured out how to set up multiple pools, assigned the correct attributes to the current components and updated all of my matchers.
However, I noticed that you can only have one entity per component. I mean, you can put two different pool attributes on a component but the last attribute always clobbers the others. Is sharing a component between multiple pool types bad practice or is this just a roadmap feature?
Duplicating components seems hairy. If I duplicate a Position component I will have to change one of their names or namespace. And given that I’m striving to make components ultra-minimal duplication seems wasteful. On the flip side a change to one version of a duplicated component is less impactful to the codebase as a whole.
dweawyn @dweawyn Aug 09 2015 14:28
At the moment, you cannot add components from different pools on the same entity. See sschmid/Entitas-CSharp#12
Brandon Catcho @bcatcho Aug 09 2015 14:53
Thats not what my issue is. I'm looking to apply the same sort of component to two different entities in two different pools. But I'll take a look at that and the other issues just in case it is represented there
Maxim Zaks @mzaks Aug 09 2015 17:07
We are currently working on following
[Pool("PoolA"), Pool("PoolB"), Pool("PoolC")]
public class MyComponent : IComponent {
}
Should be in, in a couple of days.
Maxim Zaks @mzaks Aug 09 2015 17:35
I guess I can explain why it was not supported before.
As you already know entity is backed by array for performance reasons. This means that every component type has an index in the array, and every entity is created with an array size of (number of component types)
When you have lots of components you might end up with poor memory footprint.
We introduced multiple pools to be able to create entities of different array sizes.
Let's say you have a 20 components which are annotated with Core pool, and 5 which are annotated with Meta pool. Than if you create an entity from Core pool, it will be backed by an array of length 20, and when you create an entity from Meta pool you will end up with an array of only 5 entries.
However you have to understand that by creating multiple pools you create two distinct lookups from component type to index in an array. That's why sschmid/Entitas-CSharp#12 is an issue.
We will fix it by being smart about component type to index in array map. However this is still work in progress.
@bcatcho in you case you have to think if you need a different pool type, or just another instance of the same pool type. Different pool types make sense if your component types not overlap much. Another pool instance make sense if you want to run a parallel simulation, let's say on another thread.
@bcatcho very cool. Looking forward to read all the posts
Brandon Catcho @bcatcho Aug 09 2015 10:12
Does anyone have any good examples of working with multiple pools? I have some entities that don’t need to be apart of a Lock-Step simulation and can be run in a LateUpdate. I feel like they should be in a separate pool (though they would share many of the same components and possibly a few systems).
I’m trying to wrap my head around how to organize and impliment this?
Brandon Catcho @bcatcho Aug 09 2015 11:52
Ok after noticing the menu in Unity's preference pane (https://github.com/sschmid/Entitas-CSharp/wiki/Generate-your-first-component) I figured out how to set up multiple pools, assigned the correct attributes to the current components and updated all of my matchers.
However, I noticed that you can only have one entity per component. I mean, you can put two different pool attributes on a component but the last attribute always clobbers the others. Is sharing a component between multiple pool types bad practice or is this just a roadmap feature?
Duplicating components seems hairy. If I duplicate a Position component I will have to change one of their names or namespace. And given that I’m striving to make components ultra-minimal duplication seems wasteful. On the flip side a change to one version of a duplicated component is less impactful to the codebase as a whole.
dweawyn @dweawyn Aug 09 2015 14:28
At the moment, you cannot add components from different pools on the same entity. See sschmid/Entitas-CSharp#12
Brandon Catcho @bcatcho Aug 09 2015 14:53
Thats not what my issue is. I'm looking to apply the same sort of component to two different entities in two different pools. But I'll take a look at that and the other issues just in case it is represented there
Maxim Zaks @mzaks Aug 09 2015 17:07
We are currently working on following
[Pool("PoolA"), Pool("PoolB"), Pool("PoolC")]
public class MyComponent : IComponent {
}
Should be in, in a couple of days.
Maxim Zaks @mzaks Aug 09 2015 17:35
I guess I can explain why it was not supported before.
As you already know entity is backed by array for performance reasons. This means that every component type has an index in the array, and every entity is created with an array size of (number of component types)
When you have lots of components you might end up with poor memory footprint.
We introduced multiple pools to be able to create entities of different array sizes.
Let's say you have a 20 components which are annotated with Core pool, and 5 which are annotated with Meta pool. Than if you create an entity from Core pool, it will be backed by an array of length 20, and when you create an entity from Meta pool you will end up with an array of only 5 entries.
However you have to understand that by creating multiple pools you create two distinct lookups from component type to index in an array. That's why sschmid/Entitas-CSharp#12 is an issue.
We will fix it by being smart about component type to index in array map. However this is still work in progress.
@bcatcho in you case you have to think if you need a different pool type, or just another instance of the same pool type. Different pool types make sense if your component types not overlap much. Another pool instance make sense if you want to run a parallel simulation, let's say on another thread.