Commit 0fcc8b63 authored by Thomas Jund's avatar Thomas Jund

plus d'info a l affichage, un peu de debug pour 2.5

parent 0a2ddaee
......@@ -73,6 +73,7 @@ public:
#ifndef SPATIAL_HASHING
Dart getBelongingCell(const VEC3& pos) ;
Dart getBelongingCellOnSurface(const VEC3& pos) ;
void subdivideAllToMaxLevel() ;
void subdivideToProperLevel() ;
......
......@@ -98,7 +98,7 @@ public:
void setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles);
void addMovingObstacles(unsigned int nb);
void addMovingObstacles(unsigned int nb, unsigned int type);
void addMovingObstacle(Dart d, unsigned int obstType=0);
void addAgent(const VEC3& start,const VEC3& goals);
......
......@@ -286,6 +286,8 @@ public slots:
{
for(unsigned int i=0 ; i < simulator.movingObstacles_.size() ; ++i)
{
for(unsigned int j=0 ; j < simulator.movingObstacles_[i]->nbVertices ; ++j)
{
m_triObst_render.push_back(new Algo::Render::GL2::MapRender());
Utils::ShaderSimpleColor * shader = new Utils::ShaderSimpleColor();
......@@ -301,6 +303,7 @@ public slots:
m_triObst_VBO.push_back(vbo);
m_triObst_Shader.push_back(shader);
registerShader(shader);
}
}
}
......
......@@ -564,14 +564,36 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
if (!m.isMarked(d))
{
m.mark(d) ;
if (!buildingMark.isMarked(d)
&& Algo::Surface::Geometry::isPointInConvexFace2D<PFP>(map, d, position, pos, true)) return d ;
if (!buildingMark.isMarked(d) && Algo::Surface::Geometry::isPointInConvexFace2D<PFP>(map, d, position, pos, true))
return d ;
}
}
std::cout << "ERROR : pos not in map for getBelongingCell " << pos << std::endl ;
return map.begin() ;
}
Dart EnvMap::getBelongingCellOnSurface(const PFP::VEC3& pos)
{
// assert(map.getCurrentLevel() == map.getMaxLevel()) ;
CellMarkerStore<FACE> m(map) ;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!m.isMarked(d))
{
m.mark(d) ;
if (!buildingMark.isMarked(d) && Algo::Surface::Geometry::isPointInConvexFace<PFP>(map, d, position, pos, true))
{
return d ;
}
}
}
std::cout << "ERROR : pos not in map for getBelongingCell " << pos << std::endl ;
return map.begin() ;
}
#endif
#ifndef SPATIAL_HASHING
......
......@@ -168,11 +168,12 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
for (unsigned int i = 0; i < nbVertices; ++i)
{
Dart d = sim_->envMap_.getBelongingCell(pos[i]);
#ifdef TWO_AND_HALF_DIM
Dart d = sim_->envMap_.getBelongingCellOnSurface(pos[i]);
CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>* part = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>(sim_->envMap_.map, d, pos[i], sim_->envMap_.position);
#else
Dart d = sim_->envMap_.getBelongingCell(pos[i]);
CGoGN::Algo::Surface::MovingObjects::ParticleCell2D<PFP>* part = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2D<PFP>(sim_->envMap_.map, d, pos[i], sim_->envMap_.position);
#endif
parts_[i] = part;
......@@ -977,10 +978,14 @@ void MovingObstacle::updateForces()
position[d] += (velocity_ * sim_->timeStep_);
#ifdef EXPORTING_BOXES
#ifndef TWO_AND_HALF_DIM
position[map.phi<211>(d)] += rotate(position[map.phi<211>(d)], center, abs_angle*rotor);
position[map.phi<211>(d)] += (velocity_ * sim_->timeStep_);
#endif
#endif
// position[map.phi<211>(d)] += (velocity_ * sim_->timeStep_);
bary += position[d];
......@@ -1039,13 +1044,22 @@ void MovingObstacle::applyForces()
for (unsigned int i = 0; i < nbVertices; ++i)
{
#ifdef TWO_AND_HALF_DIM
std::cout << " dist supp " << (getDilatedPosition(i)-parts_[i]->getPosition()).norm() << std::endl;
VEC3 av = parts_[i]->getPosition();
std::cout << " dist prevu " << (getDilatedPosition(i) - parts_[i]->getPosition()).norm() << std::endl;
#endif
parts_[i]->move(getDilatedPosition(i));
#ifdef TWO_AND_HALF_DIM
std::cout << " dist " << parts_[i]->getDistance() << std::endl;
Dart d(i);
position[d] = parts_[i]->getPosition();
av -= parts_[i]->getPosition();
position[map.phi<112>(d)] -= av;
#endif
// CGoGNout << "avant une etape : Obstacle "<< i << CGoGNendl;
......
......@@ -52,7 +52,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case 3 :
envMap_.init(config, 1000.0f, 1000.0f, minSize, 100.0f) ; //grosses cases
setupScenario(nbAgent, false) ;
addMovingObstacles(nbObst);
addMovingObstacles(nbObst, 1);
addPathToObstacles(envMap_.buildingMark, true);
//// setupCityScenario(-1.0f * (12 * (70.0f / 2.0f) - 10),
//// -1.0f * (12 * (70.0f / 2.0f) - 10), 20, 20);
......@@ -64,7 +64,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
envMap_.init(config, 1600.0f, 1200.0f, minSize, 400.0f) ; //svg import
setupScenario(nbAgent, true) ;
// SelectorCellNotMarked<PFP::MAP> scnm(envMap_.pedWayMark);
addMovingObstacles(nbObst);
addMovingObstacles(nbObst, 1);
// addPathToObstacles(envMap_.pedWayMark, false);
addPathsToAgents();
break;
......@@ -72,7 +72,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
#ifdef TWO_AND_HALF_DIM
envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst);
addMovingObstacles(nbObst, 0);
addPathToObstacles(envMap_.buildingMark, true);
#else
std::cout << "Agents not in 2.5D mode" << std::endl;
......@@ -718,7 +718,7 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
swapAgentsGoals();
}
void Simulator::addMovingObstacles(unsigned int nb)
void Simulator::addMovingObstacles(unsigned int nb, unsigned int type)
{
TraversorF<PFP::MAP> tF(envMap_.map);
Dart d = tF.begin() ;
......@@ -743,7 +743,7 @@ void Simulator::addMovingObstacles(unsigned int nb)
}
if (found)
addMovingObstacle(dCell,1) ;
addMovingObstacle(dCell,type) ;
}
}
......@@ -764,23 +764,41 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
VEC3 ySide (0.0f,5.0f,0.0f);
#ifdef TWO_AND_HALF_DIM
Geom::Plane3D<PFP::REAL> pl(Algo::Surface::Geometry::faceNormal<PFP>(envMap_.map, d, envMap_.position), 0.0f);
Geom::Plane3D<PFP::REAL> pl(Algo::Surface::Geometry::facePlane<PFP>(envMap_.map, d, envMap_.position));
VEC3 np;
VEC3 displ = -xSide-ySide;
Agent::rotate(Agent::xyPlane, pl.normal(), displ);
vPos.push_back(start + displ);
np = start+displ;
pl.project(np); //<- without this line, the point is not on the plane
pl.project(np); //<- without this line, the point is not on the plane (no doublon)
vPos.push_back(np);
displ = xSide-ySide;
Agent::rotate(Agent::xyPlane, pl.normal(), displ);
vPos.push_back(start + displ);
np = start+displ;
pl.project(np);
vPos.push_back(np);
displ = xSide+ySide;
Agent::rotate(Agent::xyPlane, pl.normal(), displ);
vPos.push_back(start + displ);
np = start+displ;
pl.project(np);
vPos.push_back(np);
displ = ySide-xSide;
Agent::rotate(Agent::xyPlane, pl.normal(), displ);
vPos.push_back(start + displ);
np = start+displ;
pl.project(np);
vPos.push_back(np);
#else
vPos.push_back(start-xSide-ySide);
vPos.push_back(start+xSide-ySide);
......
......@@ -445,21 +445,27 @@ void SocialAgents::updateObstacleVBO()
void SocialAgents::updateObstaclePredTriVBO()
{
unsigned int count=0;
for(unsigned int i=0 ; i < simulator.movingObstacles_.size() ; ++i)
{
Utils::VBO * vbo = m_triObst_VBO[i];
PFP::VEC3* data = static_cast<PFP::VEC3*>(vbo->lockPtr());
for(unsigned int j = 0 ; j < simulator.movingObstacles_[i]->nbVertices ; ++j)
{
Utils::VBO * vbo = m_triObst_VBO[count++];
PFP::VEC3* data = static_cast<PFP::VEC3*>(vbo->lockPtr());
VEC3 p = simulator.movingObstacles_[i]->getDilatedPosition(0);
data[0] = p;
p = simulator.envMap_.position[simulator.movingObstacles_[i]->parts_[0]->d];
data[1] = p;
VEC3 p = simulator.movingObstacles_[i]->getDilatedPosition(j);
p = simulator.envMap_.position[simulator.envMap_.map.phi1(simulator.movingObstacles_[i]->parts_[0]->d)];
data[2] = p;
data[0] = p;
vbo->releasePtr();
VEC3 p1 = simulator.envMap_.position[simulator.movingObstacles_[i]->parts_[j]->d];
data[1] = p1;
VEC3 p2 = simulator.envMap_.position[simulator.envMap_.map.phi1(simulator.movingObstacles_[i]->parts_[j]->d)];
data[2] = p2;
vbo->releasePtr();
}
}
}
......@@ -751,7 +757,7 @@ void SocialAgents::cb_redraw()
{
updateObstaclePredTriVBO();
for(unsigned int i = 0 ; i < simulator.movingObstacles_.size() ; ++i)
for(unsigned int i = 0 ; i < m_triObst_Shader.size() ; ++i)
{
Utils::ShaderSimpleColor* moShader = m_triObst_Shader[i];
......
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