Space Sim
Loading...
Searching...
No Matches
camera.c File Reference
#include <math.h>
#include <omp.h>
#include "mesh/mesh.h"
#include "core/types.h"
#include "utilities/mathf.h"
#include "core/camera.h"
#include "core/init.h"
#include <stdio.h>

Go to the source code of this file.

Functions

void compute_camera_basis (Camera *cam, vec3 world_up)
mat4 make_ortho (float left, float right, float bottom, float top, float near, float far)
mat4 make_projection (float fov_deg, float aspect, float near, float far)
void print_mat4 (const mat4 *m)
mat4 make_look_at (Camera *cam, vec3 eye)
void update_light_camera (Camera *lcam)
void update_camera (Camera *cam)
void apply_air_acceleration (vec2 wish, float wish_speed, float accel, float dt)
void apply_planet_velocity (Camera *cam, vec3 move_dir, float dt)
vec3 find_density_normal (vec3 sample, float d)
bool find_surface_entry (vec3 start, vec3 p, vec3 *entry, vec3 *normal, float voxel_size, float radius, float planet_radius)
float find_surface_z (vec3 p)
float find_surface (vec3 cam_pos, vec3 p, float planet_radius)
bool hit_ground (float z, float current_floor)
bool check_collision (vec3 start, vec3 final, vec3 *normal, vec3 *entrance, float d, float current_floor, float planet_radius)
void resolve_collisions (Camera *cam, float planet_radius)
void apply_velocity (Camera *cam, vec3 move_dir, float dt)
float signed_angle (vec2 a, vec2 b)
float signed_angle_3d (vec3 a, vec3 b, vec3 n)
float pitch_difference (vec3 a, vec3 b)
void look_at_selected_body ()

Variables

bool was_on_ground = false
bool was_not_on_ground = false
bool ground_hit = false
const float radius = 0.5

Function Documentation

◆ compute_camera_basis()

◆ make_ortho()

mat4 make_ortho ( float left,
float right,
float bottom,
float top,
float near,
float far )

◆ make_projection()

mat4 make_projection ( float fov_deg,
float aspect,
float near,
float far )

◆ print_mat4()

void print_mat4 ( const mat4 * m)

◆ make_look_at()

◆ update_light_camera()

◆ update_camera()

◆ apply_air_acceleration()

void apply_air_acceleration ( vec2 wish,
float wish_speed,
float accel,
float dt )

◆ apply_planet_velocity()

◆ find_density_normal()

vec3 find_density_normal ( vec3 sample,
float d )

◆ find_surface_entry()

bool find_surface_entry ( vec3 start,
vec3 p,
vec3 * entry,
vec3 * normal,
float voxel_size,
float radius,
float planet_radius )

◆ find_surface_z()

float find_surface_z ( vec3 p)

Definition at line 492 of file camera.c.

References calc_density(), find_surface_z(), vec3::x, vec3::y, and vec3::z.

Referenced by find_surface_z().

◆ find_surface()

float find_surface ( vec3 cam_pos,
vec3 p,
float planet_radius )

Definition at line 522 of file camera.c.

References calc_density(), find_surface(), planet_radius, vec3::x, vec3::y, and vec3::z.

Referenced by find_surface(), and resolve_collisions().

◆ hit_ground()

bool hit_ground ( float z,
float current_floor )

◆ check_collision()

bool check_collision ( vec3 start,
vec3 final,
vec3 * normal,
vec3 * entrance,
float d,
float current_floor,
float planet_radius )

◆ resolve_collisions()

◆ apply_velocity()

void apply_velocity ( Camera * cam,
vec3 move_dir,
float dt )

◆ signed_angle()

float signed_angle ( vec2 a,
vec2 b )

Definition at line 783 of file camera.c.

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

Referenced by look_at_selected_body(), and signed_angle().

◆ signed_angle_3d()

float signed_angle_3d ( vec3 a,
vec3 b,
vec3 n )

Definition at line 798 of file camera.c.

References signed_angle_3d(), vec3_cross(), and vec3_dot().

Referenced by signed_angle_3d().

◆ pitch_difference()

float pitch_difference ( vec3 a,
vec3 b )

Definition at line 816 of file camera.c.

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

Referenced by look_at_selected_body(), and pitch_difference().

◆ look_at_selected_body()

Variable Documentation

◆ was_on_ground

bool was_on_ground = false

Definition at line 576 of file camera.c.

Referenced by check_collision(), and hit_ground().

◆ was_not_on_ground

bool was_not_on_ground = false

Definition at line 577 of file camera.c.

◆ ground_hit

bool ground_hit = false

Definition at line 578 of file camera.c.

Referenced by check_collision(), hit_ground(), and resolve_collisions().

◆ radius

const float radius = 0.5