This commit adds a couple more methods to the QuadTree, allowing for additional filtering of entities using flags to identify those a system is interested in.
Systems can add flags to entities when inserting/upserting them. Later, they can use those flags to query the QuadTree to only return entities they are interested in, removing the need to filter the results afterwards.
Using those flags to filter the QuadTree result I was able to refactor my collision system to use ~12% (majority being QuadTree#getExact) instead of ~80% (QuadTree#getExact taking up 8% of those 80%) of total time reported by VisualVM in a stress test.
Before that, I had to rely on filtering the QuadTree result using Aspect#isInterested and ObjectMap#get + IntBag#contains respectively.
As a side note: This commit also allows for multiple QuadTrees to be used in the application, since idToContainer is no longer a static.
Commit message schosin/artemis-odb-contrib@18eabe3fcb0d1c97e56b3a7636a5179ed7968548:
Support entity flags for inserting and querying QuadTree
Motivation is to use only one QuadTree, but being able to only query for
entities inserted by the call site.
An example would be a collision system where several sources for
possible collisions (e.g. unit-wall, damagingEffect-unit) could only
query the QuadTree for entities flagged by that source's flag, removing
the need for further filtering of the entities returned by the QuadTree.
This commit adds a couple more methods to the QuadTree, allowing for additional filtering of entities using flags to identify those a system is interested in. Systems can add flags to entities when inserting/upserting them. Later, they can use those flags to query the QuadTree to only return entities they are interested in, removing the need to filter the results afterwards.
Using those flags to filter the QuadTree result I was able to refactor my collision system to use ~12% (majority being
QuadTree#getExact
) instead of ~80% (QuadTree#getExact
taking up 8% of those 80%) of total time reported by VisualVM in a stress test. Before that, I had to rely on filtering the QuadTree result usingAspect#isInterested
andObjectMap#get + IntBag#contains
respectively.As a side note: This commit also allows for multiple QuadTrees to be used in the application, since
idToContainer
is no longer a static.Commit message schosin/artemis-odb-contrib@18eabe3fcb0d1c97e56b3a7636a5179ed7968548: Support entity flags for inserting and querying QuadTree
Motivation is to use only one QuadTree, but being able to only query for entities inserted by the call site.
An example would be a collision system where several sources for possible collisions (e.g. unit-wall, damagingEffect-unit) could only query the QuadTree for entities flagged by that source's flag, removing the need for further filtering of the entities returned by the QuadTree.