Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SocialAgents3D
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
0fcc8b63
Commit
0fcc8b63
authored
Mar 28, 2013
by
Thomas Jund
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plus d'info a l affichage, un peu de debug pour 2.5
parent
0a2ddaee
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
25 deletions
+89
-25
include/env_map.h
include/env_map.h
+1
-0
include/simulator.h
include/simulator.h
+1
-1
include/viewer.h
include/viewer.h
+3
-0
src/env_map.cpp
src/env_map.cpp
+24
-2
src/moving_obstacle.cpp
src/moving_obstacle.cpp
+16
-2
src/simulator.cpp
src/simulator.cpp
+28
-10
src/viewer.cpp
src/viewer.cpp
+16
-10
No files found.
include/env_map.h
View file @
0fcc8b63
...
...
@@ -73,6 +73,7 @@ public:
#ifndef SPATIAL_HASHING
Dart
getBelongingCell
(
const
VEC3
&
pos
)
;
Dart
getBelongingCellOnSurface
(
const
VEC3
&
pos
)
;
void
subdivideAllToMaxLevel
()
;
void
subdivideToProperLevel
()
;
...
...
include/simulator.h
View file @
0fcc8b63
...
...
@@ -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
);
...
...
include/viewer.h
View file @
0fcc8b63
...
...
@@ -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
);
}
}
}
...
...
src/env_map.cpp
View file @
0fcc8b63
...
...
@@ -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
...
...
src/moving_obstacle.cpp
View file @
0fcc8b63
...
...
@@ -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;
...
...
src/simulator.cpp
View file @
0fcc8b63
...
...
@@ -52,7 +52,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case
3
:
envMap_
.
init
(
config
,
1000.0
f
,
1000.0
f
,
minSize
,
100.0
f
)
;
//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.0
f
,
1200.0
f
,
minSize
,
400.0
f
)
;
//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.0
f
);
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.0
f
,
5.0
f
,
0.0
f
);
#ifdef TWO_AND_HALF_DIM
Geom
::
Plane3D
<
PFP
::
REAL
>
pl
(
Algo
::
Surface
::
Geometry
::
faceNormal
<
PFP
>
(
envMap_
.
map
,
d
,
envMap_
.
position
),
0.0
f
);
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
);
...
...
src/viewer.cpp
View file @
0fcc8b63
...
...
@@ -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];
...
...
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