Internal implementation of surface.find_entities_filtered
Posted: Wed Aug 30, 2017 6:03 pm
Basically, I had assumed that no matter the type or name arguments, the game engine iterated through all entities in the area, and when you supply an entity name or type, each one is compared to that requirement and only added to the list if it matches (similar to how Minecraft does it, code sample below). The salient point being that the number of iterations is always equal to the number of candidate entities. In some cases - such as the case that has caused me to ask this question (~20 biters surrounded by >75k particles) - you may have 90000 entities in an area but only three you care about, yet still need to iterate through all 90000 to find those three.
Is this above assumption correct? And if so, do I have an alternative for finding some select entity types in a very dense field of irrelevant ones (example below)?
Sample (and pseudo-ified) code of the sort of implementation I assumed:
Sample entity list in an area. How to efficiently find only the "interactable" (not ghost, particle, etc) ones?
Is this above assumption correct? And if so, do I have an alternative for finding some select entity types in a very dense field of irrelevant ones (example below)?
Sample (and pseudo-ified) code of the sort of implementation I assumed:
Code: Select all
public void getEntitiesOfTypeWithinAAAB(AxisAlignedBB area, List list, IEntitySelector condition) {
for (Entity e : this.entityList) { //<-- note the iteration across all entities, not just ones matching the condition
if (e.boundingBox.intersectsWith(area) && (condition == null || condition.isEntityApplicable(e))) { // <-- here a null condition is basically no name or type specified
list.add(e);
}
}
}
Code: Select all
blood-particle 71597 neutral
item-on-ground 151 neutral
behemoth-biter-corpse 17 neutral
blood-fountain 8 neutral
medium-biter-corpse 26 neutral
big-biter-corpse 85 neutral
big-worm-corpse 5 neutral
small-biter-corpse 25 neutral
small-spitter-corpse 2 neutral
smoke-explosion-particle 4630 neutral
explosion-remnants-particle 160 neutral
orbital-bombardment-crater 8 neutral
biter-spawner-corpse 9 neutral
huge-worm-corpse 4 neutral
spitter-spawner-corpse 2 neutral
big-spitter-corpse 14 neutral
orbital-bombardment-shockwave 3 neutral
orbital-bombardment-explosion 8 neutral
orbital-bombardment-firing-sound 2 neutral
orbital-manual-target-secondary 2 player
dead-grey-trunk 4 neutral
orbital-manual-target-effect 1 neutral
medium-spitter-corpse 3 neutral