-
Notifications
You must be signed in to change notification settings - Fork 0
/
physics.odin
73 lines (61 loc) · 1.53 KB
/
physics.odin
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package zephr
import m "core:math/linalg/glsl"
// TODO: I can't into physics. Be into physics
PhysicsBody :: union {
StaticBody,
RigidBody,
}
StaticBody :: struct {
}
RigidBody :: struct {
velocity: m.vec3,
//mass: f32,
//force: m.vec3,
}
Entity :: struct {
physics_body: PhysicsBody,
position: m.vec3,
rotation: m.quat,
rotation_euler: m.vec3,
scale: m.vec3,
model: Model,
// TODO: this is garbage I think
type: union {
Player,
},
collision_shape: CollisionShape,
}
CollisionShape :: union {
OBB,
//Sphere,
//Capsule,
//Cylinder,
//Cone,
//ConvexHull,
Mesh,
}
// TODO: Most of this stuff should probably be done by the game instead of the engine since it's so game-specific.
// But I'm conflicted because I feel like it can be reused between multiple games (although with slight differences maybe)
// which is why it initially landed in the engine, maybe an effort to generalize and abstract this would be good, if not, just move
// to the game code.
// ?? idk. I've never programmed a game before lol
EntityType :: enum {
ENVIRONMENT,
PLAYER,
}
PlayerAnimationState :: enum {
IDLE,
WALK,
RUN,
}
Player :: struct {
forward: m.vec3,
animation_state: PlayerAnimationState,
}
entity_transform :: proc(entity: Entity) -> m.mat4 {
mat := m.identity(m.mat4)
mat = m.mat4Scale(entity.scale) * mat
mat = m.mat4FromQuat(entity.rotation) * mat
mat = m.mat4Translate(entity.position) * mat
return mat
}