Commit 6f108282 authored by Thomas Jund's avatar Thomas Jund

ajout affich onering

parent 00301910
......@@ -308,9 +308,7 @@ inline void EnvMap::pushAgentInCells(Agent* agent, Dart d)
while (ddd != dd)
{
if (!map.isBoundaryMarked2(ddd))
{
addElementToVector<Agent*>(neighborAgentvect[ddd],agent);
}
// neighborAgentvect[ddd].push_back(agent) ;
// nbAgentsIncrease(ddd);
......@@ -335,9 +333,8 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
while (ddd != dd)
{
if (!map.isBoundaryMarked2(ddd))
{
removeElementFromVector<Agent*>(neighborAgentvect[ddd], agent) ;
}
// nbAgentsDecrease(ddd) ;
ddd = map.alpha1(ddd) ;
}
......@@ -366,7 +363,7 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, const std::vector<Dart>& b
neighbor_cells->clear();
CellMarkerMemo<FACE> memo_mark(map);
CellMarkerMemo<FACE> OneRingMark(map);
memo_mark.unmarkAll();
for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
memo_mark.mark(*it);
......
......@@ -54,6 +54,8 @@
#include "shaderCustom.h"
//#define EXPORTING
//#define ONERING
//#define SHADOWSHELL
using namespace CGoGN ;
......@@ -104,6 +106,8 @@ public:
Utils::VBO* m_colorVBO;
Utils::ShaderSimpleColor* m_simpleColorShader;
Algo::Render::GL2::MapRender* m_renderWithin;
//building
Algo::Render::GL2::MapRender* m_render_scenary;
Utils::VBO* m_positionVBO_scenary;
......
......@@ -9,11 +9,12 @@
#include "agent.h"
#include "simulator.h"
#include "Geometry/frame.h"
#include "Utils/colorMaps.h"
unsigned int Agent::maxNeighbors_ = 10 ;
unsigned int Agent::maxMovingObstacles_ = 20;
float Agent::averageMaxSpeed_ = 2.0f ;
// float Agent::averageMaxSpeed_ = 20.0f ;
//float Agent::averageMaxSpeed_ = 2.0f ;
float Agent::averageMaxSpeed_ = 20.0f ;
// float Agent::neighborDist_ = 10.0f ;
float Agent::neighborDist_ = 20.0f ;
float Agent::neighborDistSq_ = neighborDist_ * neighborDist_ ;
......@@ -122,7 +123,10 @@ void Agent::initGL()
{
#ifdef EXPORTING_AGENT
m_ghost_shader = new Utils::ShaderSimpleColor();
m_ghost_shader->setColor(Geom::Vec4f(1.,0.,0.,0.));
VEC3 col = Utils::color_map_BCGYR(float(agentNo)/float(sim_->agents_.size()));
m_ghost_shader->setColor(Geom::Vec4f(col[0],col[1],col[2],0.));
// m_ghost_shader->setColor(Geom::Vec4f(1.,0.,0.,0.));
// m_ghost_shader->setAmbiant(Geom::Vec4f(1.,1.,0.,0.)) ;
// m_ghost_shader->setDiffuse(Geom::Vec4f(1.,1.,0.,0.));
......@@ -475,9 +479,12 @@ void Agent::update()
#endif
#ifdef EXPORTING_AGENT
m_ghost_previousPos.push_back(target);
if(m_ghost_previousPos.size()>m_ghost_nb)
m_ghost_previousPos.pop_front();
if(int(sim_->globalTime_ / sim_->timeStep_) % 4 == 0)
{
m_ghost_previousPos.push_back(target);
if(m_ghost_previousPos.size()>m_ghost_nb)
m_ghost_previousPos.pop_front();
}
#endif
#endif
......
......@@ -85,6 +85,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
break ;
case 2 :
CityGenerator::generateGrid<PFP>(*this) ;
// CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
break ;
case 3 :
......@@ -204,7 +205,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
map.init() ;
// registerObstaclesInFaces();
// TODO Check registerWallInFaces();
registerWallInFaces() ;
// registerWallInFaces() ;
// subdivideAllToMaxLevel();
for (unsigned int i = subdivisableFace.begin(); i < subdivisableFace.end(); subdivisableFace.next(i))
......
......@@ -36,6 +36,7 @@ void MovingObstacle::addGeneralCell ( Dart d)
general_belonging.push_back(std::make_pair(d,1));
}
}
bool MovingObstacle::removeGeneralCell (Dart d)
{
std::vector< std::pair<Dart,int> >::iterator it =general_belonging.begin();
......@@ -775,15 +776,20 @@ void MovingObstacle::update()
Obstacle* o = obstacles_[i];
o->p1 = getDilatedPosition(i);
o->p2 = getDilatedPosition((i+1) % nbVertices);
#ifndef POTENTIAL
o->prevP = getDilatedPosition((i - 1 + nbVertices) % nbVertices);
o->nextP = getDilatedPosition((i + 2 + nbVertices) % nbVertices);
#endif
Dart d1 = parts_[i]->d;
Dart d2 = parts_[(i+1)%nbVertices]->d;
if(!((sim_->envMap_.map.sameFace(d1,d2))&& (parts_[i]->crossCell==CGoGN::Algo::Surface::MovingObjects::NO_CROSS && parts_[(i+1)%nbVertices]->crossCell==CGoGN::Algo::Surface::MovingObjects::NO_CROSS)))
{
sim_->envMap_.popAndPushObstacleInCells(o,i);
sim_->envMap_.popAndPushObstacleInCells(o,i);
}
/////affichage des belonging cells
// CGoGNout<< CGoGNendl;
// CGoGNout << "Obstacle "<< i << ": ";
......@@ -859,13 +865,14 @@ void resetObstPartInFace(Obstacle* o, Dart d1)
{
MovingObstacle * mo = o->mo;
if (mo != NULL) {
if (mo != NULL)
{
unsigned int n =o->index;
VEC3 pos1 = mo->parts_[n]->getPosition();
if (Algo::Surface::Geometry::isPointInConvexFace2D < PFP
> (mo->sim_->envMap_.map, d1, mo->sim_->envMap_.position, pos1, true)) {
if (Algo::Surface::Geometry::isPointInConvexFace2D<PFP>(mo->sim_->envMap_.map, d1, mo->sim_->envMap_.position, pos1, true))
mo->parts_[n]->d = d1;
}
if(n==0)
mo->dDir = mo->parts_[0]->d;
}
......@@ -880,10 +887,9 @@ void resetPart(Obstacle * o, Dart d1)
if (mo->parts_[n]->d == mo->sim_->envMap_.map.phi1(d1))
mo->parts_[n]->d = d1;
if(n==0)
mo->dDir = mo->parts_[n]->d;
}
}
......@@ -902,7 +908,7 @@ void displayMO(Obstacle * o)
void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atteindre l'objectif // changer pour 2.5 ?
{
VEC3 goalVector;
if (index_parent<1)
if (index_parent<1) //not articulated
{
if(rigid_ || goals_.size()>1)
{
......@@ -976,9 +982,9 @@ void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atte
}
}
}
else
else //articulated
{
goalVector = get_center(parent,index_parent-1) -center;
goalVector = (get_center(parent,index_parent-1) -center);
float goalDist2 = goalVector.norm2() ;
if (goalDist2 > maxSpeed_)
{
......@@ -988,7 +994,20 @@ void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atte
}
if (spinning)
angle =get_angle(goalVector,front-center);
{
float n_angle = get_angle(goalVector,front-center);
float bornAngle = M_PI/64.0f;
if(fabs(n_angle-angle)<bornAngle)
angle = n_angle;
else
{
if(n_angle-angle>=0.0f)
angle += bornAngle;
else
angle -= bornAngle;
}
}
prefVelocity_ = goalVector ;
......
......@@ -160,8 +160,10 @@ void Simulator::doStep()
}
}
#else
if (multires)
envMap_.map.setCurrentLevel(envMap_.map.getMaxLevel()) ;
nb_dead = 0 ;
for (unsigned int i = 0 ; i < agents_.size() ; ++i)
{
......@@ -170,17 +172,8 @@ void Simulator::doStep()
Dart oldFace = agents_[i]->part_.d ;
agents_[i]->update() ;
// if(envMap_.map.getEmbedding(oldFace, FACE) != envMap_.map.getEmbedding(agents_[i]->part_.d, FACE))
if (agents_[i]->part_.crossCell != CGoGN::Algo::Surface::MovingObjects::NO_CROSS)
// switch(agents_[i]->part_.crossCell)
{
// case CGoGN::Algo::MovingObjects::CROSS_EDGE :
// envMap_.agentChangeFaceThroughEdge(agents_[i]);
// break;
// case CGoGN::Algo::MovingObjects::CROSS_OTHER :
envMap_.agentChangeFace(agents_[i], oldFace) ;
// break;
}
}
else
nb_dead++ ;
......@@ -223,14 +216,9 @@ void Simulator::addAgent(const VEC3& start, const VEC3& goal, Dart d)
void Simulator::setupCircleScenario(unsigned int nbAgents , unsigned int nbObstacles)
{
if (multires)
{
envMap_.init(config, 2000.0f, 2000.0f, minSize, 400.0f) ; //grosses cases
}
else
{
envMap_.init(config, 2000.0f, 2000.0f, minSize, 400.0f) ; //cases fines
}
std::cout << " - Setup Circle Scenario : " << nbAgents << " agents et " << nbObstacles << " obstacles"<< std::endl ;
......@@ -508,17 +496,17 @@ void Simulator::setupSnakeCorridorScenario(unsigned int nbAgents, unsigned int n
xStartMin = envMap_.geometry.min()[0] + envMap_.geometry.size(0) / 4 ;
xStartDelta = envMap_.geometry.size(0) / 2 ;
yStartMin = envMap_.geometry.min()[1] + yBorder ;
yStartDelta = envMap_.geometry.size(1) / 20 ;
yStartDelta = envMap_.geometry.size(1) / 10 ;
// Arrivée des obstacles à l'opposée
yGoalDelta = 3* envMap_.geometry.size(1) / 5 ;
yGoalDelta = envMap_.geometry.size(1) / 5 ;
yGoalMin = envMap_.geometry.max()[1] - yBorder - yGoalDelta ;
VEC3 xSide (5.0f,0.0f,0.0f);
VEC3 ySide (0.0f,10.0f,0.0f);
std::cout << "geom : " << envMap_.geometry << std::endl;
int sumObstacles=0;
for(unsigned int j = 0; j<nbSnakes; j++)
......@@ -541,12 +529,17 @@ void Simulator::setupSnakeCorridorScenario(unsigned int nbAgents, unsigned int n
std::vector<VEC3> goals;
goals.push_back(start);
int r=0;
while (r<40)
while (r<80)
{
x = xStartMin + rand() % xStartDelta;
goal=VEC3 (x, yGoalMin + rand() % yGoalDelta, 0) ;
if ((goal-goals[r]).norm2()>1000)
if ((r==0 || angle(goal-goals[r],goals[r]-goals[r-1])<M_PI/2.0f) )
{
std::cout << "new goal " << goal << std::endl;
goals.push_back(goal);
r++;
}
......@@ -604,8 +597,8 @@ void Simulator::setupScenario(unsigned int nbMaxAgent, bool pedWay)
TraversorF<PFP::MAP> tF(envMap_.map);
Dart d = tF.begin() ;
unsigned int nbx = 4 ;
unsigned int nby = 4 ;
unsigned int nbx = 1 ;
unsigned int nby = 1 ;
unsigned int bMax = nbx * nby > 0 ? nbMaxAgent / (nbx * nby) : nbMaxAgent ;
......
This diff is collapsed.
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