-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsim_with_viewer.cpp
46 lines (37 loc) · 1.01 KB
/
sim_with_viewer.cpp
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
#include <mutex>
#include <thread>
#include <cmath>
extern "C"
{
#include "vmath.h"
#include "mmath.h"
#include "qmath.h"
}
#include "physics_sim.hpp"
#include "sim_viewer.hpp"
int main()
{
std::mutex rbody_mutex;
std::mutex appl_mom_mutex;
const vec3 axis_rot = {1, 0, 0};
const quat rot_init = quat_from_axis(&axis_rot, 45.0 / 180 * M_PI);
Rigidbody rbody = (Rigidbody){
.attit = rot_init,
.ang_vel = vec3_init(0, 1, 1),
.iner_tensor = {
{1, 0, 0},
{0, 1, 0},
{0, 0, 1}}};
vec3 appl_mom = vec3_init(0, 0, 0);
PhysicsSimProperties sim_properties = {
.rbody = rbody,
.appl_mom = appl_mom,
.rbody_mutex = rbody_mutex,
.appl_mom_mutex = appl_mom_mutex,
.running = true};
std::thread thread_physics(PhysicsPipeline, &sim_properties, 0.01);
std::thread thread_render(RenderPipeline, &sim_properties, 1.0f / 60);
thread_physics.join();
thread_render.join();
return EXIT_SUCCESS;
}