Timeline for Efficient removal and adding of Components in ECS
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 20, 2015 at 12:46 | vote | accept | VaTTeRGeR | ||
| Jun 20, 2015 at 12:09 | answer | added | junkdog | timeline score: 4 | |
| Jun 19, 2015 at 21:38 | answer | added | VaTTeRGeR | timeline score: 1 | |
| Jun 19, 2015 at 21:30 | comment | added | VaTTeRGeR | Thankfully, changing the Array to use an ObjectMap(Entity ID to Array-Index) for indexing allowed it to do ~35000 Component removes+adds+movement in 50ms, that should be more than fast enough! | |
| Jun 19, 2015 at 20:49 | comment | added | VaTTeRGeR | That is what i thought about initially. I'm right now trying to subclass Array with added Entity to Index mapping, it may already provide the needed performance boost. If that doesn't work i'll try to implement what you suggested! Thanks for your help! | |
| Jun 19, 2015 at 20:42 | comment | added | Waterlimon | You are correct. A better approach might be to rebuild the family entity list at end of frame instead of removing individual entities throughout the frame. Can you try buffering the component removals/additions, then at end of frame remove the family, execute the buffered changes, then recreate the family? | |
| Jun 19, 2015 at 20:26 | comment | added | VaTTeRGeR | In the "Engine.java" method "updateFamilyMembership" [L.341] is a call to "familyEntities.removeValue(entity, true)";[L363] which goes through an Array (libGDX implementation) that holds the Familys Entities to find the one that needs to be deleted, because no Index is given to delete it efficiently. My guess is that this call takes very long to execute if a Family contains many Entities | |
| Jun 19, 2015 at 20:15 | comment | added | Waterlimon | Looking at the source, are you sure its O(N) to the number of entities? To me it seems its O(N) to the number of existing families to update some properties of the entity. The only expensive thing seems to be fetching an immutable array of all entities belonging to a family, which will be free if no changes were made, and otherwise cost O(N) to number of entities (regardless of how many changes were made) | |
| Jun 19, 2015 at 19:12 | history | asked | VaTTeRGeR | CC BY-SA 3.0 |