void BubbleManager::UpdateBubble(SystemEntity *ent, bool notify) { SystemBubble *b = ent->Bubble(); if(b != NULL) { if(b->InBubble(ent->GetPosition())) { _log(DESTINY__BUBBLE_TRACE, "Entity %u is still located in bubble %p", ent->GetID(), b); //still in bubble... return; } _log(DESTINY__BUBBLE_TRACE, "Entity %u is no longer located in bubble %p", ent->GetID(), b); b->Remove(ent, notify); } Add(ent, notify); }
//NOTE: this should probably eventually be optimized to use a //spacial partitioning scheme to speed up this search. SystemBubble * BubbleManager::_FindBubble(const GPoint &pos) const { std::vector<SystemBubble *>::const_iterator cur, end; cur = m_bubbles.begin(); end = m_bubbles.end(); for(; cur != end; ++cur) { SystemBubble *b = *cur; if(b->InBubble(pos)) { return(b); } } //not in any existing bubble. return NULL; }
//NOTE: this should probably eventually be optimized to use a //spacial partitioning scheme to speed up this search. SystemBubble * BubbleManager::FindBubble(SystemEntity *ent) const { GPoint pos = ent->GetPosition(); std::vector<SystemBubble *>::const_iterator cur, end; cur = m_bubbles.begin(); end = m_bubbles.end(); for(; cur != end; ++cur) { SystemBubble *b = *cur; if(b->InBubble(pos)) { return(b); } } //not in any existing bubble. return NULL; }
void BubbleManager::UpdateBubble(SystemEntity *ent, bool notify, bool isWarping, bool isPostWarp) { SystemBubble *b = ent->Bubble(); if(b != NULL) { if(b->InBubble(ent->GetPosition())) { _log(DESTINY__BUBBLE_DEBUG, "Entity %u at (%.2f,%.2f,%.2f) is still located in bubble %u at (%.2f,%.2f,%.2f) with radius %.2f", ent->GetID(), ent->GetPosition().x, ent->GetPosition().y, ent->GetPosition().z, b->GetBubbleID(), b->m_center.x, b->m_center.y, b->m_center.z, b->m_radius); //_log(DESTINY__BUBBLE_TRACE, "Entity %u is still located in bubble %u", ent->GetID(), b->GetBubbleID()); //still in bubble... sLog.Debug( "BubbleManager::UpdateBubble()", "SystemEntity '%s' is still located in Bubble %u", ent->GetName(), b->GetBubbleID() ); return; } _log(DESTINY__BUBBLE_DEBUG, "Entity %u at (%.2f,%.2f,%.2f) is no longer located in bubble %u at (%.2f,%.2f,%.2f) with radius %.2f", ent->GetID(), ent->GetPosition().x, ent->GetPosition().y, ent->GetPosition().z, b->GetBubbleID(), b->m_center.x, b->m_center.y, b->m_center.z, b->m_radius); //_log(DESTINY__BUBBLE_TRACE, "Entity %u is no longer located in bubble %u", ent->GetID(), b->GetBubbleID()); b->Remove(ent, notify); sLog.Debug( "BubbleManager::UpdateBubble()", "SystemEntity '%s' being removed from Bubble %u", ent->GetName(), b->GetBubbleID() ); } else sLog.Debug( "BubbleManager::UpdateBubble()", "SystemEntity '%s' not currently in ANY Bubble!!!", ent->GetName() ); if( !isWarping ) Add(ent, notify, isPostWarp); }