- Optimization: added bit vector to let CEntityManager check referenced entities with more spatial locality.
- Bug fix: Entities that died due to the action of a previous entity in a simulation step still tried to update that step. This was SVN commit r4182.
This commit is contained in:
parent
554b9e537e
commit
903b97c1a8
@ -213,6 +213,7 @@ void CEntity::kill()
|
||||
m_extant = false;
|
||||
|
||||
entf_set(ENTF_DESTROYED);
|
||||
g_EntityManager.m_refd[me.m_handle] = false;
|
||||
//Shutdown(); // PT: tentatively removed - this seems to be called by ~CJSComplex, and we don't want to do it twice
|
||||
|
||||
if( m_actor )
|
||||
@ -292,6 +293,8 @@ void CEntity::rebuildClassSet()
|
||||
|
||||
void CEntity::update( size_t timestep )
|
||||
{
|
||||
if( !m_extant ) return;
|
||||
|
||||
m_position_previous = m_position;
|
||||
m_orientation_previous = m_orientation;
|
||||
|
||||
|
@ -71,6 +71,7 @@ void HEntity::addRef()
|
||||
{
|
||||
debug_assert( m_handle < MAX_HANDLES );
|
||||
g_EntityManager.m_entities[m_handle].m_refcount++;
|
||||
g_EntityManager.m_refd[m_handle] = true;
|
||||
/*/*updatecache*/
|
||||
}
|
||||
}
|
||||
@ -80,7 +81,10 @@ void HEntity::decRef()
|
||||
if( m_handle != INVALID_HANDLE )
|
||||
{
|
||||
if( --g_EntityManager.m_entities[m_handle].m_refcount == 0 )
|
||||
{
|
||||
g_EntityManager.m_refd[m_handle] = false;
|
||||
g_EntityManager.destroy( m_handle );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
class HEntity
|
||||
{
|
||||
friend class CEntity;
|
||||
friend class CEntityManager;
|
||||
friend struct CEntityList;
|
||||
u16 m_handle;
|
||||
|
@ -22,6 +22,7 @@ CEntityManager::CEntityManager()
|
||||
m_nextalloc = 0;
|
||||
m_extant = true;
|
||||
m_death = false;
|
||||
m_refd.resize( MAX_HANDLES );
|
||||
|
||||
// Also load a couple of global entity settings
|
||||
CConfigValue* cfg = g_ConfigDB.GetValue( CFG_USER, "selection.outline.quality" );
|
||||
@ -45,12 +46,6 @@ void CEntityManager::deleteAllHelper()
|
||||
}
|
||||
}
|
||||
|
||||
bool CEntityManager::isEntityRefd(int index)
|
||||
{
|
||||
return m_entities[index].m_refcount && !m_entities[index].m_entity->entf_get(ENTF_DESTROYED);
|
||||
}
|
||||
|
||||
|
||||
CEntityManager::~CEntityManager()
|
||||
{
|
||||
m_extant = false;
|
||||
|
@ -38,18 +38,26 @@ class CEntityTemplate;
|
||||
|
||||
class CEntityManager
|
||||
{
|
||||
friend class CEntity;
|
||||
friend class HEntity;
|
||||
friend class CHandle;
|
||||
CHandle m_entities[MAX_HANDLES];
|
||||
std::vector<bool> m_refd;
|
||||
std::vector<CEntity*> m_reaper;
|
||||
std::vector<CEntity*>* m_collisionPatches;
|
||||
int m_nextalloc;
|
||||
static bool m_extant;
|
||||
bool m_death;
|
||||
void destroy( u16 handle );
|
||||
int m_collisionPatchesPerSide;
|
||||
std::vector<CEntity*>* m_collisionPatches;
|
||||
bool isEntityRefd(int index);
|
||||
|
||||
void destroy( u16 handle );
|
||||
void deleteAllHelper();
|
||||
|
||||
inline bool isEntityRefd( u16 index )
|
||||
{
|
||||
return m_refd[index];
|
||||
//return m_entities[index].m_refcount && !m_entities[index].m_entity->entf_get(ENTF_DESTROYED);
|
||||
}
|
||||
public:
|
||||
|
||||
CEntityManager();
|
||||
|
Loading…
Reference in New Issue
Block a user