|
Space Sim
|
#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 |
Definition at line 12 of file camera.c.
References cam, compute_camera_basis(), Camera::forward, Camera::pitch, Camera::right, Camera::up, vec3_cross(), vec3_normalize(), vec3::x, vec3::y, Camera::yaw, and vec3::z.
Referenced by compute_camera_basis(), render_sky_cubemap(), update_camera(), and update_light_camera().
| 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 ) |
Definition at line 76 of file camera.c.
References mat4::a0, mat4::a1, mat4::a2, mat4::a3, mat4::b0, mat4::b1, mat4::b2, mat4::b3, mat4::c0, mat4::c1, mat4::c2, mat4::c3, mat4::d0, mat4::d1, mat4::d2, mat4::d3, and make_projection().
Referenced by make_projection(), render_sky_cubemap(), and update_camera().
| void print_mat4 | ( | const mat4 * | m | ) |
Definition at line 130 of file camera.c.
References mat4::a0, mat4::a1, mat4::a2, mat4::a3, mat4::b0, mat4::b1, mat4::b2, mat4::b3, mat4::c0, mat4::c1, mat4::c2, mat4::c3, cam, mat4::d0, mat4::d1, mat4::d2, mat4::d3, Camera::forward, make_look_at(), Camera::right, s, Camera::up, vec3_dot(), vec3::x, vec3::y, and vec3::z.
Referenced by make_look_at(), render_sky_cubemap(), update_camera(), and update_light_camera().
| void update_light_camera | ( | Camera * | lcam | ) |
Definition at line 168 of file camera.c.
References cam, Camera::cam_data, CamData::cam_pos, compute_camera_basis(), Camera::forward, make_look_at(), make_ortho(), Camera::pitch, PLANET_DATA, CamData::proj, PlanetData::sun_dir, Camera::target, update_light_camera(), vec3_add(), vec3_normalize(), CamData::view, vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, vec3::z, and vec4::z.
Referenced by main(), and update_light_camera().
| void update_camera | ( | Camera * | cam | ) |
Definition at line 222 of file camera.c.
References cam, Camera::cam_data, CamData::cam_pos, compute_camera_basis(), Camera::forward, FOV, CamData::inv_proj, CamData::inv_view, make_look_at(), make_projection(), mat4_inverse(), CamData::proj, SCREEN_HEIGHT, SCREEN_WIDTH, Camera::target, update_camera(), vec3_add(), CamData::view, VIEW_FAR, VIEW_NEAR, vec4::x, vec4::y, and vec4::z.
Referenced by get_view_planes(), main(), and update_camera().
| void apply_air_acceleration | ( | vec2 | wish, |
| float | wish_speed, | ||
| float | accel, | ||
| float | dt ) |
Definition at line 263 of file camera.c.
References apply_air_acceleration(), cam, Camera::cam_data, CamData::cam_vel, clamp(), dt, Camera::forward, scale(), vec2::x, vec3::x, vec4::x, vec2::y, vec3::y, and vec4::y.
Referenced by apply_air_acceleration(), and apply_planet_velocity().
Definition at line 333 of file camera.c.
References apply_air_acceleration(), apply_planet_velocity(), cam, Camera::cam_data, CamData::cam_vel, dt, lerp(), Camera::on_ground, Camera::pitch, Camera::roll, scale(), vec3_normalize(), vec4_scale(), vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, and vec4::z.
Referenced by apply_planet_velocity(), and process_input().
Definition at line 409 of file camera.c.
References calc_density(), find_density_normal(), vec3_add(), vec3_normalize(), vec3::x, vec3::y, and vec3::z.
Referenced by find_density_normal(), and find_surface_entry().
| bool find_surface_entry | ( | vec3 | start, |
| vec3 | p, | ||
| vec3 * | entry, | ||
| vec3 * | normal, | ||
| float | voxel_size, | ||
| float | radius, | ||
| float | planet_radius ) |
Definition at line 428 of file camera.c.
References calc_density(), find_density_normal(), find_surface_entry(), planet_radius, radius, t, vec3_add(), vec3_length(), vec3_normalize(), vec3_scale(), vec3_sub(), and vec3::z.
Referenced by check_collision(), and find_surface_entry().
| 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().
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().
| bool hit_ground | ( | float | z, |
| float | current_floor ) |
Definition at line 581 of file camera.c.
References cam, Camera::cam_data, CamData::cam_pos, CamData::cam_vel, ground_hit, hit_ground(), Camera::on_ground, was_on_ground, and vec4::z.
Referenced by check_collision(), and hit_ground().
| bool check_collision | ( | vec3 | start, |
| vec3 | final, | ||
| vec3 * | normal, | ||
| vec3 * | entrance, | ||
| float | d, | ||
| float | current_floor, | ||
| float | planet_radius ) |
Definition at line 607 of file camera.c.
References cam, check_collision(), find_surface_entry(), ground_hit, hit_ground(), Camera::on_ground, planet_radius, radius, and was_on_ground.
Referenced by check_collision(), and resolve_collisions().
| void resolve_collisions | ( | Camera * | cam, |
| float | planet_radius ) |
Definition at line 638 of file camera.c.
References cam, Camera::cam_data, CamData::cam_pos, CamData::cam_vel, check_collision(), CHUNK_WORLD_SIZE, find_surface(), ground_hit, planet_radius, resolve_collisions(), start_timer(), vec3_add(), vec3_dot(), vec3_scale(), vec3_sub(), vec3::x, vec4::x, vec3::y, vec4::y, vec3::z, and vec4::z.
Referenced by process_input(), and resolve_collisions().
Definition at line 731 of file camera.c.
References apply_velocity(), cam, Camera::cam_data, CamData::cam_pos, CamData::cam_vel, dt, lerp(), Camera::pitch, Camera::roll, vec3_normalize(), vec4_scale(), vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, vec3::z, and vec4::z.
Referenced by apply_velocity(), and process_input().
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().
Definition at line 798 of file camera.c.
References signed_angle_3d(), vec3_cross(), and vec3_dot().
Referenced by signed_angle_3d().
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().
| void look_at_selected_body | ( | ) |
Definition at line 832 of file camera.c.
References cam, Camera::cam_data, CamData::cam_pos, fence, Camera::forward, GLOBALS, look_at_selected_body(), PARTICLE_SSBO, Camera::pitch, pitch_difference(), Globals::selected_body, signed_angle(), vec3_normalize(), vec3_scale(), vec3_sub(), vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, vec3::z, and vec4::z.
Referenced by look_at_selected_body().
| bool was_on_ground = false |
Definition at line 576 of file camera.c.
Referenced by check_collision(), and hit_ground().
| bool ground_hit = false |
Definition at line 578 of file camera.c.
Referenced by check_collision(), hit_ground(), and resolve_collisions().
| const float radius = 0.5 |
Definition at line 580 of file camera.c.
Referenced by check_collision(), display_main_menu(), find_surface_entry(), init_random(), main(), and make_atmosphere_sphere_face().