-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSocialForce.cpp
More file actions
45 lines (34 loc) · 887 Bytes
/
SocialForce.cpp
File metadata and controls
45 lines (34 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "SocialForce.h"
using namespace std;
SocialForce::~SocialForce() {
removeCrowd();
removeWalls();
}
void SocialForce::addAgent(Agent *agent) {
crowd.push_back(agent);
}
void SocialForce::addWall(Wall *wall) {
walls.push_back(wall);
}
void SocialForce::removeAgent() {
int lastIdx;
if (!crowd.empty()) {
lastIdx = crowd.size() - 1; // Assign index of last element
delete crowd[lastIdx];
crowd.pop_back();
}
}
void SocialForce::removeCrowd() {
for (unsigned int idx = 0; idx < crowd.size(); idx++)
delete crowd[idx];
crowd.clear();
}
void SocialForce::removeWalls() {
for (unsigned int idx = 0; idx < walls.size(); idx++)
delete walls[idx];
walls.clear();
}
void SocialForce::moveCrowd(float stepTime) {
for (unsigned int idx = 0; idx < crowd.size(); idx++)
crowd[idx]->move(crowd, walls, stepTime);
}