Space Sim
Loading...
Searching...
No Matches
types.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <SDL2/SDL.h>
#include <GL/glew.h>
#include "nk_config.h"
#include "nuklear/nuklear.h"
#include <omp.h>
#include "nuklear/nuklear_sdl_gl3.h"

Go to the source code of this file.

Data Structures

struct  vec2
struct  vec3
struct  vec4
struct  ivec3
struct  ivec4
struct  uvec4
struct  mat4
struct  Timer
struct  Particle
struct  ParticleVertex
struct  Node
struct  MortonPair
struct  ParticleData
struct  MortonData
struct  GPUNode
struct  NodeData
struct  RadixData
struct  ChunkList
struct  NodeCounter
struct  BoundsData
struct  CamData
struct  RenderData
struct  Camera
struct  ChunkScore
struct  Globals
struct  ChunkData
struct  MarchingCubesData
struct  Vertex
struct  AtmosphereVertex
struct  WaterVertex
struct  WarpLayer
struct  PerlinLayer
struct  FBMLayer
struct  PlanetData
struct  WaterData
struct  Uniform
struct  ComputeShaderProgram
struct  ShaderProgram
struct  DensityData
struct  VertexInfo
struct  GPUChunk
struct  DrawArraysIndirectCommand

Macros

#define FOV   90
#define VIEW_NEAR   0.01
#define VIEW_FAR   100000.0
#define BODY_COUNT   15000
#define MAX_NODES   45000
#define SHADOW_MAP_SIZE   2048
#define QUERY_FRAMES   3
#define MAX_DEPTH   64
#define WORKGROUP_SIZE   128
#define RADIX_BIN_SIZE   128
#define MAX_CHUNKS   1000
#define MAX_CHUNK_LIST   (MAX_CHUNKS * 20)
#define MAX_DENSITY_RESOLUTION   64
#define CHUNK_WORLD_SIZE   20
#define MAX_LAYERS   24
#define WATER_FFT_TEXTURE_SIZE   128
#define WATER_FFT_L   1000
#define MAX_LOD_MAX   1
#define HALF_LOD_MAX   27
#define QUARTER_LOD_MAX   90
#define HALF_DENSITY_RESOLUTION   32
#define QUARTER_DENSITY_RESOLUTION   16
#define WATER_RES   1024
#define VERTEX_COUNT_MAX   (LODMAX * MAX_CHUNKS * 5)
#define MESH_RES   64
#define ATMOSPHERE_RES   64
#define CHUNK_RADIUS   6
#define CHUNK_DIAMETER   (CHUNK_RADIUS * 2 + 1)
#define CHUNK_LIMIT   (CHUNK_DIAMETER * CHUNK_DIAMETER * CHUNK_DIAMETER)
#define PERLIN_TEXTURE_SIZE   32
#define WORLEY_TEXTURE_SIZE   32
#define FBM_TEXTURE_SIZE   32

Enumerations

enum  PerformanceQueryTypes {
  PQUERY_MAIN , PQUERY_BOUNDS , PQUERY_MORTON , PQUERY_RADIX , PQUERY_TREECOUNT , PQUERY_TREE , PQUERY_COM , PQUERY_ATMOSPHERE ,
  PQUERY_CLOUDS , PQUERY_WATER_GEN , PQUERY_WATER , PQUERY_MESH_GEN , PQUERY_PARTICLE , PQUERY_MESH , PQUERY_DRAW , PQUERY_POSTPROCESS ,
  PQUERY_MAX
}
enum  LodLevels { LOD0 , LOD1 , LOD2 , LOD3 , LODMAX }

Functions

void start_timer (Timer *t)
double end_timer (Timer *t)
float noise (vec3 p)
float noise3d (vec3 p)
void render_sky_cubemap ()
 Renders the atmosphere and clouds from inside of the atmosphere.

Variables

const int LOD_RES [LODMAX]
const int MAX_CHUNKS_LOD [LODMAX]
int LOD_DENSITY_SIZES [LODMAX]
int LOD_VERTEX_SIZES [LODMAX]
AtmosphereVertex * ATMOSPHERE_VERTS
uint32_t * ATMOSPHERE_INDICES
int ATMOSPHERE_VCNT
int ATMOSPHERE_ICNT
Globals GLOBALS
GLsync fence
Camera cam
Camera space_cam
Camera LIGHT_CAM
Camera * current_cam
GLuint64 density_time
GLuint64 mc_time
GLuint d_q
GLuint mc_q
bool within_planet_atmosphere

