bool ParticleSystem::UpdateSystem( float frametime ) { // the entity emitting this system cl_entity_t *source = UTIL_GetClientEntityWithServerIndex( m_iEntIndex ); if(!source) { // gEngfuncs.Con_Printf("ent not found\n" ); return false; } // Don't update if the system is outside the player's PVS. if (source->curstate.msg_time < gEngfuncs.GetClientTime()) { //remove particles enable = 0; } else enable = (source->curstate.renderfx == kRenderFxAurora); //check for contents to remove if(m_iKillCondition == gEngfuncs.PM_PointContents(source->curstate.origin, NULL)) { enable = 0; } if (m_pMainParticle == NULL) { if (enable) { ParticleType *pType = m_pMainType; if (pType) { m_pMainParticle = pType->CreateParticle(this);//m_pMainParticle); if (m_pMainParticle) { m_pMainParticle->m_iEntIndex = m_iEntIndex; m_pMainParticle->age_death = -1; // never die } } } } else if (!enable) { m_pMainParticle->age_death = 0; // die now m_pMainParticle = NULL; } particle* pParticle = m_pActiveParticle; particle* pLast = NULL; while( pParticle ) { if( UpdateParticle( pParticle, frametime ) ) { pLast = pParticle; pParticle = pParticle->nextpart; } else // deactivate it { if (pLast) { pLast->nextpart = pParticle->nextpart; pParticle->nextpart = m_pFreeParticle; m_pFreeParticle = pParticle; pParticle = pLast->nextpart; } else // deactivate the first particle in the list { m_pActiveParticle = pParticle->nextpart; pParticle->nextpart = m_pFreeParticle; m_pFreeParticle = pParticle; pParticle = m_pActiveParticle; } } } return true; }
bool ParticleSystem::UpdateSystem( float frametime ) { // the entity emitting this system edict_t *source = GetEntityByIndex( m_iEntIndex ); if( !source ) return false; // Don't update if the system is outside the player's PVS. enable = (source->v.renderfx == kRenderFxAurora); // check for contents to remove if( POINT_CONTENTS( source->v.origin ) == m_iKillCondition ) { enable = 0; } if( m_pMainParticle == NULL ) { if ( enable ) { ParticleType *pType = m_pMainType; if ( pType ) { m_pMainParticle = pType->CreateParticle( this ); if ( m_pMainParticle ) { m_pMainParticle->m_iEntIndex = m_iEntIndex; m_pMainParticle->age_death = -1; // never die } } } } else if ( !enable ) { m_pMainParticle->age_death = 0; // die now m_pMainParticle = NULL; } particle* pParticle = m_pActiveParticle; particle* pLast = NULL; while( pParticle ) { if ( UpdateParticle( pParticle, frametime )) { pLast = pParticle; pParticle = pParticle->nextpart; } else // deactivate it { if ( pLast ) { pLast->nextpart = pParticle->nextpart; pParticle->nextpart = m_pFreeParticle; m_pFreeParticle = pParticle; pParticle = pLast->nextpart; } else // deactivate the first particle in the list { m_pActiveParticle = pParticle->nextpart; pParticle->nextpart = m_pFreeParticle; m_pFreeParticle = pParticle; pParticle = m_pActiveParticle; } } } return true; }