Entity limit

From The DarkMod Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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 counted against the limit, even tho they are not really "visible" to the mapper. This basically means do not build a map that is too close to the limit, leave at least 100 entities so the game can work:

  • the worldspawn (all map geometry) counts as one entity ("entity 0")
  • 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

There are also entities that you will likely use, and you need to reserve space for them in the typical map:

  • the main ambient light
  • if you are using the zone system: one global entity plus one seperator for most portals
  • starting items and items in the players inventory


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 (graphic card) 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

  • SEED - how to overcome the entity limit