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
9734ba27
Commit
9734ba27
authored
May 30, 2013
by
pitiot
Browse files
up
parent
af8747b0
Changes
6
Hide whitespace changes
Inline
Side-by-side
include/env_generator.hpp
View file @
9734ba27
...
...
@@ -485,8 +485,9 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoofSmall
,
buildingMark
,
height
/
2.0
f
)
;
}
bool
spike
=
rand
()
%
2
;
#ifndef TWO_AND_HALF_DIM
bool
spike
=
rand
()
%
2
;
if
(
spike
)
{
typename
PFP
::
VEC3
c
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
...
...
include/env_map.h
View file @
9734ba27
...
...
@@ -32,7 +32,7 @@ class ArticulatedObstacle;
#include
"pfp.h"
//
#define EXPORTING3
#define EXPORTING3
#define TWO_AND_HALF_DIM
...
...
@@ -131,7 +131,7 @@ public:
void
pushObstNeighborInCells
(
Obstacle
*
o
,
Dart
d
);
void
popObstNeighborInCells
(
Obstacle
*
o
,
Dart
d
);
void
find_next
(
Obstacle
*
o
,
Dart
*
d
,
CellMarkerMemo
<
FACE
>&
cms
);
bool
movingObstacleFree
(
Dart
d
);
#ifdef EXPORTING3
std
::
vector
<
PFP
::
MAP
*>
m_map_Export
;
std
::
vector
<
Algo
::
Surface
::
Import
::
OBJModel
<
PFP2
>
*>
m_obj_Export
;
...
...
include/simulator.h
View file @
9734ba27
...
...
@@ -98,9 +98,9 @@ public:
void
setupCityScenario
(
int
nbLines
,
int
nbRank
)
;
void
setupScenario
(
unsigned
int
nbMaxAgent
,
bool
pedWay
=
false
)
;
void
setupPlanetScenario
(
unsigned
int
nbAgents
,
unsigned
int
nbObstacles
);
void
setupPlanetScenario
(
unsigned
int
nbAgents
,
unsigned
int
nbObstacles
,
unsigned
int
nbx
=
2
,
unsigned
int
nby
=
2
,
float
areaMin
=
100.0
f
);
void
addMovingObstacles
(
unsigned
int
nb
,
unsigned
int
type
,
float
areaMin
=
1400
);
void
addMovingObstacles
(
unsigned
int
nb
,
unsigned
int
type
,
float
areaMin
=
1400
,
int
randLimace
=
12
);
void
addMovingObstacle
(
Dart
d
,
unsigned
int
obstType
=
0
);
void
addAgent
(
const
VEC3
&
start
,
const
VEC3
&
goals
);
...
...
src/env_map.cpp
View file @
9734ba27
...
...
@@ -1503,6 +1503,27 @@ int EnvMap::testOrientation(VEC3 p, VEC3 p1, VEC3 p2, Dart d)
}
bool
EnvMap
::
movingObstacleFree
(
Dart
d
)
{
std
::
vector
<
Obstacle
*>&
obst
=
obstvect
[
d
];
for
(
std
::
vector
<
Obstacle
*>::
const_iterator
it
=
obst
.
begin
()
;
it
!=
obst
.
end
()
;
++
it
)
{
if
((
*
it
)
->
mo
!=
NULL
)
{
return
false
;
}
}
return
true
;
}
#ifdef SPATIAL_HASHING
Geom
::
Vec2ui
EnvMap
::
agentPositionCell
(
Agent
*
a
)
{
...
...
src/moving_obstacle.cpp
View file @
9734ba27
...
...
@@ -175,13 +175,17 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
edgeLength
=
map
.
addAttribute
<
float
,
EDGE
>
(
"edgeLength"
)
;
vertexAngle
=
map
.
addAttribute
<
float
,
DART
>
(
"vertexAngle"
)
;
}
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
center
+=
pos
[
i
];
}
center
/=
nbVertices
;
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
#ifdef TWO_AND_HALF_DIM
Dart
d
=
dInside
;
parts_
[
i
]
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2DAndHalf
<
PFP
>
(
sim_
->
envMap_
.
map
,
d
,
pos
[
i
]
,
sim_
->
envMap_
.
position
);
parts_
[
i
]
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2DAndHalf
<
PFP
>
(
sim_
->
envMap_
.
map
,
d
,
center
,
sim_
->
envMap_
.
position
);
parts_
[
i
]
->
move
(
pos
[
i
]);
#else
Dart
d
=
sim_
->
envMap_
.
getBelongingCell
(
pos
[
i
]);
#ifdef SECURED
...
...
@@ -191,15 +195,15 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
parts_
[
i
]
=
new
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
ParticleCell2D
<
PFP
>
(
sim_
->
envMap_
.
map
,
d
,
pos
[
i
],
sim_
->
envMap_
.
position
);
#endif
#endif
center
+=
pos
[
i
];
if
(
i
==
0
)
dDir
=
d
;
}
center
/=
nbVertices
;
front
=
(
pos
[
0
]
+
pos
[
1
])
/
2
;
front
=
(
parts_
[
0
]
->
getPosition
()
+
parts_
[
1
]
->
getPosition
())
/
2
;
if
(
!
rigid_
)
{
#ifdef TWO_AND_HALF_DIM
...
...
src/simulator.cpp
View file @
9734ba27
...
...
@@ -91,35 +91,34 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case
6
:
envMap_
.
init
(
config
,
200.0
,
200.0
,
minSize
,
400.0
f
);
setupPlanetScenario
(
nbAgent
,
nbObst
);
addMovingObstacles
(
nbObst
,
1
);
setupPlanetScenario
(
nbAgent
,
nbObst
);
addPathToObstacles
(
envMap_
.
buildingMark
,
true
);
addPathsToAgents
();
break
;
case
7
:
envMap_
.
init
(
config
,
200.0
,
200.0
,
minSize
,
400.0
f
);
setupPlanetScenario
(
nbAgent
,
nbObst
);
addMovingObstacles
(
nbObst
,
1
,
1
00
);
addMovingObstacles
(
nbObst
,
1
,
300
,
3
);
setupPlanetScenario
(
nbAgent
,
nbObst
,
1
,
1
);
addPathToObstacles
(
envMap_
.
buildingMark
,
true
);
addPathsToAgents
();
break
;
case
8
:
envMap_
.
init
(
config
,
200.0
,
200.0
,
minSize
,
400.0
f
);
setupPlanetScenario
(
nbAgent
,
nbObst
);
addMovingObstacles
(
nbObst
,
1
,
100
);
addMovingObstacles
(
nbObst
,
1
,
100
,
1
);
setupPlanetScenario
(
nbAgent
,
nbObst
,
1
,
1
);
addPathToObstacles
(
envMap_
.
buildingMark
,
true
);
addPathsToAgents
();
break
;
case
9
:
envMap_
.
init
(
config
,
200.0
,
200.0
,
minSize
,
400.0
f
);
addMovingObstacles
(
nbObst
,
1
,
400
,
1
);
setupPlanetScenario
(
nbAgent
,
nbObst
);
addMovingObstacles
(
nbObst
,
1
,
100
);
addPathToObstacles
(
envMap_
.
buildingMark
,
true
);
addPathsToAgents
();
break
;
#else
std
::
cout
<<
"Agents not in 2.5D mode"
<<
std
::
endl
;
#endif
default:
std
::
cout
<<
"Unknown scenario !"
<<
std
::
endl
;
std
::
cout
<<
"Unknown scenario !
or not in 2.5D mode
"
<<
std
::
endl
;
exit
(
1
)
;
}
...
...
@@ -752,7 +751,7 @@ void Simulator::setupScenario(unsigned int nbMaxAgent, bool pedWay)
swapAgentsGoals
()
;
}
void
Simulator
::
setupPlanetScenario
(
unsigned
int
nbAgents
,
unsigned
int
nbObstacles
)
void
Simulator
::
setupPlanetScenario
(
unsigned
int
nbAgents
,
unsigned
int
nbObstacles
,
unsigned
int
nbx
,
unsigned
int
nby
,
float
areaMin
)
{
/*
* Add agents, specifying their start position, and store their goals on the
...
...
@@ -774,8 +773,6 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
d
=
envMap_
.
map
.
begin
();
CellMarker
<
FACE
>
filled
(
envMap_
.
map
);
unsigned
int
nbx
=
1
;
unsigned
int
nby
=
1
;
unsigned
int
bMax
=
nbx
*
nby
>
0
?
nbAgents
/
(
nbx
*
nby
)
:
nbAgents
;
...
...
@@ -786,7 +783,8 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
Dart
dCell
;
while
(
!
found
&&
d
!=
envMap_
.
map
.
end
())
{
if
(
!
filled
.
isMarked
(
d
)
&&
!
envMap_
.
buildingMark
.
isMarked
(
d
))
float
area
=
Algo
::
Surface
::
Geometry
::
convexFaceArea
<
PFP
>
(
envMap_
.
map
,
d
,
envMap_
.
position
);
if
(
!
filled
.
isMarked
(
d
)
&&
!
envMap_
.
buildingMark
.
isMarked
(
d
)
&&
envMap_
.
movingObstacleFree
(
d
)
&&
area
>
areaMin
)
{
filled
.
mark
(
d
);
pos
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
envMap_
.
map
,
d
,
envMap_
.
position
);
...
...
@@ -825,7 +823,7 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
swapAgentsGoals
();
}
void
Simulator
::
addMovingObstacles
(
unsigned
int
nb
,
unsigned
int
type
,
float
areaMin
)
void
Simulator
::
addMovingObstacles
(
unsigned
int
nb
,
unsigned
int
type
,
float
areaMin
,
int
randLimace
)
{
TraversorF
<
PFP
::
MAP
>
tF
(
envMap_
.
map
);
Dart
d
=
tF
.
begin
()
;
...
...
@@ -836,11 +834,11 @@ void Simulator::addMovingObstacles(unsigned int nb, unsigned int type, float are
while
(
!
found
&&
d
!=
tF
.
end
())
{
if
(
!
envMap_
.
buildingMark
.
isMarked
(
d
)
&&
!
envMap_
.
pedWayMark
.
isMarked
(
d
)
&&
!
envMap_
.
pedWayMark
.
isMarked
(
d
)
&&
envMap_
.
obstvect
[
d
].
size
()
==
0
)
{
float
area
=
Algo
::
Surface
::
Geometry
::
convexFaceArea
<
PFP
>
(
envMap_
.
map
,
d
,
envMap_
.
position
);
if
(
area
>
areaMin
)
if
(
area
>
areaMin
&&
(
rand
()
%
randLimace
==
0
)
)
{
dCell
=
d
;
found
=
true
;
...
...
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