void EScene::ZoomExtents( ObjClassID cls, BOOL bSel ) { Fbox BB; BB.invalidate(); if (cls==OBJCLASS_DUMMY){ SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) if (_I->second){ Fbox bb; bb.invalidate(); _I->second->GetBBox (bb,bSel); if (bb.is_valid()) BB.merge(bb); } }else{ ESceneToolBase* mt = GetTool(cls); if (mt) mt->GetBBox(BB,bSel); } if (BB.is_valid()) Device.m_Camera.ZoomExtents(BB); else ELog.Msg(mtError,"Can't calculate bounding box. Nothing selected or some object unsupported this function."); }
bool ESceneObjectTools::GetBox (Fbox& bb) { bb.invalidate (); Fbox bbo; for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ (*a_it)->GetBox (bbo); bb.merge (bbo); } return bb.is_valid(); }
bool CGroupObject::GetBox(Fbox& bb) { bb.invalidate (); // update box for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){ switch((*it)->ClassID){ case OBJCLASS_SPAWNPOINT: case OBJCLASS_SCENEOBJECT:{ Fbox box; if ((*it)->GetBox(box)) bb.merge(box); }break; default: bb.modify((*it)->PPosition); } } if (!bb.is_valid()){ bb.set (PPosition,PPosition); bb.grow (EMPTY_GROUP_SIZE); } return bb.is_valid(); }
void CParticleGroup::OnFrame(u32 u_dt) { if (m_Def&&m_RT_Flags.is(flRT_Playing)){ float ct = m_CurrentTime; float f_dt = float(u_dt)/1000.f; for (CPGDef::EffectVec::const_iterator e_it=m_Def->m_Effects.begin(); e_it!=m_Def->m_Effects.end(); e_it++){ if ((*e_it)->m_Flags.is(CPGDef::SEffect::flEnabled)){ VERIFY (items.size()==m_Def->m_Effects.size()); SItem& I = items[e_it-m_Def->m_Effects.begin()]; if (I.IsPlaying()){ if ((ct<=(*e_it)->m_Time1)&&(ct+f_dt>=(*e_it)->m_Time1)) I.Stop((*e_it)->m_Flags.is(CPGDef::SEffect::flDefferedStop)); }else{ if (!m_RT_Flags.is(flRT_DefferedStop)) if ((ct<=(*e_it)->m_Time0)&&(ct+f_dt>=(*e_it)->m_Time0)) I.Play(); } } } m_CurrentTime += f_dt; if ((m_CurrentTime>m_Def->m_fTimeLimit)&&(m_Def->m_fTimeLimit>0.f)) if (!m_RT_Flags.is(flRT_DefferedStop)) Stop(true); bool bPlaying = false; Fbox box; box.invalidate(); for (SItemVecIt i_it=items.begin(); i_it!=items.end(); i_it++) i_it->OnFrame(u_dt,*m_Def->m_Effects[i_it-items.begin()],box,bPlaying); if (m_RT_Flags.is(flRT_DefferedStop)&&!bPlaying){ m_RT_Flags.set (flRT_Playing|flRT_DefferedStop,FALSE); } if (box.is_valid()){ vis.box.set (box); vis.box.getsphere (vis.sphere.P,vis.sphere.R); } } else { vis.box.set (m_InitialPosition,m_InitialPosition); vis.box.grow (EPS_L); vis.box.getsphere (vis.sphere.P,vis.sphere.R); } }