Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
af76ccee
Commit
af76ccee
authored
Jul 01, 2011
by
Pierre Kraemer
Browse files
correction GROS BUG !!
parent
42b91bf6
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/env_render.h
View file @
af76ccee
...
...
@@ -3,6 +3,7 @@
#include
"env_map.h"
#include
"agent.h"
#include
"Utils/colorMaps.h"
inline
void
renderDart
(
EnvMap
&
m
,
Dart
d
)
{
...
...
@@ -48,13 +49,15 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
VEC3
pos
=
agent
->
part_
.
m_position
;
float
radius
=
agent
->
radius_
;
Geom
::
Plane3D
<
float
>
pl
=
Algo
::
Geometry
::
facePlane
<
PFP
>
(
m
.
map
,
agent
->
part_
.
d
,
m
.
position
);
pos
[
2
]
-=
1000
;
Geom
::
intersectionPlaneRay
(
pl
,
pos
,
VEC3
(
0
,
0
,
-
1
),
pos
);
//
Geom::Plane3D<float> pl = Algo::Geometry::facePlane<PFP>(m.map,agent->part_.d,m.position);
//
pos[2] -= 1000;
//
Geom::intersectionPlaneRay(pl,pos,VEC3(0,0,-1),pos);
glLineWidth
(
1
.
0
f
);
glColor3f
(
1
.
0
f
,
0
.
0
f
,
0
.
0
f
);
// VEC3 col = Utils::color_map_BCGYR(float(agent->agentNo)/float(agent->sim_->agents_.size()));
// glColor3fv(col.data());
glColor3f
(
1
.
0
f
,
0
.
0
f
,
0
.
0
f
);
glBegin
(
GL_POLYGON
);
for
(
unsigned
int
i
=
0
;
i
<
5
;
++
i
)
glVertex3f
(
pos
[
0
]
+
(
cosT
[
i
]
*
radius
),
pos
[
1
]
+
(
sinT
[
i
]
*
radius
),
pos
[
2
]
+
0
.
01
f
);
...
...
src/env_map.cpp
View file @
af76ccee
...
...
@@ -171,7 +171,7 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
void
EnvMap
::
init
()
{
float
sideSize
=
70.0
f
;
unsigned
int
nbSquares
=
5
;
unsigned
int
nbSquares
=
14
;
// float sideSize = 420.0f;
// unsigned int nbSquares = 4;
...
...
@@ -509,6 +509,8 @@ void EnvMap::updateMap()
if
(
map
.
faceIsSubdividedOnce
(
old
))
{
// on compte le nombre d'agents dans les sous-faces
// on en profite pour compter le degré de la face grossière
unsigned
int
degree
=
0
;
unsigned
int
nbAgents
=
0
;
Dart
fit
=
old
;
...
...
@@ -516,6 +518,21 @@ void EnvMap::updateMap()
{
nbAgents
+=
agentvect
[
fit
].
size
()
;
++
degree
;
coarsenMark
.
unmark
(
fit
)
;
unsigned
int
start
=
it
+
1
;
unsigned
int
fEmb
=
map
.
getEmbedding
(
FACE
,
fit
)
;
while
(
start
<
coarsenCandidate
.
size
())
{
if
(
map
.
getEmbedding
(
FACE
,
coarsenCandidate
[
start
])
==
fEmb
)
{
coarsenCandidate
[
start
]
=
coarsenCandidate
.
back
()
;
coarsenCandidate
.
pop_back
()
;
}
else
++
start
;
}
fit
=
map
.
phi1
(
fit
)
;
}
while
(
fit
!=
old
)
;
if
(
degree
==
3
)
...
...
@@ -523,6 +540,19 @@ void EnvMap::updateMap()
map
.
setCurrentLevel
(
fLevel
)
;
Dart
centerFace
=
map
.
phi2
(
map
.
phi1
(
old
))
;
nbAgents
+=
agentvect
[
centerFace
].
size
()
;
coarsenMark
.
unmark
(
centerFace
)
;
unsigned
int
start
=
it
+
1
;
unsigned
int
fEmb
=
map
.
getEmbedding
(
FACE
,
centerFace
)
;
while
(
start
<
coarsenCandidate
.
size
())
{
if
(
map
.
getEmbedding
(
FACE
,
coarsenCandidate
[
start
])
==
fEmb
)
{
coarsenCandidate
[
start
]
=
coarsenCandidate
.
back
()
;
coarsenCandidate
.
pop_back
()
;
}
else
++
start
;
}
map
.
setCurrentLevel
(
fLevel
-
1
)
;
}
...
...
@@ -532,25 +562,11 @@ void EnvMap::updateMap()
Dart
fit
=
old
;
do
{
map
.
setCurrentLevel
(
fLevel
)
;
coarsenMark
.
unmark
(
fit
)
;
unsigned
int
start
=
it
+
1
;
unsigned
int
fEmb
=
map
.
getEmbedding
(
FACE
,
fit
)
;
while
(
start
<
coarsenCandidate
.
size
())
{
if
(
map
.
getEmbedding
(
FACE
,
coarsenCandidate
[
start
])
==
fEmb
)
{
coarsenCandidate
[
start
]
=
coarsenCandidate
.
back
()
;
coarsenCandidate
.
pop_back
()
;
}
else
++
start
;
}
PFP
::
AGENTS
a
(
agentvect
[
fit
])
;
agents
.
insert
(
agents
.
end
(),
a
.
begin
(),
a
.
end
())
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
for
(
PFP
::
AGENTS
::
iterator
ait
=
a
.
begin
();
ait
!=
a
.
end
();
++
ait
)
popAgentInCells
(
*
ait
,
fit
);
popAgentInCells
(
*
ait
,
fit
)
;
map
.
setCurrentLevel
(
fLevel
-
1
)
;
Dart
nf
=
map
.
phi2
(
fit
)
;
if
(
!
map
.
faceIsSubdivided
(
nf
))
...
...
@@ -566,24 +582,10 @@ void EnvMap::updateMap()
}
fit
=
map
.
phi1
(
fit
)
;
}
while
(
fit
!=
old
)
;
if
(
degree
==
3
)
{
map
.
setCurrentLevel
(
fLevel
)
;
Dart
centerFace
=
map
.
phi2
(
map
.
phi1
(
old
))
;
coarsenMark
.
unmark
(
centerFace
)
;
unsigned
int
start
=
it
+
1
;
unsigned
int
fEmb
=
map
.
getEmbedding
(
FACE
,
centerFace
)
;
while
(
start
<
coarsenCandidate
.
size
())
{
if
(
map
.
getEmbedding
(
FACE
,
coarsenCandidate
[
start
])
==
fEmb
)
{
coarsenCandidate
[
start
]
=
coarsenCandidate
.
back
()
;
coarsenCandidate
.
pop_back
()
;
}
else
++
start
;
}
PFP
::
AGENTS
a
(
agentvect
[
centerFace
])
;
agents
.
insert
(
agents
.
end
(),
a
.
begin
(),
a
.
end
())
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
());
...
...
@@ -591,6 +593,7 @@ void EnvMap::updateMap()
popAgentInCells
(
*
ait
,
centerFace
);
map
.
setCurrentLevel
(
fLevel
-
1
)
;
}
neighborAgentvect
[
old
].
clear
();
Algo
::
IHM
::
coarsenFace
<
PFP
>
(
map
,
old
,
position
)
;
...
...
@@ -600,7 +603,6 @@ void EnvMap::updateMap()
map
.
setCurrentLevel
(
map
.
getMaxLevel
());
agentvect
[
old
].
clear
();
for
(
PFP
::
AGENTS
::
iterator
itA
=
agents
.
begin
();
itA
!=
agents
.
end
();
++
itA
)
{
(
*
itA
)
->
part_
.
d
=
old
;
...
...
@@ -628,8 +630,6 @@ void EnvMap::updateMap()
}
}
map
.
setCurrentLevel
(
cur
)
;
}
}
...
...
src/simulator.cpp
View file @
af76ccee
#include
"simulator.h"
Simulator
::
Simulator
()
:
globalTime_
(
0.0
f
),
timeStep_
(
0.2
5
f
)
Simulator
::
Simulator
()
:
globalTime_
(
0.0
f
),
timeStep_
(
0.2
f
)
{
srand
(
10
);
envMap_
.
init
();
std
::
cout
<<
"setup scenario"
<<
std
::
endl
;
// importAgents("myAgents.pos");
setupScenario
(
1
0
);
setupScenario
(
70
0
);
// setupCircleScenario(1000);
// setupCityScenario(-1.0f*(24*(70/2.0f)-10),-1.0f*(24*(70.0f/2.0f)-10),167,5);
// addPathsToAgents();
...
...
@@ -97,11 +97,11 @@ void Simulator::doStep()
globalTime_
+=
timeStep_
;
//
if(int(globalTime_ / timeStep_) % 2000 == 0)
//
{
//
std::cout << "swap goals (globalTime -> " << globalTime_ << ")" << std::endl ;
//
swapAgentsGoals();
//
}
if
(
int
(
globalTime_
/
timeStep_
)
%
2000
==
0
)
{
std
::
cout
<<
"swap goals (globalTime -> "
<<
globalTime_
<<
")"
<<
std
::
endl
;
swapAgentsGoals
();
}
}
bool
Simulator
::
reachedGoal
()
...
...
@@ -169,8 +169,8 @@ void Simulator::setupScenario(unsigned int nbMaxAgent)
Dart
d
=
envMap_
.
map
.
begin
();
CellMarker
filled
(
envMap_
.
map
,
FACE
);
unsigned
int
nbx
=
2
;
unsigned
int
nby
=
2
;
unsigned
int
nbx
=
10
;
unsigned
int
nby
=
10
;
unsigned
int
bMax
=
nbMaxAgent
/
(
nbx
*
nby
);
...
...
src/viewer.cpp
View file @
af76ccee
...
...
@@ -114,6 +114,60 @@ void SocialAgents::cb_redraw()
// renderDart(sim.envMap_, obst->second);
// }
}
// CellMarker m(sim.envMap_.map, FACE);
// for(Dart d = sim.envMap_.map.begin() ; d != sim.envMap_.map.end() ; sim.envMap_.map.next(d))
// {
// if(!m.isMarked(d) && !sim.envMap_.buildingMark.isMarked(d))
// {
// m.mark(d);
//
// Dart dd = d;
// VEC3 cornerLeftBottom = sim.envMap_.position[d];
// do
// {
// VEC3 p = sim.envMap_.position[dd];
// if(cornerLeftBottom[0] > p[0])
// cornerLeftBottom[0] = p[0];
// if(cornerLeftBottom[1] > p[1])
// cornerLeftBottom[1] = p[1];
// if(cornerLeftBottom[2] > p[2])
// cornerLeftBottom[2] = p[2];
// dd = sim.envMap_.map.phi1(dd);
// } while (dd != d);
//
// //draw vectors
// //contains
// for(unsigned int i = 0 ; i < sim.envMap_.agentvect[d].size() ; ++i)
// {
// Agent* ag = sim.envMap_.agentvect[d][i];
//
// VEC3 col = Utils::color_map_BCGYR(float(ag->agentNo)/float(sim.agents_.size()));
// glColor3fv(col.data());
// glBegin(GL_POINTS);
// if(i < 5)
// glVertex3f(cornerLeftBottom[0]+5+1+i*2, cornerLeftBottom[1]+7+1.5, cornerLeftBottom[2]+2);
// else
// glVertex3f(cornerLeftBottom[0]+5+1+(i-5)*2, cornerLeftBottom[1]+7+1.5+3, cornerLeftBottom[2]+2);
// glEnd();
// }
//
// //neighbours
// for(unsigned int i = 0 ; i < sim.envMap_.neighborAgentvect[d].size() ; ++i)
// {
// Agent* ag = sim.envMap_.neighborAgentvect[d][i];
//
// VEC3 col = Utils::color_map_BCGYR(float(ag->agentNo)/float(sim.agents_.size()));
// glColor3fv(col.data());
// glBegin(GL_POINTS);
// if(i < 8)
// glVertex3f(12+cornerLeftBottom[0]+5+1+i*2, cornerLeftBottom[1]+7+1.5, cornerLeftBottom[2]+2);
// else
// glVertex3f(12+cornerLeftBottom[0]+5+1+(i-8)*2, cornerLeftBottom[1]+7+1.5+3, cornerLeftBottom[2]+2);
// glEnd();
// }
// }
// }
}
if
(
drawAgentsPredictionTri
)
...
...
@@ -279,23 +333,23 @@ void SocialAgents::cb_redraw()
void
SocialAgents
::
animate
()
{
if
(
sim
.
globalTime_
-
int
(
sim
.
globalTime_
)
==
0.0
f
&&
int
(
sim
.
globalTime_
)
%
10
==
0
)
if
(
sim
.
globalTime_
-
int
(
sim
.
globalTime_
)
==
0.0
f
&&
int
(
sim
.
globalTime_
)
%
10
00
==
0
)
std
::
cout
<<
sim
.
globalTime_
<<
" "
<<
sim
.
envMap_
.
mapMemoryCost
()
<<
std
::
endl
;
// std::cout << "t : " << sim.globalTime_ << std::endl;
timeval
startTime
;
gettimeofday
(
&
startTime
,
NULL
);
timeval
endTime
;
long
seconds
,
nseconds
;
//
timeval startTime;
//
gettimeofday(&startTime, NULL);
//
timeval endTime;
//
long seconds, nseconds;
sim
.
doStep
();
gettimeofday
(
&
endTime
,
NULL
);
seconds
=
endTime
.
tv_sec
-
startTime
.
tv_sec
;
nseconds
=
endTime
.
tv_usec
-
startTime
.
tv_usec
;
elapsedTime
+=
(
seconds
+
nseconds
/
1000000.0
)
;
//
gettimeofday(&endTime, NULL);
//
seconds = endTime.tv_sec - startTime.tv_sec;
//
nseconds = endTime.tv_usec - startTime.tv_usec;
//
//
elapsedTime += (seconds + nseconds/1000000.0) ;
// if(sim.globalTime_ - int(sim.globalTime_) == 0.0f && int(sim.globalTime_) % 1500 == 0)
// {
...
...
@@ -723,7 +777,6 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
if
(
infoFaces
)
{
CellMarker
m
(
sim
.
envMap_
.
map
,
FACE
);
// m.unmarkAll();
for
(
Dart
d
=
sim
.
envMap_
.
map
.
begin
()
;
d
!=
sim
.
envMap_
.
map
.
end
()
;
sim
.
envMap_
.
map
.
next
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment