Commit d8445613 authored by pitiot's avatar pitiot

ecnore un bug coarse cas triangle agents

parent 247a530f
......@@ -247,6 +247,16 @@ inline void EnvMap::pushAgentInCells(Agent* agent, Dart d)
// assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) == agentvect[d].end());
// map.check();
TraversorF<PFP::MAP> tF(map);
for(Dart ddd = tF.begin() ; ddd != tF.end() ; ddd = tF.next())
{
if(std::find(agentvect[ddd].begin(), agentvect[ddd].end(), agent) != agentvect[ddd].end())
std::cout <<agent << " SO WRONG ADD" <<ddd.index<< std::endl;
if(std::find(neighborAgentvect[ddd].begin(), neighborAgentvect[ddd].end(), agent) != neighborAgentvect[ddd].end())
std::cout <<agent<< " SO SO WRONG ADD" <<ddd.index<< std::endl;
}
addElementToVector<Agent*>(agentvect[d],agent);
// agentvect[d].push_back(agent) ;
// nbAgentsIncrease(d);
......
......@@ -112,7 +112,7 @@ public:
bool importAgents(std::string filename) ;
bool exportAgents(std::string filename) ;
void checkRegistering();
void swapAgentsGoals() ;
Geom::BoundingBox<VEC3> getAgentsBB() ;
......
......@@ -172,7 +172,7 @@ public:
bool render_anim ;
int visu ;
Utils::Drawer* m_ds;
bool drawEnvLines ;
bool drawEnvFaces ;
bool drawEnvTopo ;
......
......@@ -88,6 +88,7 @@ void Agent::init(const VEC3& start, const VEC3& goal)
movingObstacles_ = new MovingObstacle* [maxMovingObstacles_];
nb_mos=0;
agentNo = cptAgent++ ;
CGoGNout<<this<<" = agent n°"<<agentNo<<CGoGNendl;
}
......
......@@ -794,14 +794,14 @@ void EnvMap::refine()
newF.mark(dd) ;
dd = map.phi1(dd) ;
} while (dd != old) ;
map.setCurrentLevel(fLevel+1) ;
if (degree == 3)
{
Dart centerFace = map.phi2(map.phi1(old)) ;
newF.mark(centerFace) ;
}
map.setCurrentLevel(map.getMaxLevel()) ;
map.setCurrentLevel(map.getMaxLevel()) ;
//retrieve neighbors agents from onering cells
dd = old ;
do
......@@ -830,7 +830,9 @@ void EnvMap::refine()
if (degree == 3)
{
map.setCurrentLevel(fLevel+1) ;
Dart centerFace = map.phi2(map.phi1(old)) ;
map.setCurrentLevel(map.getMaxLevel()) ;
Dart d3 = centerFace ;
do
{
......@@ -848,7 +850,7 @@ void EnvMap::refine()
d3 = map.phi1(d3) ;
} while (d3 != centerFace) ;
}
cout<<"coucou"<<endl;
//agents contained in the subdivided cell are pushed correctly
for (PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait)
{
......@@ -1155,7 +1157,7 @@ void EnvMap::updateMap()
assert(map.getCurrentLevel() == map.getMaxLevel()) ;
refine();
// coarse();
coarse();
}
void EnvMap::resetAgentInFace(Agent* agent)
......
......@@ -104,7 +104,7 @@ void Simulator::doStep()
envMap_.clearUpdateCandidates() ;
envMap_.map.setCurrentLevel(envMap_.map.getMaxLevel()) ;
#endif
checkRegistering();
for (unsigned int i = 0 ; i < movingObstacles_.size() ; ++i)
{
movingObstacles_[i]->computePrefVelocity() ;
......@@ -1088,3 +1088,27 @@ Geom::BoundingBox<VEC3> Simulator::getAgentsBB()
}
return bb ;
}
void Simulator::checkRegistering()
{
for(std::vector<Agent *>::iterator it = agents_.begin() ; it != agents_.end() ; ++it)
{
TraversorF<PFP::MAP> tF(envMap_.map);
for(Dart d = tF.begin() ; d != tF.end() ; d = tF.next())
{
PFP::AGENTS a = envMap_.agentvect[d];
PFP::AGENTS::iterator f1 = std::find(a.begin(), a.end(), *it);
if(f1!=a.end())
if(std::find(++f1, a.end(), *it)!=a.end())
std::cout << "pas cool."<<(*it)->agentNo << std::endl;
a = envMap_.neighborAgentvect[d];
PFP::AGENTS::iterator f2 = std::find(a.begin(), a.end(), *it);
if(f2!=a.end())
if(std::find(++f2, a.end(), *it)!=a.end())
std::cout << "pas cool, mais un peu moins." <<(*it)->agentNo << std::endl;
}
}
}
......@@ -126,7 +126,7 @@ void SocialAgents::cb_initGL()
// create the render
m_render = new Algo::Render::GL2::MapRender();
m_renderTopo = new Algo::Render::GL2::TopoRender();
m_ds = new Utils::Drawer();
if(simulator.config==5)
m_renderPedway = new Algo::Render::GL2::MapRender();
......@@ -494,7 +494,16 @@ void SocialAgents::cb_redraw()
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
glEnable(GL_LIGHTING);
glm::mat4& matrice = modelViewMatrix();
Geom::Matrix44f matrix;
for (unsigned int i = 0; i<4; i++)
{
for(unsigned int j = 0; j<4; j++)
{
matrix(i,j)=matrice[i][j];
}
}
// cout<<matrice[0][0]<<endl;
dock.check_slide->setRange(0, simulator.envMap_.map.end().index) ;
......@@ -528,6 +537,34 @@ void SocialAgents::cb_redraw()
// renderAgent(simulator.envMap_, *it, drawAgentsNeighborDist, drawAgentsObstacleDist, drawAgentsPath,
// (*it)->color1, (*it)->color2, (*it)->color3) ;
// }
if(target_Agent)
{
glDisable(GL_LIGHTING);
VEC3 pos =simulator.agents_[agentSlider]->part_.getPosition();
CGoGNout<<"agent "<<agentSlider<< " sélectionné, à la position :"<<pos<<CGoGNendl;
m_ds->newList(GL_COMPILE);
m_ds->lineWidth(5.0f);
m_ds->pointSize(10.0f);
m_ds->begin(GL_POINTS);
// fait varier la couleur du plus pres au plus loin
m_ds->color3f(0.0f , 1.0f, 0.9f);
m_ds->vertex(pos);
m_ds->vertex(pos+VEC3(0,0,50));
m_ds->vertex(pos+VEC3(0,10,50));
// m_ds->vertex(VEC3 (pos[0]+10,pos[1]-10,pos[2]));
m_ds->end();
m_ds->endList();
m_ds->callList();
}
}
if (drawMovingObstacles)
......@@ -822,7 +859,7 @@ void SocialAgents::animate()
// if (CityGenerator::animateCity<PFP>(&simulator.envMap_)) simulator.addPathToCorner() ;
// simulator.addPathsToAgents() ;
//
// std::cout << "t : " << simulator.globalTime_ << std::endl ;
std::cout << "t : " << simulator.globalTime_ << std::endl ;
//
// timeval startTime ;
// gettimeofday(&startTime, NULL) ;
......
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