Data Structure Documentation

◆ vec2

struct vec2

Definition at line 45 of file types.h.

Data Fields
float x
float y

◆ vec3

struct vec3

Definition at line 5 of file main.h.

Data Fields
float x
float y
float z

◆ vec4

struct vec4

Definition at line 47 of file types.h.

Data Fields
float x
float y
float z
float w

◆ ivec3

struct ivec3

Definition at line 48 of file types.h.

Data Fields
int x
int y
int z

◆ ivec4

struct ivec4

Definition at line 49 of file types.h.

Data Fields
int x
int y
int z
int w

◆ uvec4

struct uvec4

Definition at line 50 of file types.h.

Data Fields
uint32_t x
uint32_t y
uint32_t z
uint32_t w

◆ mat4

struct mat4

Definition at line 51 of file types.h.

Data Fields
float a0
float a1
float a2
float a3
float b0
float b1
float b2
float b3
float c0
float c1
float c2
float c3
float d0
float d1
float d2
float d3

◆ Timer

struct Timer

Definition at line 53 of file types.h.

Data Fields
uint64_t start
uint64_t freq

◆ Particle

struct Particle

Definition at line 7 of file main.h.

Data Fields
vec3 pos
vec3 vel
vec4 p_m
vec4 mat
vec4 vel
vec4 acc

◆ ParticleVertex

struct ParticleVertex

Definition at line 101 of file types.h.

Data Fields
vec3 pos
vec3 vel

◆ Node

struct Node

Definition at line 108 of file types.h.

Data Fields
vec3 center_of_mass
vec3 center
float mass
int first_child
bool subdivided
float half_size
int body_index
vec4 com_m
vec4 min
vec3 max
int next
ivec4 lrpd

◆ MortonPair

struct MortonPair

Definition at line 121 of file types.h.

Data Fields
uint32_t pid
uint32_t m

◆ ParticleData

struct ParticleData

Definition at line 128 of file types.h.

Data Fields
Particle p_spawn[BODY_COUNT]
vec4 p_colors[BODY_COUNT]
uint32_t p_dead[BODY_COUNT]
uint32_t claimed[BODY_COUNT]
int nodes_visited[BODY_COUNT]
uint32_t star_particles[BODY_COUNT]
Particle p[BODY_COUNT]

◆ MortonData

struct MortonData

Definition at line 139 of file types.h.

Data Fields
MortonPair entry[BODY_COUNT]

◆ GPUNode

struct GPUNode

Definition at line 145 of file types.h.

Data Fields
vec4 com_m
vec4 min
vec3 max
int next
ivec4 lrpd

◆ NodeData

struct NodeData

Definition at line 156 of file types.h.

Data Fields
uint32_t ready_queue[MAX_NODES]
uint32_t children_remaining[MAX_NODES]
uint32_t depth_offsets[MAX_DEPTH+1]
uint32_t pad0
uint32_t pad1
uint32_t pad2
vec4 com_m[MAX_NODES]
vec4 lrsn[MAX_NODES]
vec4 nmin[MAX_NODES]
vec4 nmax[MAX_NODES]

◆ RadixData

struct RadixData

Definition at line 174 of file types.h.

Data Fields
uint32_t local_prefix[5000 *WORKGROUP_SIZE]
uint32_t local_offsets[BODY_COUNT]
uint32_t block_bin_count[5000 *RADIX_BIN_SIZE]
uint32_t global_offsets[5000 *RADIX_BIN_SIZE]
uint32_t local_bin_count[5000 *RADIX_BIN_SIZE]

◆ ChunkList

struct ChunkList

Definition at line 188 of file types.h.

Data Fields
int lod0
int lod1
int offset0
int offset1
int id0
int id1
vec3 center
vec3 min
vec3 max
bool free

◆ NodeCounter

struct NodeCounter

Definition at line 203 of file types.h.

Data Fields
uint32_t queue_out
int p_dead_cnt
int p_spawn_cnt
uint32_t star_pcnt

◆ BoundsData

struct BoundsData

Definition at line 212 of file types.h.

Data Fields
uint32_t minx
uint32_t miny
uint32_t minz
uint32_t maxx
uint32_t maxy
uint32_t maxz

◆ CamData

struct CamData

Definition at line 221 of file types.h.

Data Fields
vec4 cam_pos
vec4 cam_vel
mat4 proj
mat4 view
mat4 inv_proj
mat4 inv_view

