Untitled
Loading...
Searching...
No Matches
mathf.h File Reference
#include <math.h>
#include "types.h"
#include <stdio.h>

Go to the source code of this file.

Macros

#define MAX(a, b)
#define MIN(a, b)

Functions

int round_up_power_of_two (int a, int max)
float smoothstep (float a, float b, float c)
vec2 vec2_normalize (vec2 v)
vec3 vec3_normalize (vec3 v)
vec4 vec4_normalize (vec4 v)
vec3 ivec3_normalize (ivec3 a)
vec3 vec3_cross (vec3 a, vec3 b)
mat3 rotation_matrix_r (vec3 right, vec3 up, vec3 forward)
bool m9_inverse (float inverse[9][9], float mat[9][9])
bool m4_inverse (float out[16], const float m[16])
vec2 vec2_scale (vec2 a, float b)
vec3 vec3_scale (vec3 a, float b)
vec4 vec4_scale (vec4 a, float b)
float ivec3_dist (ivec3 a, ivec3 b)
ivec3 ivec3_sub (ivec3 a, ivec3 b)
vec3 vec3_sub (vec3 a, vec3 b)
vec2 vec2_sub (vec2 a, vec2 b)
vec2 vec2_add (vec2 a, vec2 b)
ivec3 ivec3_add (ivec3 a, ivec3 b)
vec3 ivec3_scale (ivec3 a, float b)
vec3 vec3_add (vec3 a, vec3 b)
vec4 vec4_add (vec4 a, vec4 b)
vec4 vec4_sub (vec4 a, vec4 b)
vec3 vec3_mul (vec3 a, vec3 b)
vec4 vec4_mul (vec4 a, vec4 b)
vec3 vec3_div (vec3 a, vec3 b)
float vec3_dist2 (vec3 a, vec3 b)
float vec3_dist2x2 (vec3 a, vec3 b)
float vec3_dist (vec3 a, vec3 b)
float vec3_dot (vec3 a, vec3 b)
float vec2_dot (vec2 a, vec2 b)
float vec3_length (vec3 v)
float vec4_length (vec4 v)
float vec2_length (vec2 v)
mat4 mat4_inverse (mat4 in)
float lerp (float a, float b, float t)
vec3 vec3_lerp (vec3 a, vec3 b, float t)
float clamp (float a, float b, float c)
vec4 mul_m4_v4 (mat4 m, vec4 v)
vec4 mul_m4_v4r (mat4 m, vec4 v)
mat4 m4_mul (mat4 a, mat4 b)
void mat4_mul (float out[16], const float a[16], const float b[16])
uint32_t expand_bits (uint32_t v)
uint32_t morton (uint32_t x, uint32_t y, uint32_t z)

Macro Definition Documentation

◆ MAX

◆ MIN

Function Documentation

◆ round_up_power_of_two()

int round_up_power_of_two ( int a,
int max )
inline

Definition at line 11 of file mathf.h.

References round_up_power_of_two().

Referenced by allocate_audio_scratch_hrtf(), and round_up_power_of_two().

◆ smoothstep()

float smoothstep ( float a,
float b,
float c )
inline

Definition at line 27 of file mathf.h.

References smoothstep().

Referenced by main(), smoothstep(), and vignette().

◆ vec2_normalize()

vec2 vec2_normalize ( vec2 v)
inline

Definition at line 38 of file mathf.h.

References vec2_normalize(), vec2::x, and vec2::y.

Referenced by render_text_menu(), render_ui_menu(), update_leg(), and vec2_normalize().

◆ vec3_normalize()

◆ vec4_normalize()

vec4 vec4_normalize ( vec4 v)
inline

Definition at line 55 of file mathf.h.

