-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (46 loc) · 1.46 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (46 loc) · 1.46 KB
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
46
47
48
49
50
51
52
/* *
* @project nbodies
* @file main.cpp
*
* @author Braden Nicholson
* @date 3/8/21, 5/18/22
*/
#include "simulation.h"
#include <algorithm>
int main(int argc, char **argv) {
// Run in headless mode if arguments are specified
if (argc >= 5) {
char *c;
int maxTicks = (int) strtol(argv[1], &c, 10);
float step = strtof(argv[2], &c);
int mode = (int) strtol(argv[3], &c, 10);
int threads = (int) strtol(argv[4], &c, 10);
// Define the simulation parameters
auto s = Settings{
.maxTicks = maxTicks,
.useParallel = (mode == 1),
.useCollisions = false,
.realtime = false,
.targetFps = 0,
.numThreads = threads,
.maxThreads = threads,
.radius = 1024,
.scale = 1,
.stepSize = step,
.showControls = false,
.rotP = 0,
.rotY = 0,
};
// Initialize a simulation with the provided settings
auto simulation = new Simulation(&s);
// Run the simulation
simulation->runHeadless();
} else {
printf("./nbodies or ./nbodies <maxTicks> <tickSize> <useParallel (1 or 0)> <numThreads (-1 for all)>\n");
// Initialize the simulation with the default values
auto simulation = new Simulation();
// Run windowed
simulation->run();
}
return 0;
}