◆ RenderData

struct RenderData

Definition at line 227 of file types.h.

Data Fields
ivec4 resolution

◆ Camera

struct Camera

Definition at line 231 of file types.h.

Data Fields
vec3 forward
vec3 right
vec3 up
vec3 dir
vec3 target
float yaw
float pitch
float roll
CamData cam_data
bool on_ground

◆ ChunkScore

struct ChunkScore

Definition at line 243 of file types.h.

Data Fields
int index
int lod
float score
bool active

◆ Globals

struct Globals

Definition at line 252 of file types.h.

Data Fields
int hovered_body
int selected_body
bool lock_on
bool paused
float min_mass
float max_mass
float mass_pow
float radius
bool force_space_cam
bool planet_meshing_toggle
bool water_toggle
bool particle_toggle
bool sky_toggle
bool profiling

◆ ChunkData

struct ChunkData

Definition at line 319 of file types.h.

Data Fields
int id0
int id1
int lod
bool within_frustum
uint32_t uID
ivec3 min
ivec3 max
ivec3 center
int replacement_index
int replacement_lod
bool is_child
bool free

◆ MarchingCubesData

struct MarchingCubesData

Definition at line 338 of file types.h.

Data Fields
int EDGE_TO_VERTICES[12][2]
int EDGE_TABLE[256]
int TRIANGLE_TABLE[256][16]

◆ Vertex

struct Vertex

Definition at line 347 of file types.h.

Data Fields
vec3 pos
float pad0
vec3 normal
float pad1
vec3 color
float pad2

◆ AtmosphereVertex

struct AtmosphereVertex

Definition at line 358 of file types.h.

Data Fields
vec3 pos
vec3 normal

◆ WaterVertex

struct WaterVertex

Definition at line 365 of file types.h.

Data Fields
vec3 pos

◆ WarpLayer

struct WarpLayer

Definition at line 371 of file types.h.

Data Fields
vec3 offset0
float freq0
vec3 offset1
float freq1
vec3 offset2
float freq2
float amp
float pad0
float pad1
float pad3

◆ PerlinLayer

struct PerlinLayer

Definition at line 387 of file types.h.

Data Fields
float freq
float amp
float pad0
float pad1

◆ FBMLayer

struct FBMLayer

Definition at line 397 of file types.h.

Data Fields
float freq
float amp
float pad0
float pad1

◆ PlanetData

struct PlanetData

Definition at line 408 of file types.h.

Data Fields
int warp_count
int perlin_count
int fbm_count
int pad0
vec4 sun_dir
vec4 sun_color
WarpLayer warp_layers[MAX_LAYERS]
PerlinLayer perlin_layers[MAX_LAYERS]
FBMLayer fbm_layers[MAX_LAYERS]

◆ Uniform

struct Uniform

Definition at line 433 of file types.h.

Data Fields
GLuint location
char name[256]

◆ ComputeShaderProgram

struct ComputeShaderProgram

Definition at line 439 of file types.h.

Data Fields
char path[256]
GLuint program
Uniform uniforms[32]

◆ ShaderProgram

struct ShaderProgram

Definition at line 449 of file types.h.

Data Fields
GLuint program
char vert_path[256]
char frag_path[256]
Uniform uniforms[32]

◆ VertexInfo

struct VertexInfo

Definition at line 484 of file types.h.

Data Fields
int vcnt
uint32_t uid
uint32_t pad0
uint32_t pad1
uint uid
uint pad0
uint pad1

◆ GPUChunk

struct GPUChunk

Definition at line 492 of file types.h.

Data Fields
float lod_dist[3]
uint32_t emitted_chunks
VertexInfo vertex_counts[VERTEX_COUNT_MAX]

◆ DrawArraysIndirectCommand

struct DrawArraysIndirectCommand

Definition at line 518 of file types.h.

Data Fields
uint32_t count
uint32_t instanceCount
uint32_t first
uint32_t baseInstance

Macro Definition Documentation

◆ FOV

#define FOV   90

Definition at line 35 of file types.h.

Referenced by update_camera().

◆ VIEW_NEAR

#define VIEW_NEAR   0.01

Definition at line 36 of file types.h.

Referenced by update_camera().

◆ VIEW_FAR

#define VIEW_FAR   100000.0

Definition at line 37 of file types.h.

Referenced by update_camera().

◆ BODY_COUNT

#define BODY_COUNT   15000

Definition at line 39 of file types.h.