References vec4_normalize(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by update_physics_components(), and vec4_normalize().

◆ ivec3_normalize()

vec3 ivec3_normalize ( ivec3 a)
inline

Definition at line 69 of file mathf.h.

References ivec3_normalize(), ivec3::x, vec3::x, ivec3::y, vec3::y, ivec3::z, and vec3::z.

Referenced by ivec3_normalize().

◆ vec3_cross()

◆ rotation_matrix_r()

mat3 rotation_matrix_r ( vec3 right,
vec3 up,
vec3 forward )
inline

◆ m9_inverse()

bool m9_inverse ( float inverse[9][9],
float mat[9][9] )
inline

Definition at line 108 of file mathf.h.

References m9_inverse(), and temp.

Referenced by m9_inverse().

◆ m4_inverse()

◆ vec2_scale()

vec2 vec2_scale ( vec2 a,
float b )
inline

◆ vec3_scale()

◆ vec4_scale()

vec4 vec4_scale ( vec4 a,
float b )
inline

Definition at line 252 of file mathf.h.

References vec4_scale(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by fbm_noise(), perm(), and vec4_scale().

◆ ivec3_dist()

float ivec3_dist ( ivec3 a,
ivec3 b )
inline

Definition at line 257 of file mathf.h.

References ivec3_dist(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_dist().

◆ ivec3_sub()

ivec3 ivec3_sub ( ivec3 a,
ivec3 b )
inline

Definition at line 262 of file mathf.h.

References ivec3_sub(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_sub().

◆ vec3_sub()

vec3 vec3_sub ( vec3 a,
vec3 b )
inline

Definition at line 266 of file mathf.h.

References vec3_sub(), vec3::x, vec3::y, and vec3::z.

Referenced by a_star_aportal(), add_horizon_face_to_hull_faces(), assign_uvs(), check_audio_pv(), check_face_visibility(), check_lighting_pv(), clip_against_plane(), clip_manifold(), clip_pts_against_plane(), clip_tri_against_plane(), closest_point_segment(), closest_point_triangle(), collision(), compute_3d_barycentric(), compute_camera_basis(), compute_tri_normal(), compute_triangle_normal(), define_M(), determine_closest_rprobes(), determine_light_visibility_per_mesh(), epa(), EPA_add_horizon_face_to_hull_faces(), EPA_check_face_visibility(), fbm_noise(), find_closest_visible_aportal(), find_next_direction(), generate_capsule_hull_manifold(), incremental_hull(), interpolate_nearest_aprobes(), obb_orthonormalize(), pathfind_audio_occlusion(), PC_resolve_impulse(), PC_resolve_impulse_static(), perform_clip(), player_find_collision(), player_resolve_impulse(), player_resolve_impulse_static(), point_in_obb(), point_in_triangle(), point_triangle_distance(), pos_to_pv_local(), process_sdl_event(), project_point_plane(), ray_intersects_obb_with_point(), ray_intersects_triangle(), ray_traverse_scene_bvh(), recalculate_audio_portal_paths(), render(), segment_plane_distance(), setup_initial_hull_points(), solve_Q(), support_diff(), test_sphere_aabb(), update_angular_spring(), update_audio_occlusion(), update_body_from_legs(), update_leg(), update_light_camera(), update_physics_components(), update_skeleton(), update_spring(), vec3_dist(), vec3_dist2(), vec3_dist2x2(), vec3_lerp(), and vec3_sub().

◆ vec2_sub()

◆ vec2_add()

vec2 vec2_add ( vec2 a,
vec2 b )
inline

◆ ivec3_add()

ivec3 ivec3_add ( ivec3 a,
ivec3 b )
inline

Definition at line 278 of file mathf.h.

References ivec3_add(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_add().

◆ ivec3_scale()

vec3 ivec3_scale ( ivec3 a,
float b )
inline

Definition at line 282 of file mathf.h.

References ivec3_scale(), ivec3::x, ivec3::y, and ivec3::z.

Referenced by ivec3_scale().

◆ vec3_add()

◆ vec4_add()

vec4 vec4_add ( vec4 a,
vec4 b )
inline

Definition at line 290 of file mathf.h.

References vec4_add(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by fbm_noise(), get_view_planes(), perm(), and vec4_add().

◆ vec4_sub()

vec4 vec4_sub ( vec4 a,
vec4 b )
inline

Definition at line 294 of file mathf.h.

References vec4_sub(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by get_view_planes(), and vec4_sub().

◆ vec3_mul()

vec3 vec3_mul ( vec3 a,
vec3 b )
inline

Definition at line 298 of file mathf.h.

References vec3_mul(), vec3::x, vec3::y, and vec3::z.

Referenced by fbm_noise(), init_player(), and vec3_mul().

◆ vec4_mul()

vec4 vec4_mul ( vec4 a,
vec4 b )
inline

Definition at line 302 of file mathf.h.

References vec4_mul(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by perm(), and vec4_mul().

◆ vec3_div()

vec3 vec3_div ( vec3 a,
vec3 b )
inline

Definition at line 306 of file mathf.h.

References vec3_div(), vec3::x, vec3::y, and vec3::z.

Referenced by pos_to_pv_local(), and vec3_div().

◆ vec3_dist2()

float vec3_dist2 ( vec3 a,
vec3 b )
inline

Definition at line 310 of file mathf.h.

References vec3_dist2(), vec3_sub(), vec3::x, vec3::y, and vec3::z.

Referenced by vec3_dist2().

◆ vec3_dist2x2()

float vec3_dist2x2 ( vec3 a,
vec3 b )
inline

Definition at line 314 of file mathf.h.

References vec3_dist2x2(), vec3_sub(), vec3::x, vec3::y, and vec3::z.

Referenced by vec3_dist2x2().

◆ vec3_dist()

float vec3_dist ( vec3 a,
vec3 b )
inline

◆ vec3_dot()

◆ vec2_dot()

float vec2_dot ( vec2 a,
vec2 b )
inline

Definition at line 325 of file mathf.h.

References vec2_dot(), vec2::x, and vec2::y.

Referenced by update_ui_state(), and vec2_dot().

◆ vec3_length()

◆ vec4_length()

float vec4_length ( vec4 v)
inline

Definition at line 332 of file mathf.h.

References vec4_length(), vec4::w, vec4::x, vec4::y, and vec4::z.

Referenced by build_light_bvh(), and vec4_length().

◆ vec2_length()

float vec2_length ( vec2 v)
inline

◆ mat4_inverse()

◆ lerp()

float lerp ( float a,
float b,
float t )
inline

◆ vec3_lerp()

vec3 vec3_lerp ( vec3 a,
vec3 b,
float t )
inline

Definition at line 375 of file mathf.h.

References vec3_add(), vec3_lerp(), vec3_scale(), and vec3_sub().

Referenced by render_tree(), update_animation_components(), update_leg(), and vec3_lerp().

◆ clamp()

◆ mul_m4_v4()

◆ mul_m4_v4r()

◆ m4_mul()

◆ mat4_mul()

void mat4_mul ( float out[16],
const float a[16],
const float b[16] )
inline

Definition at line 421 of file mathf.h.

References mat4_mul().

Referenced by mat4_mul().

◆ expand_bits()

uint32_t expand_bits ( uint32_t v)
inline

Definition at line 438 of file mathf.h.

References expand_bits().

Referenced by expand_bits(), and morton().

◆ morton()

uint32_t morton ( uint32_t x,
uint32_t y,
uint32_t z )
inline

Definition at line 447 of file mathf.h.

References expand_bits(), and morton().

Referenced by morton().