Untitled
Loading...
Searching...
No Matches
engine_utilities.h
Go to the documentation of this file.
1#ifndef ENGINE_UTILITIES_H
2#define ENGINE_UTILITIES_H
3
4#include "core/engine_types.h"
5#include "utilities/mathf.h"
7
8static inline void start_timer(Timer* t) {
9 t->start = SDL_GetPerformanceCounter();
10 t->freq = SDL_GetPerformanceFrequency();
11}
12
13static inline double end_timer(Timer* t) {
14 Uint64 end = SDL_GetPerformanceCounter();
15 return (double)(end - t->start) * 1000.0 / (double)t->freq;
16}
17bool mn_inside_of_root_tree(MeshNode * mns, int check_id, int id);
19
22 mat4 S = mat4_scale(mn->scale);
23
24 return m4_mul(T, m4_mul(R, S));
25}
26
27static inline void PV_step_size(ProbeVolume * pv, vec3 * step_x, vec3 * step_y, vec3 * step_z)
28{
29
30 vec3 fwd; vec3 right; vec3 up;
31 OBB_vectors(pv->obb.rot, &fwd, &right, &up);
32
33 float dx = (pv->obb.extents.x * 2) / (pv->resolution.x-1);
34 float dy = (pv->obb.extents.y * 2) / (pv->resolution.y-1);
35 float dz = (pv->obb.extents.z * 2) / (pv->resolution.z-1);
36
37 *step_x = vec3_scale(fwd, dx);
38 *step_y = vec3_scale(right, dy);
39 *step_z = vec3_scale(up, dz);
40
41}
43
44
45#endif
Engine specific types and defines.
bool mn_inside_of_root_tree(MeshNode *mns, int check_id, int id)
MeshNode * get_root_node(MeshNode *mns, MeshNode *mn)
double end_timer(Timer *t)
mat4 compose_trs_from_mesh_node(MeshNode *mn)
void start_timer(Timer *t)
void PV_step_size(ProbeVolume *pv, vec3 *step_x, vec3 *step_y, vec3 *step_z)
ivec3 resolution
The resolution in X, Y, Z.
OBB obb
The OBB that defines the size.
The ProbeVolumes for APVs and LPVs, controlled by OBBs.
vec3 translation
vec3 extents
Definition dynamic.frag:23
mat3 rot
Definition types.h:49
MeshNodes that describe the position of Meshes, GLTF nodes for GLTFAnimations, or hold references to ...
mat4 m4_mul(mat4 a, mat4 b)
Definition mathf.h:401
vec3 vec3_scale(vec3 a, float b)
Definition mathf.h:248
float x
Definition types.h:12
int y
Definition types.h:15
float y
Definition types.h:12
int z
Definition types.h:15
uint64_t start
Definition types.h:334
float z
Definition types.h:12
int x
Definition types.h:15
uint64_t freq
Definition types.h:335
Definition types.h:333
Definition types.h:21
Definition types.h:12
mat4 mat4_translation(vec3 t)
Definition utilities.h:445
mat4 mat4_from_quat(vec4 q)
Definition utilities.h:459
void OBB_vectors(mat3 rot, vec3 *fwd, vec3 *right, vec3 *up)
Definition utilities.h:600
mat4 mat4_scale(vec3 s)
Definition utilities.h:452