Referenced by delta(), init_random(), layout(), main(), main(), render(), and sim_step().

◆ MAX_NODES

#define MAX_NODES   45000

Definition at line 40 of file types.h.

Referenced by layout(), main(), and sim_step().

◆ SHADOW_MAP_SIZE

#define SHADOW_MAP_SIZE   2048

Definition at line 42 of file types.h.

Referenced by init(), and render().

◆ QUERY_FRAMES

#define QUERY_FRAMES   3

Definition at line 43 of file types.h.

Referenced by main().

◆ MAX_DEPTH

#define MAX_DEPTH   64

Definition at line 154 of file types.h.

Referenced by layout(), main(), and sim_step().

◆ WORKGROUP_SIZE

#define WORKGROUP_SIZE   128

Definition at line 171 of file types.h.

Referenced by layout(), and main().

◆ RADIX_BIN_SIZE

#define RADIX_BIN_SIZE   128

Definition at line 172 of file types.h.

◆ MAX_CHUNKS

#define MAX_CHUNKS   1000

Definition at line 182 of file types.h.

Referenced by init(), init_chunk_data(), layout(), and load_chunks().

◆ MAX_CHUNK_LIST

#define MAX_CHUNK_LIST   (MAX_CHUNKS * 20)

Definition at line 184 of file types.h.

Referenced by init_chunk_data().

◆ MAX_DENSITY_RESOLUTION

#define MAX_DENSITY_RESOLUTION   64

Definition at line 297 of file types.h.

◆ CHUNK_WORLD_SIZE

#define CHUNK_WORLD_SIZE   20

◆ MAX_LAYERS

#define MAX_LAYERS   24

Definition at line 407 of file types.h.

Referenced by display_main_menu(), and layout().

◆ WATER_FFT_TEXTURE_SIZE

#define WATER_FFT_TEXTURE_SIZE   128

Definition at line 423 of file types.h.

Referenced by fft_textures(), init(), and update_water_fft().

◆ WATER_FFT_L

#define WATER_FFT_L   1000

Definition at line 424 of file types.h.

Referenced by init().

◆ MAX_LOD_MAX

#define MAX_LOD_MAX   1

Definition at line 464 of file types.h.

◆ HALF_LOD_MAX

#define HALF_LOD_MAX   27

Definition at line 465 of file types.h.

◆ QUARTER_LOD_MAX

#define QUARTER_LOD_MAX   90

Definition at line 466 of file types.h.

◆ HALF_DENSITY_RESOLUTION

#define HALF_DENSITY_RESOLUTION   32

Definition at line 467 of file types.h.

◆ QUARTER_DENSITY_RESOLUTION

#define QUARTER_DENSITY_RESOLUTION   16

Definition at line 468 of file types.h.

◆ WATER_RES

#define WATER_RES   1024

Definition at line 471 of file types.h.

Referenced by init().

◆ VERTEX_COUNT_MAX

#define VERTEX_COUNT_MAX   (LODMAX * MAX_CHUNKS * 5)

Definition at line 483 of file types.h.

Referenced by load_chunks().

◆ MESH_RES

#define MESH_RES   64

Definition at line 501 of file types.h.

Referenced by init().

◆ ATMOSPHERE_RES

#define ATMOSPHERE_RES   64

Definition at line 503 of file types.h.

Referenced by init(), main(), and make_atmosphere_sphere_face().

◆ CHUNK_RADIUS

#define CHUNK_RADIUS   6

Definition at line 505 of file types.h.

Referenced by load_chunks(), and make_atmosphere_sphere_face().

◆ CHUNK_DIAMETER

#define CHUNK_DIAMETER   (CHUNK_RADIUS * 2 + 1)

Definition at line 506 of file types.h.

◆ CHUNK_LIMIT

#define CHUNK_LIMIT   (CHUNK_DIAMETER * CHUNK_DIAMETER * CHUNK_DIAMETER)

Definition at line 507 of file types.h.

◆ PERLIN_TEXTURE_SIZE

#define PERLIN_TEXTURE_SIZE   32

◆ WORLEY_TEXTURE_SIZE

#define WORLEY_TEXTURE_SIZE   32

Definition at line 509 of file types.h.

Referenced by init(), and precompute_worley_texture().

◆ FBM_TEXTURE_SIZE

#define FBM_TEXTURE_SIZE   32

Definition at line 510 of file types.h.

Referenced by calc_density(), init(), precompute_fbm_texture(), and sample_fbm_density().

