Commit 7154420a authored by Thomas's avatar Thomas
Browse files

simplifications des brins du bord, essaie d ecriture d un nouveau comportement experimental

parent 49a41675
......@@ -24,6 +24,8 @@ public:
void computePrefVelocity();
void computeNewVelocity();
void computeNewVelocity2();
bool linearProgram1(
const std::vector<Line>& lines, unsigned int lineNo,
float radius, const VEC3& optVelocity,
......
......@@ -408,6 +408,23 @@ void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, Ce
}
convexifyFreeSpace<PFP>(map, position, obstacleMark, buildingMark);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(buildingMark.isMarked(d) && !buildingMark.isMarked(map.phi2(d)))
{
if(map.alpha1(map.alpha1(map.phi1(d)))==map.phi1(d)
&& Geom::testOrientation2D(position[d], position[map.phi1(d)],position[map.phi1(map.phi1(d))])==Geom::ALIGNED)
{
VEC3 p = position[map.phi1(map.phi1(d))];
// Dart dN = map.phi1(d);
map.collapseEdge(map.phi1(d));
position[map.phi1(d)] = p;
}
}
}
map.check();
}
......
......@@ -126,6 +126,56 @@ void Agent::computePrefVelocity()
prefVelocity_ = goalVector + VEC3(dist * cos(angle), dist * sin(angle), 0.0f);
}
void Agent::computeNewVelocity2()
{
VEC3 centroid;
VEC3 c;
VEC3 vel;
float cohesion=1.0f;
centroid.zero();
c.zero();
vel.zero();
for(std::vector<std::pair<float, Dart> >::iterator it = obstacleNeighbors_.begin();
it != obstacleNeighbors_.end();
++it)
{
}
unsigned int nbA = 0;
for(std::vector<std::pair<float, Agent*> >::iterator it = agentNeighbors_.begin();
it != agentNeighbors_.end() && nbA < maxNeighbors_;
++it, ++nbA)
{
VEC3 mPos = part_.m_position;
VEC3 oPos = (*it).second->part_.m_position;
centroid += oPos;
VEC3 pOp(oPos-mPos);
if(pOp.norm2()<=radius_*radius_*maxSpeed_*maxSpeed_*2.0f) {
c -= pOp;
// prefVelocity_.zero();
}
vel += (*it).second->prefVelocity_;
}
if(nbA>0) {
centroid /= nbA;
centroid -= part_.m_position;
centroid /= 10;
vel /= nbA;
vel -= prefVelocity_;
vel /= 8;
}
newVelocity_ = prefVelocity_ + cohesion*centroid + c + vel;
}
/* Search for the best new velocity. */
void Agent::computeNewVelocity()
{
......
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