30 virtual VIPRA_GOALS_INIT_STEP = 0;
31 virtual VIPRA_GOALS_UPDATE_STEP = 0;
32 virtual VIPRA_GOALS_NEXT_GOAL = 0;
33 virtual VIPRA_GOALS_CHANGE_GOAL = 0;
34 virtual VIPRA_GOALS_RESET = 0;
39 assert(pedset.num_pedestrians() > 0);
43 VIPRA::size
const pedCnt = pedset.num_pedestrians();
45 _currentGoals.resize(pedCnt);
46 _endGoals.resize(pedCnt);
47 _timeSinceLastGoal = std::vector<VIPRA::f_pnt>(pedCnt, 0);
48 _met = std::vector<bool>(pedCnt,
false);
50 init_step(pedset, map, engine);
52 assert(_timeSinceLastGoal.size() == pedCnt);
53 assert(_currentGoals.size() == pedCnt);
54 assert(_endGoals.size() == pedCnt);
60 VIPRA::delta_t deltaT)
62 assert(pedset.num_pedestrians() > 0);
64 for ( VIPRA::idx pedIdx = 0; pedIdx < pedset.num_pedestrians(); ++pedIdx ) {
65 if ( _met[pedIdx] )
continue;
67 auto const pos = pedset.ped_coords(pedIdx);
68 _timeSinceLastGoal[pedIdx] += deltaT;
70 if ( pos.distance_to(end_goal(pedIdx)) < MIN_GOAL_DIST ) {
74 if ( pos.distance_to(current_goal(pedIdx)) < MIN_GOAL_DIST ) {
75 if ( next_goal(pedIdx, pedset, map, deltaT) ) _met[pedIdx] =
true;
76 _timeSinceLastGoal[pedIdx] = 0.0F;
81 update_step(pedset, map, deltaT);
87 assert(pedIdx < _endGoals.size());
88 set_end_goal(pedIdx, goalPos);
89 set_goal_met(pedIdx,
false);
90 return change_end_goal_impl(pedIdx, currPos, goalPos, engine);
93 [[nodiscard]] VIPRA_INLINE
auto current_goals()
const ->
const VIPRA::f3dVec&
98 [[nodiscard]] VIPRA_INLINE
auto end_goals()
const ->
const VIPRA::f3dVec&
103 [[nodiscard]] VIPRA_INLINE
auto current_goal(VIPRA::idx pedIdx)
const
106 return _currentGoals[pedIdx];
109 [[nodiscard]] VIPRA_INLINE
auto end_goal(VIPRA::idx pedIdx)
const ->
VIPRA::f3d const&
111 return _endGoals[pedIdx];
114 [[nodiscard]] VIPRA_INLINE
auto is_goal_met(VIPRA::idx pedIdx)
const ->
bool
119 [[nodiscard]] VIPRA_INLINE
auto is_sim_goal_met()
const ->
bool
121 return std::all_of(_met.begin(), _met.end(), [](
bool met) { return met; });
124 [[nodiscard]] VIPRA_INLINE
auto time_since_last_goal(VIPRA::idx pedIdx)
const
127 assert(_timeSinceLastGoal.size() > pedIdx);
128 return _timeSinceLastGoal[pedIdx];
132 VIPRA::f3dVec _currentGoals;
133 VIPRA::f3dVec _endGoals;
134 std::vector<VIPRA::f_pnt> _timeSinceLastGoal;
136 std::vector<bool> _met;
138 static constexpr VIPRA::f_pnt MIN_GOAL_DIST = 0.05;
141 VIPRA_INLINE
void set_goal_met(VIPRA::idx pedIdx,
bool met) { _met[pedIdx] = met; }
142 VIPRA_INLINE
void set_end_goal(VIPRA::idx pedIdx,
VIPRA::f3d pos)
144 _endGoals[pedIdx] = pos;
146 VIPRA_INLINE
void set_current_goal(VIPRA::idx pedIdx,
VIPRA::f3d pos)
148 _currentGoals[pedIdx] = pos;
153 Goals(
const Goals&) =
default;
154 Goals(Goals&&)
noexcept =
default;
155 auto operator=(
const Goals&) -> Goals& =
default;
156 auto operator=(Goals&&)
noexcept -> Goals& =
default;
157 virtual ~Goals() =
default;