Enumeration Type Documentation

◆ PerformanceQueryTypes

Enumerator
PQUERY_MAIN 
PQUERY_BOUNDS 
PQUERY_MORTON 
PQUERY_RADIX 
PQUERY_TREECOUNT 
PQUERY_TREE 
PQUERY_COM 
PQUERY_ATMOSPHERE 
PQUERY_CLOUDS 
PQUERY_WATER_GEN 
PQUERY_WATER 
PQUERY_MESH_GEN 
PQUERY_PARTICLE 
PQUERY_MESH 
PQUERY_DRAW 
PQUERY_POSTPROCESS 
PQUERY_MAX 

Definition at line 69 of file types.h.

◆ LodLevels

enum LodLevels
Enumerator
LOD0 
LOD1 
LOD2 
LOD3 
LODMAX 

Definition at line 284 of file types.h.

Function Documentation

◆ start_timer()

void start_timer ( Timer * t)
inline

Definition at line 58 of file types.h.

References start_timer(), and t.

Referenced by load_chunks(), main(), make_atmosphere_sphere_face(), resolve_collisions(), and start_timer().

◆ end_timer()

double end_timer ( Timer * t)
inline

Definition at line 63 of file types.h.

References end_timer(), and t.

Referenced by end_timer(), load_chunks(), main(), and make_atmosphere_sphere_face().

◆ noise()

float noise ( vec3 p)

Definition at line 116 of file density.comp.

References noise(), perm(), vec3::x, vec3::y, vec4::y, and vec3::z.

Referenced by fbm(), and noise().

◆ noise3d()

float noise3d ( vec3 p)

Variable Documentation

◆ LOD_RES

const int LOD_RES[LODMAX]
Initial value:
=
{
16, 8, 4, 2
}

Definition at line 299 of file types.h.

Referenced by create_new_planet_mesh(), and init().

◆ MAX_CHUNKS_LOD

const int MAX_CHUNKS_LOD[LODMAX]
Initial value:
=
{
32, 64, 100, 600
}

Definition at line 309 of file types.h.

Referenced by display_main_menu(), init(), init_chunk_data(), load_chunks(), and render_mesh_planet().

◆ LOD_DENSITY_SIZES

int LOD_DENSITY_SIZES[LODMAX]
extern

Definition at line 64 of file main.c.

Referenced by init().

◆ LOD_VERTEX_SIZES

int LOD_VERTEX_SIZES[LODMAX]
extern

Definition at line 65 of file main.c.

Referenced by init().

◆ ATMOSPHERE_VERTS

AtmosphereVertex* ATMOSPHERE_VERTS
extern

Definition at line 186 of file main.c.

Referenced by main(), make_atmosphere_sphere_face(), and mesh_atmosphere_sphere().

◆ ATMOSPHERE_INDICES

uint32_t* ATMOSPHERE_INDICES
extern

Definition at line 187 of file main.c.

Referenced by main(), and make_atmosphere_sphere_face().

◆ ATMOSPHERE_VCNT

int ATMOSPHERE_VCNT
extern

Definition at line 188 of file main.c.

Referenced by main(), make_atmosphere_sphere_face(), and mesh_atmosphere_sphere().

◆ ATMOSPHERE_ICNT

int ATMOSPHERE_ICNT
extern

◆ GLOBALS

Globals GLOBALS
extern

◆ fence

GLsync fence
extern

Definition at line 247 of file main.c.

Referenced by look_at_selected_body(), main(), and process_input().

◆ cam

Camera cam
extern

Definition at line 222 of file main.c.

◆ space_cam

Camera space_cam
extern

Definition at line 223 of file main.c.

Referenced by main(), and render().

◆ LIGHT_CAM

Camera LIGHT_CAM
extern

Definition at line 224 of file main.c.

Referenced by load_chunks(), main(), and render().

◆ current_cam

Camera* current_cam
extern

Definition at line 225 of file main.c.

Referenced by load_chunks(), main(), and process_input().

◆ density_time

GLuint64 density_time
extern

Definition at line 1720 of file main.c.

Referenced by main().

◆ mc_time

GLuint64 mc_time
extern

Definition at line 1721 of file main.c.

Referenced by main().

◆ d_q

GLuint d_q
extern

◆ mc_q

GLuint mc_q
extern

◆ within_planet_atmosphere

bool within_planet_atmosphere
extern

Definition at line 1249 of file main.c.

Referenced by main(), and render().