|
Space Sim
|
#include "core/init.h"#include "utilities/mathf.h"#include "core/types.h"#include "mesh/mesh.h"#include "uthash/uthash.h"#include "core/camera.h"#include <assert.h>#include <stdint.h>#include <stdio.h>#include <float.h>Go to the source code of this file.
Data Structures | |
| struct | ZeroKey |
| struct | ZeroEntry |
Macros | |
| #define | ATMOSPHERE_IDX(x, y, o) |
| #define | MAX_ZERO_LIST 100000 |
Enumerations | |
| enum | FACE { XPOS , XNEG , YPOS , YNEG , ZPOS , ZNEG } |
Functions | |
| vec3 | cube_pos (FACE face, vec2 uv) |
| vec3 | calc_normal (vec3 a, vec3 b, vec3 c) |
| float | mod289 (float x) |
| vec4 | perm (vec4 x) |
| vec3 | vec3_fract (vec3 x) |
| vec4 | vec4_fract (vec4 x) |
| float | fbm_noise (vec3 p) |
| float | fbm (vec3 p) |
| float | wrap (float x, float size) |
| vec3 | vec3_wrap (vec3 a, float size) |
| float | sample_density (vec3 p) |
| Samples a precomputed perlin volume. | |
| float | sample_fbm_density (vec3 p) |
| Samples a precomputed fbm volume. | |
| float | calc_density (vec3 p) |
| Copies the exact density function from the GPU to the CPU. | |
| void | create_new_planet_mesh (int lod, ivec3 chunk_center, int chunk_id, bool is_parent) |
| Creates a mesh for a certain chunk. | |
| bool | aabb_in_frustum (ivec3 min, ivec3 max, vec4 planes[6]) |
| void | get_view_planes (vec4 planes[6], Camera *cam, vec3 planet_offset, float planet_radius) |
| Returns view planes from a camera, used for frustum culling. | |
| int | compareJobs (const void *a, const void *b) |
| int | compareFrees (const void *a, const void *b) |
| int | find_current_lod (ivec3 center, ChunkHash **h) |
| Finds the highest LOD that we have cached from the current chunk. | |
| bool | free_current_parent (int lod, int i) |
| Frees the given LOD (as a parent). | |
| bool | free_parent (int lod, int i) |
| Frees the parent of given LOD. | |
| bool | free_child (int lod, int i) |
| Frees the child of given LOD. | |
| uint32_t | assign_new_uID () |
| void | init_chunk_data () |
| Initializes and frees old ChunkData and hash tables. | |
| void | load_chunks (vec3 planet_origin, float planet_radius) |
| Checks all chunks based on new Camera position, building a job list and then executing them based on ChunkScore. | |
| void | make_atmosphere_sphere_face (FACE face, int *vcnt, int *icnt) |
| Creats a sphere face to be used for atmosphere rendering. | |
| void | mesh_atmosphere_sphere () |
| Creates an atmosphere sphere for rendering. | |
Variables | |
| AuthorityEntry * | authority_map = NULL |
| ChunkHash * | hash_table = NULL |
| bool | already_emitted [LODMAX][MAX_CHUNKS] |
| uint32_t | chunk_uID = 0 |
| ZeroEntry * | zero_hash_table = NULL |
| int | zero_list_count = 0 |
| ChunkScore * | jobs = NULL |
| ChunkData * | job_data = NULL |
| ChunkScore * | frees = NULL |
| bool | replacement_mask [LODMAX][MAX_CHUNKS] = {0} |
| int | generation_id = 0 |
| int | emitted_chunks = 0 |
| int | emitted_chunk_ids [VERTEX_COUNT_MAX] |
| int | emitted_chunk_lods [VERTEX_COUNT_MAX] |
| GLsync | zero_fence |
| #define MAX_ZERO_LIST 100000 |
Definition at line 763 of file mesh.c.
Referenced by load_chunks().
Definition at line 36 of file mesh.c.
References cube_pos(), vec2::x, XNEG, XPOS, vec2::y, YNEG, YPOS, ZNEG, and ZPOS.
Referenced by cube_pos(), and make_atmosphere_sphere_face().
Definition at line 58 of file mesh.c.
References calc_normal(), vec3::x, vec3::y, and vec3::z.
Referenced by calc_normal(), and make_atmosphere_sphere_face().
Definition at line 79 of file mesh.c.
References mod289(), perm(), vec4_add(), vec4_mul(), vec4_scale(), vec4::w, vec4::x, vec4::y, and vec4::z.
Definition at line 101 of file mesh.c.
References vec3_fract(), vec3::x, vec3::y, and vec3::z.
Referenced by vec3_fract().
Definition at line 116 of file mesh.c.
References vec4_fract(), vec4::w, vec4::x, vec4::y, and vec4::z.
Referenced by fbm_noise(), and vec4_fract().
| float fbm_noise | ( | vec3 | p | ) |
Definition at line 134 of file mesh.c.
References fbm_noise(), perm(), vec2_add(), vec2_scale(), vec3_mul(), vec3_scale(), vec3_sub(), vec4_add(), vec4_fract(), vec4_scale(), vec4::w, vec2::x, vec3::x, vec4::x, vec2::y, vec3::y, vec4::y, vec3::z, and vec4::z.
Referenced by fbm(), and fbm_noise().
| float fbm | ( | vec3 | p | ) |
Definition at line 163 of file mesh.c.
References fbm(), fbm_noise(), vec3_add(), and vec3_scale().
| float wrap | ( | float | x, |
| float | size ) |
Definition at line 202 of file mesh.c.
References size, vec3_wrap(), wrap(), vec3::x, vec3::y, and vec3::z.
Referenced by vec3_wrap().
Definition at line 492 of file mesh.c.
References aabb_in_frustum(), vec3_dot(), vec4::w, ivec3::x, vec4::x, ivec3::y, vec4::y, ivec3::z, and vec4::z.
Referenced by aabb_in_frustum(), and load_chunks().
Returns view planes from a camera, used for frustum culling.
Definition at line 527 of file mesh.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, Camera::cam_data, CamData::cam_pos, mat4::d0, mat4::d1, mat4::d2, mat4::d3, get_view_planes(), m4_mul(), Camera::pitch, planet_radius, CamData::proj, update_camera(), vec4_add(), vec4_sub(), CamData::view, vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, vec3::z, and vec4::z.
Referenced by get_view_planes(), and load_chunks().
| int compareJobs | ( | const void * | a, |
| const void * | b ) |
Definition at line 569 of file mesh.c.
References compareJobs(), and ChunkScore::score.
Referenced by compareJobs(), and load_chunks().
| int compareFrees | ( | const void * | a, |
| const void * | b ) |
Definition at line 587 of file mesh.c.
References compareFrees(), and ChunkScore::score.
Referenced by compareFrees(), and load_chunks().
| uint32_t assign_new_uID | ( | ) |
Definition at line 757 of file mesh.c.
References assign_new_uID(), and chunk_uID.
Referenced by assign_new_uID(), and load_chunks().
| AuthorityEntry* authority_map = NULL |
Definition at line 617 of file mesh.c.
Referenced by get_current_lod(), init_chunk_data(), and set_current_lod().
| ChunkHash* hash_table = NULL |
Definition at line 618 of file mesh.c.
Referenced by add_chunk_hash(), delete_chunk_hash(), find_chunk_hash(), init_chunk_data(), and replace_chunk_hash().
| bool already_emitted[LODMAX][MAX_CHUNKS] |
Definition at line 623 of file mesh.c.
Referenced by free_child(), free_parent(), and load_chunks().
| uint32_t chunk_uID = 0 |
Definition at line 754 of file mesh.c.
Referenced by assign_new_uID(), and load_chunks().
| ZeroEntry* zero_hash_table = NULL |
Definition at line 778 of file mesh.c.
Referenced by init_chunk_data(), and load_chunks().
| int zero_list_count = 0 |
Definition at line 779 of file mesh.c.
Referenced by load_chunks().
| ChunkScore* jobs = NULL |
Definition at line 782 of file mesh.c.
Referenced by init_chunk_data(), and load_chunks().
| ChunkData* job_data = NULL |
Definition at line 783 of file mesh.c.
Referenced by init_chunk_data(), and load_chunks().
| ChunkScore* frees = NULL |
Definition at line 784 of file mesh.c.
Referenced by init_chunk_data(), and load_chunks().
| bool replacement_mask[LODMAX][MAX_CHUNKS] = {0} |
Definition at line 786 of file mesh.c.
Referenced by load_chunks().
| int generation_id = 0 |
Definition at line 877 of file mesh.c.
Referenced by load_chunks().
| int emitted_chunks = 0 |
Definition at line 879 of file mesh.c.
Referenced by layout(), load_chunks(), and main().
| int emitted_chunk_ids[VERTEX_COUNT_MAX] |
Definition at line 880 of file mesh.c.
Referenced by load_chunks().
| int emitted_chunk_lods[VERTEX_COUNT_MAX] |
Definition at line 881 of file mesh.c.
Referenced by load_chunks().
| GLsync zero_fence |
Definition at line 884 of file mesh.c.
Referenced by load_chunks().