void ActorBank::destroyActor(Actor& actor) { if (m_currentActor == &actor) { m_currentActor = 0; } removeActor(actor); delete &actor; }
void Actors::addActor (const MWWorld::Ptr& ptr) { // erase previous death events since we are currently only tracking them while in an active cell MWWorld::Class::get(ptr).getCreatureStats(ptr).clearHasDied(); removeActor(ptr); MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr); mActors.insert(std::make_pair(ptr, new CharacterController(ptr, anim))); }
/* * Actually commit the operation against our data structures */ void LevelManager::onPostMove(Moveable& obj, Position old) { auto actor = m_actorsID[obj.getID()]; removeActor(old); addActor(actor); auto current = actor->getPosition(); if (current != old) { runTriggers(actor, old); } }
void Phy2dWorld::deleteSelectedActors() { for(int i=0, is=(int)m_editorSelectedActors.size(); i<is; i++) { if(removeActor(m_editorSelectedActors[i])) { delete m_editorSelectedActors[i]; } } m_editorSelectedActors.clear(); }
void Game::removeBlocks(Box2 const &box) { for (ActorIterator i = actors_.begin(); i != actors_.end(); ++i) { Actor *actor = &*i; if (isBlock(actor)) { BlockPhysicsComponent *physicsComponent = convert(actor->getPhysicsComponent()); b2Vec2 position = physicsComponent->getBody()->GetPosition(); if (box.containsPoint(Vector2(position.x, position.y))) { int j = i - actors_.begin(); removeActor(actor); i = actors_.begin() + j - 1; } } } }
void OutofcoreCloud::render (vtkRenderer* renderer) { vtkSmartPointer<vtkCamera> active_camera = renderer->GetActiveCamera (); Scene *scene = Scene::instance (); Camera *camera = scene->getCamera (active_camera); if (render_camera_ != NULL && render_camera_->getName() == camera->getName ()) { renderer->ComputeAspect (); //double *aspect = renderer->GetAspect (); int *size = renderer->GetSize (); OctreeDisk::BreadthFirstIterator breadth_first_it (*octree_); breadth_first_it.setMaxDepth(display_depth_); double frustum[24]; camera->getFrustum(frustum); Eigen::Vector3d eye = camera->getPosition(); Eigen::Matrix4d view_projection_matrix = camera->getViewProjectionMatrix(); //Eigen::Matrix4d view_projection_matrix = projection_matrix * model_view_matrix;//camera->getViewProjectionMatrix(); cloud_actors_->RemoveAllItems (); while ( *breadth_first_it !=0 ) { OctreeDiskNode *node = *breadth_first_it; Eigen::Vector3d min_bb, max_bb; node->getBoundingBox(min_bb, max_bb); // Frustum culling if (pcl::visualization::cullFrustum(frustum, min_bb, max_bb) == pcl::visualization::PCL_OUTSIDE_FRUSTUM) { breadth_first_it.skipChildVoxels(); breadth_first_it++; continue; } // Bounding box lod projection float coverage = pcl::visualization::viewScreenArea(eye, min_bb, max_bb, view_projection_matrix, size[0], size[1]); if (coverage <= lod_pixel_threshold_) { breadth_first_it.skipChildVoxels(); } // for (int i=0; i < node->getDepth(); i++) // std::cout << " "; // std::cout << coverage << "-" << pcd_file << endl;//" : " << (coverage > (size[0] * size[1])) << endl; std::string pcd_file = node->getPCDFilename ().string (); cloud_data_cache_mutex.lock(); PcdQueueItem pcd_queue_item(pcd_file, coverage); // If we can lock the queue add another item if (pcd_queue_mutex.try_lock()) { pcd_queue.push(pcd_queue_item); pcd_queue_mutex.unlock(); } if (cloud_data_cache.hasKey(pcd_file)) { //std::cout << "Has Key for: " << pcd_file << std::endl; if (cloud_actors_map_.find (pcd_file) == cloud_actors_map_.end ()) { vtkSmartPointer<vtkActor> cloud_actor = vtkSmartPointer<vtkActor>::New (); CloudDataCacheItem *cloud_data_cache_item = &cloud_data_cache.get(pcd_file); #if VTK_RENDERING_BACKEND_OPENGL_VERSION < 2 vtkSmartPointer<vtkVertexBufferObjectMapper> mapper = vtkSmartPointer<vtkVertexBufferObjectMapper>::New (); mapper->SetInput (cloud_data_cache_item->item); #else vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New (); // Usually we choose between SetInput and SetInputData based on VTK version. But OpenGL ≥ 2 automatically // means VTK version is ≥ 6.3 mapper->SetInputData (cloud_data_cache_item->item); #endif cloud_actor->SetMapper (mapper); cloud_actor->GetProperty ()->SetColor (0.0, 0.0, 1.0); cloud_actor->GetProperty ()->SetPointSize (1); cloud_actor->GetProperty ()->SetLighting (false); cloud_actors_map_[pcd_file] = cloud_actor; } if (!hasActor (cloud_actors_map_[pcd_file])) { points_loaded_ += cloud_actors_map_[pcd_file]->GetMapper ()->GetInput ()->GetNumberOfPoints (); data_loaded_ += cloud_actors_map_[pcd_file]->GetMapper ()->GetInput ()->GetActualMemorySize(); } //std::cout << "Adding Actor: " << pcd_file << std::endl; cloud_actors_->AddItem (cloud_actors_map_[pcd_file]); addActor (cloud_actors_map_[pcd_file]); } cloud_data_cache_mutex.unlock(); breadth_first_it++; } // We're done culling, notify the pcd_reader thread the queue is read pcd_queue_ready.notify_one(); std::vector<vtkActor*> actors_to_remove; { actors_to_remove.clear (); actors_->InitTraversal (); for (vtkIdType i = 0; i < actors_->GetNumberOfItems (); i++) { vtkActor* actor = actors_->GetNextActor (); if (actor != voxel_actor_.GetPointer ()) { bool actor_found = false; cloud_actors_->InitTraversal (); for (vtkIdType j = 0; j < cloud_actors_->GetNumberOfItems (); j++) { vtkActor* cloud_actor = cloud_actors_->GetNextActor (); if (actor == cloud_actor) { actor_found = true; break; } } if (!actor_found) { actors_to_remove.push_back (actor); } } } } for (size_t i = 0; i < actors_to_remove.size (); i++) { points_loaded_ -= actors_to_remove.back ()->GetMapper ()->GetInput ()->GetNumberOfPoints (); data_loaded_ -= actors_to_remove.back ()->GetMapper ()->GetInput ()->GetActualMemorySize(); removeActor (actors_to_remove.back ()); actors_to_remove.pop_back (); } } Object::render(renderer); }
void Cross::update_semaphore() { if(!accident) { if(frame%change_semaphore==0) { if(activo) { north->changeSemaphore(change_semaphore); south->changeSemaphore(change_semaphore); east->turnOff(); west->turnOff(); }else{ east->changeSemaphore(change_semaphore); west->changeSemaphore(change_semaphore); north->turnOff(); south->turnOff(); } activo=!activo; }else{ if(!crossing) { if(north->empty() && south->empty()) { east->changeSemaphore(change_semaphore); west->changeSemaphore(change_semaphore); north->turnOff(); south->turnOff(); activo=true; }else if(east->empty() && west->empty()){ north->changeSemaphore(change_semaphore); south->changeSemaphore(change_semaphore); east->turnOff(); west->turnOff(); activo=false; } } } }else{ north->turnOff(); south->turnOff(); east->turnOff(); west->turnOff(); if(time_accident<0) { time_accident=0; accident=false; if(n1) { removeActor(cross_n_1); cross_n_1=NULL; n1=false; } if(n2) { removeActor(cross_n_2); cross_n_2=NULL; n2=false; } if(s1) { removeActor(cross_s_1); cross_s_1=NULL; s1=false; } if(s2) { removeActor(cross_s_2); cross_s_2=NULL; s2=false; } if(e1) { removeActor(cross_e_1); cross_e_1=NULL; e1=false; } if(e2) { removeActor(cross_e_2); cross_e_2=NULL; e2=false; } if(w1) { removeActor(cross_w_1); cross_w_1=NULL; w1=false; } if(w2) { removeActor(cross_w_2); cross_w_2=NULL; w2=false; } east->changeSemaphore(change_semaphore); west->changeSemaphore(change_semaphore); north->turnOff(); south->turnOff(); activo=true; } time_accident--; } }
void Cross::cross_cars() { if(!accident) { int segs; if(east->semaphore->isActivo()) { // west - east if(!cross_e_1) { cross_e_1 = east->cola1->pop(); if(cross_e_1){ segs = cross_e_1->setMoving(); cout<<"Segs: "<<segs<<endl; if(!east->ableToCross(segs))cross_e_1->setVXY(segs-1); addActor(cross_e_1); cross_e_1->movingON(); } } if(!cross_e_2) { cross_e_2 = east->cola2->pop(); if(cross_e_2){ segs = cross_e_2->setMoving(); cout<<"Segs: "<<segs<<endl; if(!east->ableToCross(segs))cross_e_2->setVXY(segs-1); addActor(cross_e_2); cross_e_2->movingON(); } } //east - west if(!cross_w_1) { cross_w_1 = west->cola1->pop(); if(cross_w_1){ segs = cross_w_1->setMoving(); cout<<"Segs: "<<segs<<endl; if(!west->ableToCross(segs))cross_w_1->setVXY(segs-1); addActor(cross_w_1); cross_w_1->movingON(); } } if(!cross_w_2) { cross_w_2 = west->cola2->pop(); if(cross_w_2){ segs = cross_w_2->setMoving(); cout<<"Segs: "<<segs<<endl; if(!west->ableToCross(segs))cross_w_2->setVXY(segs-1); addActor(cross_w_2); cross_w_2->movingON(); } } }else{ //Bus puede cruzar en rojo int can_Cross; //east if(!cross_e_1) { cross_e_1 = east->cola1->first(); if(cross_e_1!=NULL && cross_e_1->type == BUS && !cross_e_1->checked) { cross_e_1->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_e_1 = east->cola1->pop(); segs = cross_e_1->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_e_1); cross_e_1->movingON(); checkColisions(east,cross_e_1,&e1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); }else{ cross_e_1 = NULL; } }else{ cross_e_1 = NULL; } }else{ if(cross_e_1->type == BUS) checkColisions(east,cross_e_1,&e1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); } if(!cross_e_2) { cross_e_2 = east->cola2->first(); if(cross_e_2!=NULL && cross_e_2->type == BUS && !cross_e_2->checked) { cross_e_2->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_e_2 = east->cola2->pop(); segs = cross_e_2->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_e_2); cross_e_2->movingON(); checkColisions(east,cross_e_2,&e2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); }else{ cross_e_2 = NULL; } }else{ cross_e_2 = NULL; } }else{ if(cross_e_2->type == BUS) checkColisions(east,cross_e_2,&e2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); } //west if(!cross_w_1) { cross_w_1 = west->cola1->first(); if(cross_w_1!=NULL && cross_w_1->type == BUS && !cross_w_1->checked) { cross_w_1->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_w_1 = west->cola1->pop(); segs = cross_w_1->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_w_1); cross_w_1->movingON(); checkColisions(west,cross_w_1,&w1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); }else{ cross_w_1 = NULL; } }else{ cross_w_1 = NULL; } }else{ if(cross_w_1->type == BUS) checkColisions(west,cross_w_1,&w1,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); } if(!cross_w_2) { cross_w_2 = west->cola2->first(); if(cross_w_2!=NULL && cross_w_2->type == BUS && !cross_w_2->checked) { cross_w_2->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_w_2 = west->cola2->pop(); segs = cross_w_2->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_w_2); cross_w_2->movingON(); checkColisions(west,cross_w_2,&w2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); }else{ cross_w_2 = NULL; } }else{ cross_w_2 = NULL; } }else{ if(cross_w_2->type == BUS) checkColisions(west,cross_w_2,&w2,cross_n_1,&n1,cross_n_2,&n2,cross_s_1,&s1,cross_s_2,&s2); } } if(north->semaphore->isActivo()){ //south - north if(!cross_n_1) { cross_n_1 = north->cola1->pop(); if(cross_n_1){ segs = cross_n_1->setMoving(); cout<<"Segs: "<<segs<<endl; if(!north->ableToCross(segs))cross_n_1->setVXY(segs-1); addActor(cross_n_1); cross_n_1->movingON(); } } if(!cross_n_2) { cross_n_2 = north->cola2->pop(); if(cross_n_2){ segs = cross_n_2->setMoving(); cout<<"Segs: "<<segs<<endl; if(!north->ableToCross(segs))cross_n_2->setVXY(segs-1); addActor(cross_n_2); cross_n_2->movingON(); } } //north - south if(!cross_s_1) { cross_s_1 = south->cola1->pop(); if(cross_s_1){ segs = cross_s_1->setMoving(); cout<<"Segs: "<<segs<<endl; if(!south->ableToCross(segs))cross_s_1->setVXY(segs-1); addActor(cross_s_1); cross_s_1->movingON(); } } if(!cross_s_2) { cross_s_2 = south->cola2->pop(); if(cross_s_2){ segs = cross_s_2->setMoving(); cout<<"Segs: "<<segs<<endl; if(!south->ableToCross(segs))cross_s_2->setVXY(segs-1); addActor(cross_s_2); cross_s_2->movingON(); } } }else{ //Bus puede cruzar en rojo 2 int can_Cross; //north if(!cross_n_1) { cross_n_1 = north->cola1->first(); if(cross_n_1!=NULL && cross_n_1->type == BUS && !cross_n_1->checked) { cross_n_1->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_n_1 = north->cola1->pop(); segs = cross_n_1->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_n_1); cross_n_1->movingON(); checkColisions(north,cross_n_1,&n1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); }else{ cross_n_1 = NULL; } }else{ cross_n_1 = NULL; } }else{ if(cross_n_1->type == BUS) checkColisions(north,cross_n_1,&n1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); } if(!cross_n_2) { cross_n_2 = north->cola2->first(); if(cross_n_2!=NULL && cross_n_2->type == BUS && !cross_n_2->checked) { cross_n_2->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_n_2 = north->cola2->pop(); segs = cross_n_2->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_n_2); cross_n_2->movingON(); checkColisions(north,cross_n_2,&n2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); }else{ cross_n_2 = NULL; } }else{ cross_n_2 = NULL; } }else{ if(cross_n_2->type == BUS) checkColisions(north,cross_n_2,&n2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); } //south if(!cross_s_1) { cross_s_1 = south->cola1->first(); if(cross_s_1!=NULL && cross_s_1->type == BUS && !cross_s_1->checked) { cross_s_1->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_s_1 = south->cola1->pop(); segs = cross_s_1->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_s_1); cross_s_1->movingON(); checkColisions(south,cross_s_1,&s1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); }else{ cross_s_1 = NULL; } }else{ cross_s_1 = NULL; } }else{ if(cross_s_1->type == BUS) checkColisions(south,cross_s_1,&s1,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); } if(!cross_s_2) { cross_s_2 = south->cola2->first(); if(cross_s_2!=NULL && cross_s_2->type == BUS && !cross_s_2->checked) { cross_s_2->checked=true; //srand(time(NULL)); can_Cross = rand()%11; cout<<"puede cruzar: "<<crossInRed[can_Cross]<<endl; if(crossInRed[can_Cross]) { cross_s_2 = south->cola2->pop(); segs = cross_s_2->setMoving(); cout<<"Segs: "<<segs<<endl; addActor(cross_s_2); cross_s_2->movingON(); checkColisions(south,cross_s_2,&s2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); }else{ cross_s_2 = NULL; } }else{ cross_s_2 = NULL; } }else{ if(cross_s_2->type == BUS) checkColisions(south,cross_s_2,&s2,cross_e_1,&e1,cross_e_2,&e2,cross_w_1,&w1,cross_w_2,&w2); } } } //east if(cross_e_1) { cross_e_1->logica(); float x = cross_e_1->position().x(); float xf = east->posPilas[0]->x(); if(xf>x) { removeActor(cross_e_1); // cross_e_1->movingOFF(); east->pila1->push(cross_e_1); cross_e_1=NULL; } } if(cross_e_2) { cross_e_2->logica(); float x = cross_e_2->position().x(); float xf = east->posPilas[1]->x(); if(xf>x) { removeActor(cross_e_2); // cross_e_2->movingOFF(); east->pila2->push(cross_e_2); cross_e_2=NULL; } } //west if(cross_w_1) { cross_w_1->logica(); float x = cross_w_1->position().x(); float xf = west->posPilas[0]->x(); if(xf<x + cross_w_1->imagen->width()) { removeActor(cross_w_1); // cross_w_1->movingOFF(); west->pila1->push(cross_w_1); cross_w_1=NULL; } } if(cross_w_2) { cross_w_2->logica(); float x = cross_w_2->position().x(); float xf = west->posPilas[1]->x(); if(xf<x + cross_w_2->imagen->width()) { removeActor(cross_w_2); // cross_w_2->movingOFF(); west->pila2->push(cross_w_2); cross_w_2=NULL; } } //north if(cross_n_1) { cross_n_1->logica(); float y = cross_n_1->position().y(); float yf = north->posPilas[0]->y(); if(yf>y) { removeActor(cross_n_1); // cross_n_1->movingOFF(); north->pila1->push(cross_n_1); cross_n_1=NULL; } } if(cross_n_2) { cross_n_2->logica(); float y = cross_n_2->position().y(); float yf = north->posPilas[1]->y(); if(yf>y) { removeActor(cross_n_2); // cross_n_2->movingOFF(); north->pila2->push(cross_n_2); cross_n_2=NULL; } } //south if(cross_s_1) { cross_s_1->logica(); float y = cross_s_1->position().y(); float yf = south->posPilas[0]->y(); if(yf<y + cross_s_1->imagen->height()) { removeActor(cross_s_1); // cross_s_1->movingOFF(); south->pila1->push(cross_s_1); cross_s_1=NULL; } } if(cross_s_2) { cross_s_2->logica(); float y = cross_s_2->position().y(); float yf = south->posPilas[1]->y(); if(yf<y + cross_s_2->imagen->height()) { removeActor(cross_s_2); // cross_s_2->movingOFF(); south->pila2->push(cross_s_2); cross_s_2=NULL; } } if(cross_e_1 || cross_e_2 || cross_w_1 || cross_w_2 || cross_n_1 || cross_n_2 || cross_s_1 || cross_s_2) { crossing=true; }else{ crossing=false; } }
void SceneManager::removeSelected() { removeActor(selectedActorId); setSelectedActor(-1); }