Skip to content

Commit

Permalink
Changed: Number of defragmeneted entites per tick can be changed in r…
Browse files Browse the repository at this point in the history
…untime

Added: defrag_entities_per_tick
  • Loading branch information
richardbiely committed Nov 10, 2023
1 parent 24fdc73 commit d25d8b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 0 additions & 5 deletions include/gaia/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
#define GAIA_USE_PREFETCH 1
#endif

//! Maximum number of entities to defragment per frame
#ifndef GAIA_DEFRAG_ENTITIES_PER_FRAME
#define GAIA_DEFRAG_ENTITIES_PER_FRAME 100
#endif

//! If enabled, a very small hash table is stored in chunks internally which
//! is used to do ComponentId -> component index lookups.
//! \warning Experimental, don't use.
Expand Down
10 changes: 9 additions & 1 deletion include/gaia/ecs/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace gaia {
cnt::darray<Archetype*> m_archetypesToRemove;
//! ID of the last defragmented archetype
uint32_t m_defragLastArchetypeID = 0;
//! Maximum number of entities to defragment per world tick
uint32_t m_defragEntitesPerTick = 100;

//! With every structural change world version changes
uint32_t m_worldVersion = 0;
Expand Down Expand Up @@ -754,7 +756,7 @@ namespace gaia {
GAIA_PROF_SCOPE(gc);

remove_empty_chunks();
defrag_chunks(GAIA_DEFRAG_ENTITIES_PER_FRAME);
defrag_chunks(m_defragEntitesPerTick);
remove_empty_archetypes();
}

Expand Down Expand Up @@ -1093,6 +1095,12 @@ namespace gaia {
GAIA_PROF_FRAME();
}

//! Sets the maximum number of entites defragmented per world tick
//! \param value Number of entities to defragment
void defrag_entities_per_tick(uint32_t value) {
m_defragEntitesPerTick = value;
}

//--------------------------------------------------------------------------------

//! Performs diagnostics on archetypes. Prints basic info about them and the chunks they contain.
Expand Down
15 changes: 9 additions & 6 deletions single_include/gaia.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,6 @@ namespace gaia {
#define GAIA_USE_PREFETCH 1
#endif

//! Maximum number of entities to defragment per frame
#ifndef GAIA_DEFRAG_ENTITIES_PER_FRAME
#define GAIA_DEFRAG_ENTITIES_PER_FRAME 100
#endif

//! If enabled, a very small hash table is stored in chunks internally which
//! is used to do ComponentId -> component index lookups.
//! \warning Experimental, don't use.
Expand Down Expand Up @@ -19090,6 +19085,8 @@ namespace gaia {
cnt::darray<Archetype*> m_archetypesToRemove;
//! ID of the last defragmented archetype
uint32_t m_defragLastArchetypeID = 0;
//! Maximum number of entities to defragment per world tick
uint32_t m_defragEntitesPerTick = 100;

//! With every structural change world version changes
uint32_t m_worldVersion = 0;
Expand Down Expand Up @@ -19781,7 +19778,7 @@ namespace gaia {
GAIA_PROF_SCOPE(gc);

remove_empty_chunks();
defrag_chunks(GAIA_DEFRAG_ENTITIES_PER_FRAME);
defrag_chunks(m_defragEntitesPerTick);
remove_empty_archetypes();
}

Expand Down Expand Up @@ -20120,6 +20117,12 @@ namespace gaia {
GAIA_PROF_FRAME();
}

//! Sets the maximum number of entites defragmented per world tick
//! \param value Number of entities to defragment
void defrag_entities_per_tick(uint32_t value) {
m_defragEntitesPerTick = value;
}

//--------------------------------------------------------------------------------

//! Performs diagnostics on archetypes. Prints basic info about them and the chunks they contain.
Expand Down

0 comments on commit d25d8b6

Please sign in to comment.