Skip to content

Commit 7d4fd18

Browse files
committed
Tidying up
1 parent cd73d78 commit 7d4fd18

20 files changed

+126
-108
lines changed

external/Actor.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
*
2121
* Description:
2222
* Class denoting an actor in social force model
23-
*
23+
*
2424
**************************************************************************/
2525

2626
#include "Actor.hpp"
2727

28-
Actor::Actor(sycl::float2 pPos, sycl::float2 pVelocity, float pDesiredSpeed, int pPathId,
29-
float pMass, float pRadius, bool pAtDestination,
28+
Actor::Actor(sycl::float2 pPos, sycl::float2 pVelocity, float pDesiredSpeed,
29+
int pPathId, float pMass, float pRadius, bool pAtDestination,
3030
std::array<int, 3> pColor)
3131
: pos(pPos), velocity(pVelocity), desiredSpeed(pDesiredSpeed),
3232
pathId(pPathId), mass(pMass), radius(pRadius),
33-
atDestination(pAtDestination), color(pColor),
34-
destinationIndex(0), bBox({0, 0}) {}
33+
atDestination(pAtDestination), color(pColor), destinationIndex(0),
34+
bBox({0, 0}) {}
3535

3636
SYCL_EXTERNAL sycl::float2 Actor::getPos() const { return pos; }
3737

@@ -85,8 +85,9 @@ SYCL_EXTERNAL void Actor::setSeed(uint newSeed) { seed = newSeed; }
8585

8686
SYCL_EXTERNAL void Actor::setForce(float newForce) { force = newForce; }
8787

88-
SYCL_EXTERNAL void Actor::checkAtDestination(std::array<sycl::float2, 2> destination,
89-
int pathSize) {
88+
SYCL_EXTERNAL void
89+
Actor::checkAtDestination(std::array<sycl::float2, 2> destination,
90+
int pathSize) {
9091
// Destinations are defined as rectangular regions
9192
if (pos[0] >= destination[0][0] && pos[0] <= destination[1][0] &&
9293
pos[1] >= destination[0][1] && pos[1] <= destination[1][1]) {

external/Actor.hpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* Description:
2222
* Class denoting an actor in social force model
23-
*
23+
*
2424
**************************************************************************/
2525

2626
#ifndef Actor_hpp
@@ -36,22 +36,22 @@
3636

3737
class Actor {
3838
private:
39-
std::array<int, 3> color; // 12 bytes
40-
sycl::float2 pos; // 8 bytes
41-
sycl::float2 velocity; // 8 bytes
42-
std::array<int, 2> bBox; // 8 bytes
43-
float desiredSpeed; // 4 bytes
44-
int pathId; // 4 bytes
45-
int destinationIndex; // 4 bytes
46-
float mass; // 4 bytes
47-
float radius; // 4 bytes
48-
uint seed; // 4 bytes
49-
float force; // 4 bytes
50-
bool atDestination; // 1 byte
39+
std::array<int, 3> color;
40+
sycl::float2 pos;
41+
sycl::float2 velocity;
42+
std::array<int, 2> bBox;
43+
float desiredSpeed;
44+
int pathId;
45+
int destinationIndex;
46+
float mass;
47+
float radius;
48+
uint seed;
49+
float force;
50+
bool atDestination;
5151

5252
public:
53-
Actor(sycl::float2 pPos, sycl::float2 pVelocity, float pdesiredSpeed, int pPathId,
54-
float pMass, float pRadius, bool pAtDestination,
53+
Actor(sycl::float2 pPos, sycl::float2 pVelocity, float pdesiredSpeed,
54+
int pPathId, float pMass, float pRadius, bool pAtDestination,
5555
std::array<int, 3> pColor);
5656

5757
SYCL_EXTERNAL sycl::float2 getPos() const;
@@ -76,8 +76,8 @@ class Actor {
7676
SYCL_EXTERNAL void setSeed(uint newSeed);
7777
SYCL_EXTERNAL void setForce(float newForce);
7878

79-
SYCL_EXTERNAL void checkAtDestination(std::array<sycl::float2, 2> destination,
80-
int pathSize);
79+
SYCL_EXTERNAL void
80+
checkAtDestination(std::array<sycl::float2, 2> destination, int pathSize);
8181
};
8282

8383
#endif

external/DifferentialEq.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
*
2121
* Description:
2222
* Kernel for calculating social forces
23-
*
23+
*
2424
**************************************************************************/
2525

2626
#include "DifferentialEq.hpp"
2727

2828
SYCL_EXTERNAL void differentialEq(
2929
int actorIndex,
3030
sycl::accessor<Actor, 1, sycl::access::mode::read_write> actors,
31-
sycl::accessor<std::array<sycl::float2, 2>, 1, sycl::access::mode::read> walls,
32-
sycl::accessor<Path, 1, sycl::access::mode::read> paths,
31+
sycl::accessor<std::array<sycl::float2, 2>, 1, sycl::access::mode::read>
32+
walls,
33+
sycl::accessor<Path, 1, sycl::access::mode::read> paths,
3334
sycl::accessor<bool, 1, sycl::access::mode::read> heatmapEnabled) {
3435
Actor *currentActor = &actors[actorIndex];
3536

@@ -60,7 +61,8 @@ SYCL_EXTERNAL void differentialEq(
6061
}
6162
}
6263
minRegionDistance.second = normalize(minRegionDistance.second);
63-
sycl::float2 e0i = {-minRegionDistance.second[0], -minRegionDistance.second[1]};
64+
sycl::float2 e0i = {-minRegionDistance.second[0],
65+
-minRegionDistance.second[1]};
6466

6567
sycl::float2 vi = currentActor->getVelocity();
6668

@@ -113,7 +115,8 @@ SYCL_EXTERNAL void differentialEq(
113115
for (int x = 0; x < walls.size(); x++) {
114116
std::array<sycl::float2, 2> currentWall = walls[x];
115117
float ri = currentActor->getRadius();
116-
std::pair<float, sycl::float2> dAndn = getDistanceAndNiw(pos, currentWall);
118+
std::pair<float, sycl::float2> dAndn =
119+
getDistanceAndNiw(pos, currentWall);
117120
float diw = dAndn.first;
118121
float g = diw > ri ? 0 : ri - diw;
119122
sycl::float2 niw = normalize(dAndn.second);

external/DifferentialEq.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* Description:
2222
* Kernel for calculating social forces
23-
*
23+
*
2424
**************************************************************************/
2525

2626
#ifndef DifferentialEqu_hpp
@@ -54,7 +54,8 @@ constexpr float TIMESTEP = 0.001;
5454
SYCL_EXTERNAL void differentialEq(
5555
int actorIndex,
5656
sycl::accessor<Actor, 1, sycl::access::mode::read_write> actors,
57-
sycl::accessor<std::array<sycl::float2, 2>, 1, sycl::access::mode::read> walls,
57+
sycl::accessor<std::array<sycl::float2, 2>, 1, sycl::access::mode::read>
58+
walls,
5859
sycl::accessor<Path, 1, sycl::access::mode::read> paths,
5960
sycl::accessor<bool, 1, sycl::access::mode::read> heatmapEnabled);
6061

external/Heatmap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Description:
2222
* Applying heatmap across actors reflecting how much force they are
2323
* experiencing
24-
*
24+
*
2525
**************************************************************************/
2626

2727
#include "Heatmap.hpp"

external/Heatmap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Description:
2222
* Applying heatmap across actors reflecting how much force they are
2323
* experiencing
24-
*
24+
*
2525
**************************************************************************/
2626

2727
#ifndef Heatmap_hpp

external/MathHelper.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,25 @@
1919
* MathHelper.cpp
2020
*
2121
* Description:
22-
* Collection of helper functions performing common vector math
22+
* Collection of helper functions performing common vector math
2323
* operations
24-
*
24+
*
2525
**************************************************************************/
2626

2727
#include "MathHelper.hpp"
2828

29-
SYCL_EXTERNAL sycl::float2 getDirectionVector(sycl::float2 from, sycl::float2 to) {
29+
SYCL_EXTERNAL sycl::float2 getDirectionVector(sycl::float2 from,
30+
sycl::float2 to) {
3031
return to - from;
3132
}
3233

33-
SYCL_EXTERNAL sycl::float2 velFromSpeedAndDir(float speed, sycl::float2 direction) {
34+
SYCL_EXTERNAL sycl::float2 velFromSpeedAndDir(float speed,
35+
sycl::float2 direction) {
3436
return direction * (speed * inverseMagnitude(direction));
3537
}
3638

3739
SYCL_EXTERNAL sycl::float2 velToPoint(float speed, sycl::float2 pos,
38-
sycl::float2 destination) {
40+
sycl::float2 destination) {
3941
return velFromSpeedAndDir(speed, getDirectionVector(pos, destination));
4042
}
4143

external/MathHelper.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
* MathHelper.hpp
2020
*
2121
* Description:
22-
* Collection of helper functions performing common vector math
22+
* Collection of helper functions performing common vector math
2323
* operations
24-
*
24+
*
2525
**************************************************************************/
2626

2727
#ifndef MathHelper_hpp
@@ -33,9 +33,11 @@
3333

3434
SYCL_EXTERNAL sycl::float2 getDirectionVector(sycl::float2 a, sycl::float2 b);
3535

36-
SYCL_EXTERNAL sycl::float2 velFromSpeedAndDir(float speed, sycl::float2 direction);
36+
SYCL_EXTERNAL sycl::float2 velFromSpeedAndDir(float speed,
37+
sycl::float2 direction);
3738

38-
SYCL_EXTERNAL sycl::float2 velToPoint(float speed, sycl::float2 pos, sycl::float2 destination);
39+
SYCL_EXTERNAL sycl::float2 velToPoint(float speed, sycl::float2 pos,
40+
sycl::float2 destination);
3941

4042
SYCL_EXTERNAL float magnitude(sycl::float2 inp);
4143

external/ParseInputFile.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* Description:
2222
* Parse input JSON file and load configuration into simulation
23-
*
23+
*
2424
**************************************************************************/
2525

2626
#include "ParseInputFile.hpp"
@@ -42,8 +42,8 @@ void validateParameters(rapidjson::Document &jsonDoc) {
4242
throw JSONException("Missing these parameters: " + missingParameters);
4343
} else {
4444
auto &config = jsonDoc["config"];
45-
auto configParams = {"width", "height", "scale",
46-
"delay", "wallColor", "bgColor", "heatmapEnabled"};
45+
auto configParams = {"width", "height", "scale", "delay",
46+
"wallColor", "bgColor", "heatmapEnabled"};
4747
for (auto p : configParams) {
4848
if (!config.HasMember(p))
4949
missingParameters += std::string(p) + " ";
@@ -52,9 +52,8 @@ void validateParameters(rapidjson::Document &jsonDoc) {
5252
if (!jsonDoc["room"].HasMember("walls"))
5353
missingParameters += "walls ";
5454

55-
auto actorParams = {"pos", "velocity", "desiredSpeed",
56-
"pathId", "mass", "radius",
57-
"atDestination", "color"};
55+
auto actorParams = {"pos", "velocity", "desiredSpeed", "pathId",
56+
"mass", "radius", "atDestination", "color"};
5857
for (auto &a : jsonDoc["actors"].GetArray()) {
5958
for (auto p : actorParams) {
6059
if (!a.HasMember(p))
@@ -79,8 +78,8 @@ void validateParameters(rapidjson::Document &jsonDoc) {
7978
void parseInputFile(std::string filename, std::vector<Actor> &actors,
8079
Room &room, std::vector<Path> &paths, int &WIDTH,
8180
int &HEIGHT, int &SCALE, int &DELAY,
82-
std::array<int, 3> &BGCOLOR,
83-
std::array<int, 3> &WALLCOLOR, bool &HEATMAPENABLED) {
81+
std::array<int, 3> &BGCOLOR, std::array<int, 3> &WALLCOLOR,
82+
bool &HEATMAPENABLED) {
8483
std::ifstream jsonFile(filename);
8584
if (!jsonFile.is_open()) {
8685
throw JSONException("Error opening file " + filename);
@@ -130,9 +129,9 @@ void parseInputFile(std::string filename, std::vector<Actor> &actors,
130129
for (int i = 0; i < jsonCheckpoints.Size(); i++) {
131130
std::array<sycl::float2, 2> region;
132131
region[0] = sycl::float2({jsonCheckpoints[i][0][0].GetFloat(),
133-
jsonCheckpoints[i][0][1].GetFloat()});
132+
jsonCheckpoints[i][0][1].GetFloat()});
134133
region[1] = sycl::float2({jsonCheckpoints[i][1][0].GetFloat(),
135-
jsonCheckpoints[i][1][1].GetFloat()});
134+
jsonCheckpoints[i][1][1].GetFloat()});
136135
checkpoints[i] = region;
137136
}
138137
int pathSize = jsonCheckpoints.Size();
@@ -144,7 +143,7 @@ void parseInputFile(std::string filename, std::vector<Actor> &actors,
144143
for (auto &a : jsonActors) {
145144
sycl::float2 pos = {a["pos"][0].GetFloat(), a["pos"][1].GetFloat()};
146145
sycl::float2 velocity = {a["velocity"][0].GetFloat(),
147-
a["velocity"][1].GetFloat()};
146+
a["velocity"][1].GetFloat()};
148147
float desiredSpeed = a["desiredSpeed"].GetFloat();
149148
int pathId = a["pathId"].GetInt();
150149
int pathSize = paths[pathId].getPathSize();

external/ParseInputFile.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* Description:
2222
* Parse input JSON file and load configuration into simulation
23-
*
23+
*
2424
**************************************************************************/
2525

2626
#ifndef ParseInputFile_hpp
@@ -49,6 +49,7 @@ void validateParameters(rapidjson::Document &jsonDoc);
4949
void parseInputFile(std::string filename, std::vector<Actor> &actors,
5050
Room &room, std::vector<Path> &paths, int &WIDTH,
5151
int &HEIGHT, int &SCALE, int &DELAY,
52-
std::array<int, 3> &BGCOLOR, std::array<int, 3> &WALLCOLOR, bool &HEATMAPENABLED);
52+
std::array<int, 3> &BGCOLOR, std::array<int, 3> &WALLCOLOR,
53+
bool &HEATMAPENABLED);
5354

5455
#endif

0 commit comments

Comments
 (0)