Kohi Game Engine
math_types.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "defines.h"
15 
19 typedef union vec2_u {
22  struct {
23  union {
25  f32 x,
27  r,
29  s,
31  u;
32  };
33  union {
35  f32 y,
37  g,
39  t,
41  v;
42  };
43  };
44 } vec2;
45 
49 typedef union vec3_u {
52  struct {
53  union {
55  f32 x,
57  r,
59  s,
61  u;
62  };
63  union {
65  f32 y,
67  g,
69  t,
71  v;
72  };
73  union {
75  f32 z,
77  b,
79  p,
81  w;
82  };
83  };
84 } vec3;
85 
89 typedef union vec4_u {
92  union {
93  struct {
94  union {
96  f32 x,
98  r,
100  s;
101  };
102  union {
106  g,
108  t;
109  };
110  union {
114  b,
116  p,
119  };
120  union {
124  a,
126  q,
129  };
130  };
131  };
133 
135 typedef vec4 quat;
136 
138 typedef vec4 rect_2d;
139 
141 typedef union mat3_u {
143  f32 data[12];
145 
147 typedef union mat4_u {
149  f32 data[16];
151 
155 typedef struct extents_2d {
161 
165 typedef struct extents_3d {
171 
175 typedef struct vertex_3d {
187 
191 typedef struct vertex_2d {
197 
201 typedef struct colour_vertex_3d {
207 
215 typedef struct transform {
232 
234 
236  struct transform* parent;
238 
239 typedef struct plane_3d {
243 
244 typedef struct frustum {
245  // Top, bottom, right, left, far, near
This file contains global type definitions which are used throughout the entire engine and applicatio...
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
union mat3_u mat3
A 3x3 matrix.
struct extents_2d extents_2d
Represents the extents of a 2d object.
struct vertex_2d vertex_2d
Represents a single vertex in 2D space.
union vec2_u vec2
A 2-element vector.
union vec4_u vec4
A 4-element vector.
union vec3_u vec3
A 3-element vector.
union mat4_u mat4
a 4x4 matrix, typically used to represent object transformations.
struct extents_3d extents_3d
Represents the extents of a 3d object.
struct plane_3d plane_3d
struct frustum frustum
struct vertex_3d vertex_3d
Represents a single vertex in 3D space.
struct transform transform
Represents the transform of an object in the world. Transforms can have a parent whose own transform ...
vec4 rect_2d
A 2d rectangle.
Definition: math_types.h:138
struct colour_vertex_3d colour_vertex_3d
Represents a single vertex in 3D space with position and colour data only.
vec4 quat
A quaternion, used to represent rotational orientation.
Definition: math_types.h:135
Represents a single vertex in 3D space with position and colour data only.
Definition: math_types.h:201
vec4 position
The position of the vertex. w is ignored.
Definition: math_types.h:203
vec4 colour
The colour of the vertex.
Definition: math_types.h:205
Represents the extents of a 2d object.
Definition: math_types.h:155
vec2 max
The maximum extents of the object.
Definition: math_types.h:159
vec2 min
The minimum extents of the object.
Definition: math_types.h:157
Represents the extents of a 3d object.
Definition: math_types.h:165
vec3 min
The minimum extents of the object.
Definition: math_types.h:167
vec3 max
The maximum extents of the object.
Definition: math_types.h:169
Definition: math_types.h:244
plane_3d sides[6]
Definition: math_types.h:246
Definition: math_types.h:239
f32 distance
Definition: math_types.h:241
vec3 normal
Definition: math_types.h:240
Represents the transform of an object in the world. Transforms can have a parent whose own transform ...
Definition: math_types.h:215
vec3 position
The position in the world.
Definition: math_types.h:217
f32 determinant
Definition: math_types.h:233
mat4 local
The local transformation matrix, updated whenever the position, rotation or scale have changed.
Definition: math_types.h:231
b8 is_dirty
Indicates if the position, rotation or scale have changed, indicating that the local matrix needs to ...
Definition: math_types.h:226
quat rotation
The rotation in the world.
Definition: math_types.h:219
struct transform * parent
A pointer to a parent transform if one is assigned. Can also be null.
Definition: math_types.h:236
vec3 scale
The scale in the world.
Definition: math_types.h:221
Represents a single vertex in 2D space.
Definition: math_types.h:191
vec2 position
The position of the vertex.
Definition: math_types.h:193
vec2 texcoord
The texture coordinate of the vertex.
Definition: math_types.h:195
Represents a single vertex in 3D space.
Definition: math_types.h:175
vec3 position
The position of the vertex.
Definition: math_types.h:177
vec3 tangent
The tangent of the vertex.
Definition: math_types.h:185
vec3 normal
The normal of the vertex.
Definition: math_types.h:179
vec2 texcoord
The texture coordinate of the vertex.
Definition: math_types.h:181
vec4 colour
The colour of the vertex.
Definition: math_types.h:183
A 3x3 matrix.
Definition: math_types.h:141
f32 data[12]
The matrix elements.
Definition: math_types.h:143
a 4x4 matrix, typically used to represent object transformations.
Definition: math_types.h:147
f32 data[16]
The matrix elements.
Definition: math_types.h:149
A 2-element vector.
Definition: math_types.h:19
f32 r
The first element.
Definition: math_types.h:27
f32 v
The second element.
Definition: math_types.h:41
f32 s
The first element.
Definition: math_types.h:29
f32 x
The first element.
Definition: math_types.h:25
f32 g
The second element.
Definition: math_types.h:37
f32 t
The second element.
Definition: math_types.h:39
f32 u
The first element.
Definition: math_types.h:31
f32 y
The second element.
Definition: math_types.h:35
f32 elements[2]
An array of x, y.
Definition: math_types.h:21
A 3-element vector.
Definition: math_types.h:49
f32 elements[3]
An array of x, y, z.
Definition: math_types.h:51
f32 r
The first element.
Definition: math_types.h:57
f32 v
The second element.
Definition: math_types.h:71
f32 s
The first element.
Definition: math_types.h:59
f32 b
The third element.
Definition: math_types.h:77
f32 x
The first element.
Definition: math_types.h:55
f32 p
The third element.
Definition: math_types.h:79
f32 g
The second element.
Definition: math_types.h:67
f32 t
The second element.
Definition: math_types.h:69
f32 u
The first element.
Definition: math_types.h:61
f32 z
The third element.
Definition: math_types.h:75
f32 y
The second element.
Definition: math_types.h:65
f32 w
The third element.
Definition: math_types.h:81
A 4-element vector.
Definition: math_types.h:89
f32 q
The fourth element.
Definition: math_types.h:126
f32 elements[4]
An array of x, y, z, w.
Definition: math_types.h:91
f32 height
The fourth element.
Definition: math_types.h:128
f32 r
The first element.
Definition: math_types.h:98
f32 a
The fourth element.
Definition: math_types.h:124
f32 s
The first element.
Definition: math_types.h:100
f32 b
The third element.
Definition: math_types.h:114
f32 x
The first element.
Definition: math_types.h:96
f32 p
The third element.
Definition: math_types.h:116
f32 g
The third element.
Definition: math_types.h:106
f32 t
The third element.
Definition: math_types.h:108
f32 width
The third element.
Definition: math_types.h:118
f32 z
The third element.
Definition: math_types.h:112
f32 y
The second element.
Definition: math_types.h:104
f32 w
The fourth element.
Definition: math_types.h:122