//-----------------------------------------------------------------------------
void ActorTreeAbstract::prepareActors(ActorCollection& actors)
{
  // finds the root transforms

  std::set< ITransform* > root_transforms;
  for(int i=0; i<(int)actors.size(); ++i)
  {
    for( ITransform* root = actors[i]->transform(); root; root = root->parent() )
      if ( !root->parent() )
        root_transforms.insert(root);
  }

  // setup the matrices

  std::set< ITransform* >::iterator tra = root_transforms.begin();
  while( tra != root_transforms.end() )
  {
    (*tra)->computeWorldMatrixRecursive();
    ++tra;
  }

  // setup the Actor[s] bounding box and bounding sphere

  for(int i=0; i<(int)actors.size(); ++i)
    actors[i]->computeBounds();
}
Exemplo n.º 2
0
//clear all actors
void VLBaseView::flush( bool bUpdate )
{
	ActorCollection actors;
	sceneManager()->tree()->extractActors(actors);

	for (int i=0;i<actors.size();i++)
	{
		sceneManager()->tree()->eraseActor(actors[i].get());	
		mTextDebug = NULL;
	}

	if (bUpdate)
	{
		openglContext()->update();
	}
}
//-----------------------------------------------------------------------------
void SceneManagerPortals::extractVisibleActors(ActorCollection& list, const Camera* camera)
{
  if (cullingEnabled())
  {
    Sector* start = computeStartingSector(camera);
    if (!start)
      extractActors(list);
    else
    {
      ++mVisitTick;
      mTempActors.clear();
      mFrustumStack.clear();

      mFrustumStack.push_back(camera->frustum());
      start->executeCallbacks(camera,this,NULL);
      visitSector(NULL, start, camera->modelingMatrix().getT(), camera);

      // remove duplicates
      std::sort(mTempActors.begin(), mTempActors.end());
      std::vector< ref<Actor> >::iterator new_end = std::unique(mTempActors.begin(), mTempActors.end());
      for(std::vector< ref<Actor> >::iterator it = mTempActors.begin(); it != new_end; ++it)
        list.push_back(it->get());
    }
  }
  else
    extractActors(list);
}
//-----------------------------------------------------------------------------
void SceneManagerPortals::extractVisibleActors(ActorCollection& list, const Camera* camera)
{
  if (cullingEnabled())
  {
    Sector* start = computeStartingSector(camera);
    if (!start)
      extractActors(list);
    else
    {
      ++mVisitTick;
      mTempActors.clear();
      mFrustumStack.clear();

      mFrustumStack.push_back(camera->frustum());
      start->executeCallbacks(camera,this,NULL);
      visitSector(NULL, start, camera->modelingMatrix().getT(), camera);

      // insert portal actors
      if (showPortals())
      {
        for(std::map<Portal*, ref<Actor> >::const_iterator it = mPortalActorMap.begin(); it != mPortalActorMap.end(); ++it)
          mTempActors.push_back(it->second);
      }

      // mic fixme: isn't quicker to use sets instead of sort()+unique()?
      // avoid reporting duplicates
      std::sort(mTempActors.begin(), mTempActors.end());
      std::vector< ref<Actor> >::iterator new_end = std::unique(mTempActors.begin(), mTempActors.end());
      for(std::vector< ref<Actor> >::iterator it = mTempActors.begin(); it != new_end; ++it)
        list.push_back(it->get());
    }
  }
  else
    extractActors(list);
}
//-----------------------------------------------------------------------------
void ActorTreeAbstract::extractActors(ActorCollection& list)
{
  for(int i=0; i<actors()->size(); ++i)
    list.push_back(actors()->at(i));
  for(int i=0; i<childrenCount(); ++i)
    if (child(i))
      child(i)->extractActors(list);
}
 virtual void extractActors(ActorCollection& queue)
 {
   int actor_rank = mActorRenderRankStart;
   for(int i=0; i<vectorGraphicObjects()->size(); ++i)
   {
     for(int j=0; j<vectorGraphicObjects()->at(i)->actors()->size(); ++j)
     {
       vectorGraphicObjects()->at(i)->actors()->at(j)->setRenderRank( actor_rank++ );
       queue.push_back( vectorGraphicObjects()->at(i)->actors()->at(j) );
     }
   }
 }
//-----------------------------------------------------------------------------
void ActorTreeAbstract::extractVisibleActors(ActorCollection& list, const Camera* camera, unsigned enable_mask)
{
  // try to cull the whole node
  if ( !camera->frustum().cull(aabb()) )
  {
    // cull Actor by Actor
    for(int i=0; i<actors()->size(); ++i)
    {
      if (enable_mask & actors()->at(i)->enableMask())
      {
        VL_CHECK(actors()->at(i)->lod(0))
        actors()->at(i)->computeBounds();
        if ( !camera->frustum().cull( actors()->at(i)->boundingSphere() ) )
          list.push_back(actors()->at(i));
      }
    }
    for(int i=0; i<childrenCount(); ++i)
      if (child(i))
        child(i)->extractVisibleActors(list, camera);
  }
}
//-----------------------------------------------------------------------------
void SceneManagerPortals::extractActors(ActorCollection& list)
{
  for(unsigned i=0; i<mSectors.size(); ++i)
    for(int j=0; j<mSectors[i]->actors()->size(); ++j)
      list.push_back( mSectors[i]->actors()->at(j) );
}