Jecs - Optimizing declarative scene graphs with ECS

Thanks Ukendio, this ECS is goat.

1 Like

If I were to implementing a health or position component, is there a correct way of altering the value of an instance when this happens? Like the position of a part, model or health of a humanoid?

I would assume this would happen in a system right before or after calling :set to update the value, then again some entities would update a part while others would update a model or ui or pure data…

Would a move system have a loop for each case like ā€˜has Position and MoveablePart’, ā€˜has Position and MoveableModel’?

I believe an example or demo involving updating instances would be very useful and much more practical. If I have missed it then I’m sorry. It’s actually a little frustrating that I cannot see anh documentation about it, but perhaps that just means it’s up to me (or I’m blind) :sweat_smile:

Generally I have a Renderable component which is just any PV instance that can use PivotTo and then I have a specialized Assembly which is a model whose parts are unanchored and welded together. This is useful for updating or reconciling predicted transforms.

But no, there’s not really any correct way to do things but there are ways to ensure your data is well normalized, as in following basic rules of 1NF, 2NF and 3NF. To learn more about these normal forms check out this chapter of the book data oriented design by Richard Fabian. Good normalization will make for better joins (i.e. queries) and that is ultimately the goal with ensuring that your systems establish requirements or constraints for the data.

2 Likes

hmm, is there any way to create a ā€œhasdamageupdatesā€ component, thereby filtering all entities with health but that haven’t been damaged? the issue i see with this is that i don’t know how jecs handles filtering, so it might get the data for all the other components, see that the entity doesn’t have ā€œhasdamageupdatesā€, then drop all that data
i tried avoiding inner loops but the issue i found with that is that sometimes i get a ton of hitrequests targeting the same entity, and i have to basically re-get the target entity’s component data for every hitrequest

edit: oh wait do archetypes already solve this

You would probably be interested in reading some of the examples

1 Like