Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
e5aa38ee
Commit
e5aa38ee
authored
May 05, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correction critere subdivision (taille / rayon)
parent
c6aee824
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
65 deletions
+107
-65
include/agent.h
include/agent.h
+7
-7
include/env_map.h
include/env_map.h
+6
-2
include/utils.h
include/utils.h
+1
-1
src/agent.cpp
src/agent.cpp
+9
-9
src/env_map.cpp
src/env_map.cpp
+81
-43
src/simulator.cpp
src/simulator.cpp
+3
-3
No files found.
include/agent.h
View file @
e5aa38ee
...
...
@@ -49,13 +49,13 @@ public:
std
::
vector
<
VEC3
>
goals_
;
unsigned
int
curGoal_
;
size_t
maxNeighbors_
;
float
maxSpeed_
;
float
neighborDistSq_
;
float
radius_
;
float
timeHorizon_
;
float
timeHorizonObst_
;
float
rangeSq_
;
static
size_t
maxNeighbors_
;
static
float
maxSpeed_
;
static
float
neighborDistSq_
;
static
float
radius_
;
static
float
timeHorizon_
;
static
float
timeHorizonObst_
;
static
float
rangeSq_
;
VEC3
velocity_
;
VEC3
newVelocity_
;
...
...
include/env_map.h
View file @
e5aa38ee
...
...
@@ -40,6 +40,8 @@ struct PFP: public PFP_STANDARD
typedef
NoMathIONameAttribute
<
OBSTACLES
>
OBSTACLEVECT
;
typedef
AttributeHandler
<
AGENTVECT
>
TAB_AGENTVECT
;
typedef
AttributeHandler
<
OBSTACLEVECT
>
TAB_OBSTACLEVECT
;
typedef
NoMathIONameAttribute
<
std
::
pair
<
bool
,
bool
>
>
BOOLATTRIB
;
};
typedef
PFP
::
VEC3
VEC3
;
...
...
@@ -70,7 +72,7 @@ public :
void
addRefineCandidate
(
Dart
d
);
void
addCoarsenCandidate
(
Dart
d
);
void
clearUpdateCandidates
();
void
updateMap
();
void
resetAgentInFace
(
Agent
*
agent
);
...
...
@@ -80,6 +82,8 @@ public :
PFP
::
TVEC3
position
;
PFP
::
TVEC3
normal
;
AttributeHandler
<
PFP
::
BOOLATTRIB
>
subdivisableFace
;
PFP
::
TAB_AGENTVECT
agentvect
;
PFP
::
TAB_AGENTVECT
neighborAgentvect
;
...
...
@@ -88,7 +92,7 @@ public :
CellMarker
obstacleMark
;
CellMarker
buildingMark
;
static
const
unsigned
int
nbAgentsToSubdivide
=
3
;
static
const
unsigned
int
nbAgentsToSubdivide
=
7
;
static
const
unsigned
int
nbAgentsToSimplify
=
7
;
std
::
map
<
unsigned
int
,
Dart
>
refineCandidate
;
...
...
include/utils.h
View file @
e5aa38ee
...
...
@@ -21,7 +21,7 @@ inline float det2D(const VEC3& vector1, const VEC3& vector2)
return
vector1
[
0
]
*
vector2
[
1
]
-
vector1
[
1
]
*
vector2
[
0
];
}
inline
float
distSqPointLineSegment
(
VEC3
a1
,
VEC3
b1
,
const
VEC3
&
c1
)
inline
float
distSqPointLineSegment
(
VEC3
a1
,
VEC3
b1
,
const
VEC3
&
c1
)
{
a1
[
2
]
=
0
;
b1
[
2
]
=
0
;
...
...
src/agent.cpp
View file @
e5aa38ee
#include "agent.h"
#include "simulator.h"
size_t
Agent
::
maxNeighbors_
=
10
;
float
Agent
::
maxSpeed_
=
2.0
f
;
float
Agent
::
neighborDistSq_
=
15.0
f
*
15.0
f
;
float
Agent
::
radius_
=
1.5
f
;
float
Agent
::
timeHorizon_
=
10.0
f
;
float
Agent
::
timeHorizonObst_
=
10.0
f
;
float
Agent
::
rangeSq_
=
(
timeHorizonObst_
*
maxSpeed_
+
radius_
)
*
(
timeHorizonObst_
*
maxSpeed_
+
radius_
);
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC3
&
position
,
Dart
d
)
:
part_
(
sim
->
envMap_
.
map
,
d
,
position
,
sim
->
envMap_
.
position
),
curGoal_
(
-
1
),
maxNeighbors_
(
10
),
maxSpeed_
(
2.0
f
),
neighborDistSq_
(
15.0
f
*
15.0
f
),
radius_
(
1.5
f
),
timeHorizon_
(
10.0
f
),
timeHorizonObst_
(
10.0
f
),
velocity_
(
0
),
newVelocity_
(
0
),
prefVelocity_
(
0
),
sim_
(
sim
)
{
rangeSq_
=
(
timeHorizonObst_
*
maxSpeed_
+
radius_
)
*
(
timeHorizonObst_
*
maxSpeed_
+
radius_
);
}
{}
VEC3
Agent
::
getPosition
()
{
...
...
src/env_map.cpp
View file @
e5aa38ee
...
...
@@ -16,6 +16,7 @@ EnvMap::EnvMap() : obstacleMark(map, EDGE_CELL), buildingMark(map, FACE_CELL)
agentvect
=
map
.
addAttribute
<
PFP
::
AGENTVECT
>
(
FACE_ORBIT
,
"agents"
);
neighborAgentvect
=
map
.
addAttribute
<
PFP
::
AGENTVECT
>
(
FACE_ORBIT
,
"neighborAgents"
);
obstvect
=
map
.
addAttribute
<
PFP
::
OBSTACLEVECT
>
(
FACE_ORBIT
,
"obstacles"
);
subdivisableFace
=
map
.
addAttribute
<
PFP
::
BOOLATTRIB
>
(
FACE_ORBIT
,
"subdivisableFace"
);
}
unsigned
int
EnvMap
::
mapMemoryCost
()
...
...
@@ -41,12 +42,14 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
void
EnvMap
::
init
()
{
float
sideSize
=
70.0
f
;
unsigned
int
nbSquares
=
7
;
unsigned
int
nbSquares
=
25
;
CityGenerator
::
generateCity
<
PFP
>
(
map
,
position
,
obstacleMark
,
buildingMark
,
sideSize
,
nbSquares
);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
CityGenerator
::
simplifyFreeSpace
<
PFP
>
(
map
,
position
,
obstacleMark
,
buildingMark
);
map
.
init
();
registerObstaclesInFaces
();
for
(
unsigned
int
i
=
subdivisableFace
.
begin
();
i
<
subdivisableFace
.
end
();
subdivisableFace
.
next
(
i
))
subdivisableFace
[
i
].
first
=
false
;
}
void
EnvMap
::
foreach_neighborFace
(
Dart
d
,
FunctorType
&
f
)
...
...
@@ -225,62 +228,97 @@ void EnvMap::updateMap()
if
(
agentvect
[
old
].
size
()
>
nbAgentsToSubdivide
)
{
PFP
::
AGENTS
oldAgents
(
agentvect
[
old
]);
for
(
PFP
::
AGENTS
::
iterator
ait
=
oldAgents
.
begin
();
ait
!=
oldAgents
.
end
();
++
ait
)
popAgentInCells
(
*
ait
,
old
);
neighborAgentvect
[
old
].
clear
()
;
map
.
setCurrentLevel
(
fLevel
)
;
CellMarkerStore
newF
(
map
,
FACE_CELL
);
newF
.
mark
(
old
);
Algo
::
IHM
::
subdivideFace
<
PFP
>
(
map
,
old
,
position
)
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
for
(
PFP
::
AGENTS
::
iterator
ait
=
oldAgents
.
begin
();
ait
!=
oldAgents
.
end
();
++
ait
)
bool
subdivisable
=
true
;
if
(
subdivisableFace
[
old
].
first
==
true
)
{
resetAgentInFace
(
*
ait
)
;
pushAgentInCells
(
*
ait
,
(
*
ait
)
->
part_
.
d
)
;
subdivisable
=
subdivisableFace
[
old
].
second
;
}
unsigned
int
degree
=
0
;
Dart
dd
=
old
;
do
else
{
++
degree
;
Dart
d3
=
dd
;
float
maxEdgeSize
=
Agent
::
neighborDistSq_
;
// diametre de vision de l'agent au carré
map
.
setCurrentLevel
(
fLevel
)
;
PFP
::
VEC3
fCenter
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
old
,
position
)
;
Dart
fd
=
old
;
do
{
Dart
d4
=
map
.
alpha1
(
map
.
alpha1
(
d3
));
while
(
d4
!=
d3
)
PFP
::
VEC3
edge
=
Algo
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
fd
,
position
)
;
PFP
::
VEC3
proj
=
fCenter
-
(
position
[
fd
]
+
(
edge
*
(
fCenter
-
position
[
fd
])
/
edge
.
norm2
())
*
edge
)
;
if
(
proj
.
norm2
()
<
maxEdgeSize
)
// if(Algo::Geometry::vectorOutOfDart<PFP>(map, fd, position).norm2() < maxEdgeSize)
{
if
(
!
newF
.
isMarked
(
d4
))
neighborAgentvect
[
d3
].
insert
(
neighborAgentvect
[
d3
].
end
(),
agentvect
[
d4
].
begin
(),
agentvect
[
d4
].
end
());
d4
=
map
.
alpha1
(
d4
);
subdivisable
=
false
;
break
;
}
d3
=
map
.
phi1
(
d3
);
}
while
(
d3
!=
dd
);
fd
=
map
.
phi1
(
fd
)
;
}
while
(
fd
!=
old
)
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
subdivisableFace
[
old
].
first
=
true
;
subdivisableFace
[
old
].
second
=
subdivisable
;
}
if
(
subdivisable
)
{
subdivisableFace
[
old
].
first
=
false
;
PFP
::
AGENTS
oldAgents
(
agentvect
[
old
]);
for
(
PFP
::
AGENTS
::
iterator
ait
=
oldAgents
.
begin
();
ait
!=
oldAgents
.
end
();
++
ait
)
popAgentInCells
(
*
ait
,
old
);
neighborAgentvect
[
old
].
clear
()
;
map
.
setCurrentLevel
(
fLevel
)
;
dd
=
map
.
phi1
(
dd
);
CellMarkerStore
newF
(
map
,
FACE_CELL
);
newF
.
mark
(
old
);
Algo
::
IHM
::
subdivideFace
<
PFP
>
(
map
,
old
,
position
)
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
}
while
(
dd
!=
old
);
for
(
PFP
::
AGENTS
::
iterator
ait
=
oldAgents
.
begin
();
ait
!=
oldAgents
.
end
();
++
ait
)
{
resetAgentInFace
(
*
ait
)
;
pushAgentInCells
(
*
ait
,
(
*
ait
)
->
part_
.
d
)
;
}
if
(
degree
==
3
)
{
Dart
centerFace
=
map
.
phi2
(
map
.
phi1
(
old
));
Dart
d3
=
centerFace
;
unsigned
int
degree
=
0
;
Dart
dd
=
old
;
do
{
Dart
d4
=
map
.
alpha1
(
map
.
alpha1
(
d3
));
while
(
d4
!=
d3
)
++
degree
;
Dart
d3
=
dd
;
do
{
if
(
!
newF
.
isMarked
(
d4
))
neighborAgentvect
[
d3
].
insert
(
neighborAgentvect
[
d3
].
end
(),
agentvect
[
d4
].
begin
(),
agentvect
[
d4
].
end
());
d4
=
map
.
alpha1
(
d4
);
}
d3
=
map
.
phi1
(
d3
);
}
while
(
d3
!=
centerFace
);
Dart
d4
=
map
.
alpha1
(
map
.
alpha1
(
d3
));
while
(
d4
!=
d3
)
{
if
(
!
newF
.
isMarked
(
d4
))
neighborAgentvect
[
d3
].
insert
(
neighborAgentvect
[
d3
].
end
(),
agentvect
[
d4
].
begin
(),
agentvect
[
d4
].
end
());
d4
=
map
.
alpha1
(
d4
);
}
d3
=
map
.
phi1
(
d3
);
}
while
(
d3
!=
dd
);
map
.
setCurrentLevel
(
fLevel
)
;
dd
=
map
.
phi1
(
dd
);
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
}
while
(
dd
!=
old
);
if
(
degree
==
3
)
{
Dart
centerFace
=
map
.
phi2
(
map
.
phi1
(
old
));
Dart
d3
=
centerFace
;
do
{
Dart
d4
=
map
.
alpha1
(
map
.
alpha1
(
d3
));
while
(
d4
!=
d3
)
{
if
(
!
newF
.
isMarked
(
d4
))
neighborAgentvect
[
d3
].
insert
(
neighborAgentvect
[
d3
].
end
(),
agentvect
[
d4
].
begin
(),
agentvect
[
d4
].
end
());
d4
=
map
.
alpha1
(
d4
);
}
d3
=
map
.
phi1
(
d3
);
}
while
(
d3
!=
centerFace
);
}
}
}
}
...
...
src/simulator.cpp
View file @
e5aa38ee
#include "simulator.h"
Simulator
::
Simulator
()
:
globalTime_
(
0.0
f
),
timeStep_
(
0.
0
5
f
)
Simulator
::
Simulator
()
:
globalTime_
(
0.0
f
),
timeStep_
(
0.
2
5
f
)
{
srand
(
10
);
envMap_
.
init
();
std
::
cout
<<
"setup scenario"
<<
std
::
endl
;
//
importAgents("myAgents.pos");
setupScenario
();
importAgents
(
"myAgents.pos"
);
//
setupScenario();
// addPathsToAgents();
for
(
unsigned
int
i
=
0
;
i
<
agents_
.
size
();
++
i
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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