Commit 4dbff019 authored by pitiot's avatar pitiot
Browse files

remise en marche fonctionnalité de mort des agents

parent 2858de63
......@@ -5,7 +5,7 @@
#include "utils.h"
#include "env_map.h"
#include <set>
#include "Algo/MovingObjects/particle_cell_2D_memo.h"
using namespace std;
PFP::VEC3 rotate (PFP::VEC3 pos1, PFP::VEC3 center, float angle);
......@@ -42,10 +42,11 @@ public:
int index;
int max_x_ind;
int min_x_ind;
Obstacle* * obstacles_;
std::vector<Dart> * belonging_cells;
std::vector<Dart> * neighbor_cells;
std::vector<Dart> general_belonging;
std::set<Dart> general_belonging;
VEC3 front;
CellMarkerMemo<FACE> * memo_mark;
//difference entre 2 listes utilisé pour update
......
......@@ -138,6 +138,7 @@ public:
int avoidance;
int nb_dead;
bool multires;
bool detect_agent_collision;
ThreadUpdateInfo* tc1 ;
ThreadUpdateInfo* tc2 ;
ThreadUpdateInfo* tc3 ;
......
......@@ -239,7 +239,9 @@ void MovingObstacle::computePrefVelocity()
void MovingObstacle::update()
{
assert(sim_->envMap_.map.getCurrentLevel() == sim_->envMap_.map.getMaxLevel()) ;
// general_belonging.clear();
if(sim_->detect_agent_collision)
general_belonging.clear();
PFP::VEC3 bary = 0;
Dart d;
......@@ -290,33 +292,38 @@ void MovingObstacle::update()
// o->nextP = parts_[(i + 2) % nbVertices]->getPosition();
register_update(o,i);
//
// for (std::vector<Dart>::iterator it = belonging_cells[i].begin(); it != belonging_cells[i].end(); ++it)
// {
// general_belonging.push_back(*it);
// }
if(sim_->detect_agent_collision)
{
for (std::vector<Dart>::iterator it = belonging_cells[i].begin(); it != belonging_cells[i].end(); ++it)
{
general_belonging.insert(*it);
}
}
// CGoGNout << "Apres une etape : Obstacle "<< i << CGoGNendl;
}
//
// envMap_->addMovingObstAsNeighbor(this,general_belonging,&(general_neighbors));
// CGoGNout << "nouvel update : "<< CGoGNendl;
if(sim_->detect_agent_collision)
{
for (std::set<Dart>::iterator it2 = general_belonging.begin(); it2 != general_belonging.end(); ++ it2)
{
std::vector<Agent*> vector =sim_->envMap_.agentvect[(*it2)];
for(std::vector<Agent*>::iterator it=vector.begin();it!=vector.end(); ++it)
{
if (this->is_inside((*it)->part_.getPosition()))
{
(*it)->alive=false;
(*it)->color1=0.0f;
(*it)->color2=0.4f;
(*it)->color3=0.0f;
sim_->envMap_.popAgentInCells(*it,(*it)->part_.d);
}
}
// for (std::vector<Dart>::iterator it2 = general_belonging.begin(); it2 != general_belonging.end(); ++ it2)
// {
// std::vector<Agent*> vector =envMap_->agentvect[(*it2)];
// for(std::vector<Agent*>::iterator it=vector.begin();it!=vector.end(); ++it)
// {
// if (this->is_inside((*it)->part_.m_position))
// {
// (*it)->alive=false;
// (*it)->color1=0.0f;
// (*it)->color2=0.4f;
// (*it)->color3=0.0f;
// envMap_->popAgentInCells(*it,(*it)->part_.d);
// }
// }
//
// }
}
}
}
......
......@@ -13,7 +13,8 @@ Simulator::Simulator(int minSize) :
avoidance(1),
nb_dead(0)
{
multires=true;
multires=false;
detect_agent_collision=true;
srand(10) ;
nbStepsPerUnit_ = 1 / timeStep_ ;
init(1, minSize, 2.0f) ;
......@@ -28,8 +29,8 @@ Simulator::~Simulator()
void Simulator::init(unsigned int config, int minSize, float dimension, bool enablePathFinding)
{
std::cout << "Setup scenario" << std::endl ;
envMap_.init(config, 1600.0f, 960.0f, minSize, 320.0f) ;
// envMap_.init(config, 1600.0f, 960.0f, minSize, 320.0f) ; //grosses cases
envMap_.init(config, 1600.0f, 960.0f, minSize, 20.0f) ; //cases fines
switch (config)
{
case 0 :
......
......@@ -641,6 +641,10 @@ void SocialAgents::cb_redraw()
<< " [" << (sim.nbUpdates == 0 ? 0 : 100 * sim.nbSorts / sim.nbUpdates) << "%]" ;
oss << " | To Refine " << sim.nbRefineCandidate ;
oss << " | To Coarsen " << sim.nbCoarsenCandidate ;
if(sim.detect_agent_collision)
{
oss << " | agents morts : "<<sim.nb_dead;
}
glColor3f(1.0f, 1.0f, 1.0f) ;
statusMsg(oss.str().c_str()) ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment