Entity limit

From The DarkMod Wiki
Revision as of 06:45, 1 December 2010 by Tels (talk | contribs) (first stab)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Entities?

An entity is the basic object in the idTech4 engine. This can be something visible (a chair, a light), or invisible (a trigger), or global objects that are there just to make your map work (the worldspawn, ambient light etc).

Each entity added to a map uses up a certain amount of memory, and needs quite a bit of time to "spawn". So having many entities makes your map load slower and use more resources.


Entity Limit in Doom3/TDM

The idTech4 engine limits the number of entities in a map to a certain fixed amount. These are:

  • Doom 3: 4096
  • The Dark Mod: 8192

While it is possible to raise the entity limit further, this is not really a good idea, and not planned at the moment.


"Invisible entities"

There are some entities that are counted into the limit, even tho they are not really "visible" to the mapper, but you still need to count them against the limit. This basically means do not build a map that is too close to the limit, leave quite a bit space (like 100 entities) so the game can work:

  • the worldspawn (all map geometry) counts as 1 entity
  • the player itself
  • arrows spawned when the player shoots an arrow
  • broken arrows or other flinders spawned when objects get destroyed
  • arrow results (an invisible entity that makes guards investigate arrows sticking into walls)
  • items dropped from the player inventory (keys, readables) to the world


Resources used

Entities that spawn use up the following resources:

  • CPU time uring spawn (and during destroy). So avoid constantly spawning/destroying entities, that can be very costly (f.i. an arrow trap that shoots an high amount of arrows that than later disappear)
  • CPU time during runtime, because some operations need to filter through all entities just to find their entities. F.i. an AI that wants to check if there is another AI needs to run through all existing entities to find them. The more entities your map has (say 7000 vs. 700) the longer that takes. Note: This time is very small, but it can add up if you have a really high entity number. This is the main reason why you should save entities and not just ask us to raise the entity limit.
  • CPU time thinking (unless the entity is dormant)
  • GPU time during drawing if the entity is visible

The entity limit itself does not use any mentionable resources, e.g. if we would raise the entity limit from 8192 to 16384 would not use up any more resources. Only entities actually spawned use resources.


Reducing the entity count

You can reduce the entity count in your map by:

  • combine multiple func_statics into one, if possible. This brings the most benefits, as it also improves rendering performance.
  • remove entities at the border of the map and replace them with decals (f.i. distant trees). This also improves rendering performance since a decal is only 2 triangles, while a tree might be 100..1000s of triangles.
  • instead of having multiple atdm:ammo_XXXarrow entities that are given to the player at map start, create only one and set the spawnarg "inv_ammo_amount" to the desired amount. These entities are removed at map start anyway, but this way they don't count against the overall limit while loading the map. Not having to spawn 10 arrow entities is also faster while loading your map.


See also