Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OCSR
UMANS
Commits
479d9390
Commit
479d9390
authored
Apr 07, 2020
by
VAN TOLL Wouter
Browse files
WorldBase/Infinite/Toric: Fixed a crash when trying to find neighbors without a KD tree.
parent
42a62237
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Engine/core/worldBase.h
View file @
479d9390
...
...
@@ -81,9 +81,6 @@ private:
/// <summary>A list of agents (sorted by time) that will be added to the simulation in the future.</summary>
AgentQueue
agentsToAdd
;
/// <summary>A kd-tree of agent positions, used for nearest-neighbor queries.</summary>
AgentKDTree
*
agentKDTree
;
/// <summary>A mapping from agent IDs to positions in the agents_ list.</summary>
/// <remarks>Because agents can be removed during the simulation, the ID of an agent is not necessarily the same
/// as its position in the list. This is why we need this extra administration.
...
...
@@ -103,6 +100,9 @@ protected:
/// <summary>A list containing all agents that are currently in the crowd.</summary>
std
::
vector
<
Agent
*>
agents_
;
/// <summary>A kd-tree of agent positions, used for nearest-neighbor queries.</summary>
AgentKDTree
*
agentKDTree
;
/// <summary>The length (in seconds) of a simulation step.</summary>
float
delta_time_
;
...
...
src/Engine/core/worldInfinite.cpp
View file @
479d9390
...
...
@@ -30,10 +30,14 @@ WorldInfinite::WorldInfinite() : WorldBase(INFINITE_WORLD)
NeighborList
WorldInfinite
::
ComputeNeighbors
(
const
Vector2D
&
position
,
float
search_radius
,
const
Agent
*
queryingAgent
)
const
{
const
auto
&
agents
=
computeNeighboringAgents_Flat
(
position
,
search_radius
,
queryingAgent
);
vector
<
PhantomAgent
>
phantoms
;
for
(
const
Agent
*
agent
:
agents
)
phantoms
.
push_back
(
PhantomAgent
(
agent
->
getPosition
(),
agent
->
getVelocity
(),
agent
));
vector
<
PhantomAgent
>
phantoms
;
if
(
agentKDTree
!=
nullptr
)
{
const
auto
&
agents
=
computeNeighboringAgents_Flat
(
position
,
search_radius
,
queryingAgent
);
for
(
const
Agent
*
agent
:
agents
)
phantoms
.
push_back
(
PhantomAgent
(
agent
->
getPosition
(),
agent
->
getVelocity
(),
agent
));
}
return
{
phantoms
,
computeNeighboringObstacles_Flat
(
position
,
search_radius
)
};
}
...
...
src/Engine/core/worldToric.cpp
View file @
479d9390
...
...
@@ -32,10 +32,13 @@ WorldToric::WorldToric(float width, float height)
void
WorldToric
::
computeNeighbors_Displaced
(
const
Vector2D
&
position
,
const
Vector2D
&
displacement
,
float
search_radius
,
const
Agent
*
queryingAgent
,
NeighborList
&
result
)
const
{
// agents
const
auto
&
agents
=
computeNeighboringAgents_Flat
(
position
+
displacement
,
search_radius
,
queryingAgent
);
for
(
const
Agent
*
agent
:
agents
)
result
.
first
.
push_back
(
PhantomAgent
(
agent
->
getPosition
()
-
displacement
,
agent
->
getVelocity
(),
agent
));
if
(
agentKDTree
!=
nullptr
)
{
// agents
const
auto
&
agents
=
computeNeighboringAgents_Flat
(
position
+
displacement
,
search_radius
,
queryingAgent
);
for
(
const
Agent
*
agent
:
agents
)
result
.
first
.
push_back
(
PhantomAgent
(
agent
->
getPosition
()
-
displacement
,
agent
->
getVelocity
(),
agent
));
}
// obstacles
const
auto
&
obstacles
=
computeNeighboringObstacles_Flat
(
position
+
displacement
,
search_radius
);
...
...
Write
Preview
Supports
Markdown
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