forked from PrototypeX29A/norbit
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_physics.cpp
More file actions
58 lines (44 loc) · 1023 Bytes
/
test_physics.cpp
File metadata and controls
58 lines (44 loc) · 1023 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
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <assert.h>
#include <stdio.h>
#include "physics.h"
simulation_world World;
float
GetTime ()
{
static float t = 0.0f;
printf ("%0.4f ", t);
return t++;
}
void
RunS (void)
{
static real LastTime = GetTime ();
// use a fixed timestep until we implement a better integrator
// real Time = GetTime();
real Time = LastTime + r (0.02);
printf ("time %0.4f %0.4f\n", Time, LastTime);
World.Simulate (Time - LastTime);
printf ("after simulate:\n");
World.Render ();
printf ("----------------------------------\n");
LastTime = Time;
return;
}
int
main (int argc, char **argv)
{
// initialize bodies
real const Density = r (0.01);
World.add_body (100.0f);
World.add_body (100.0f);
World.add_body (100.0f);
World.aBodies.at (0)->aConfigurations[0].CMVelocity =
vector_2 (r (0.40), r (0.10));
World.aBodies.at (2)->aConfigurations[0].AngularVelocity = r (PI);
for (int i = 0; i < 1000; i++)
{
printf ("run %d\n", i);
::RunS ();
}
return 0;
}