summaryrefslogtreecommitdiff
path: root/src/systems/physics.h
blob: 7239ab531e8fda4bdad3b4800438093ff72d4013 (plain)
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
#pragma once

#include "geometry.h"
#include "maths_types.h"

// 'system' means that it gets called per frame

typedef struct physics_settings {
  f32 gravity_strength;
} physics_settings;

enum collider_type {
  cuboid_collider,
  sphere_collider,
};

/** @brief generic collider structure */
typedef struct physics_collider {
  u64 id;  // ? Replace with handle?
  enum collider_type shape;
  union collider_data {
    cuboid cuboid;
    sphere sphere;
  } geometry;
  transform transform;
  u8 layer;
  bool on_ground;
} physics_collider;

// What else do I need?
// intersection methods

typedef struct physics_world {
  physics_settings settings;
} physics_world;

physics_world physics_init(physics_settings settings);
void physics_shutdown(physics_world* phys_world);

/** @brief perform one or more simulation steps */
void physics_system_update(physics_world* phys_world, f64 deltatime);