some more cleanup
This commit is contained in:
parent
f4170614a7
commit
26e855369d
20 changed files with 22 additions and 41 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "pxl8_bytes.h"
|
||||
#include "pxl8_color.h"
|
||||
#include "pxl8_io.h"
|
||||
#include "pxl8_log.h"
|
||||
|
|
@ -328,22 +329,6 @@ void demo3d_bsp_destroy(demo3d_bsp* bsp) {
|
|||
memset(bsp, 0, sizeof(*bsp));
|
||||
}
|
||||
|
||||
i32 demo3d_bsp_find_leaf(const demo3d_bsp* bsp, pxl8_vec3 pos) {
|
||||
if (!bsp || bsp->num_nodes == 0) return -1;
|
||||
|
||||
i32 node_id = 0;
|
||||
|
||||
while (node_id >= 0) {
|
||||
const demo3d_bsp_node* node = &bsp->nodes[node_id];
|
||||
const demo3d_bsp_plane* plane = &bsp->planes[node->plane_id];
|
||||
|
||||
f32 dist = pxl8_vec3_dot(pos, plane->normal) - plane->dist;
|
||||
node_id = node->children[dist < 0 ? 1 : 0];
|
||||
}
|
||||
|
||||
return -(node_id + 1);
|
||||
}
|
||||
|
||||
|
||||
bool demo3d_bsp_is_leaf_visible(const demo3d_bsp* bsp, i32 leaf_from, i32 leaf_to) {
|
||||
if (!bsp || !bsp->visdata || bsp->visdata_size == 0) return true;
|
||||
|
|
|
|||
|
|
@ -157,6 +157,18 @@ static inline bool demo3d_bsp_get_edge_vertex(const demo3d_bsp* bsp, i32 surfedg
|
|||
return *out_vert_idx < bsp->num_vertices;
|
||||
}
|
||||
|
||||
static inline i32 demo3d_bsp_find_leaf(const demo3d_bsp* bsp, pxl8_vec3 pos) {
|
||||
if (!bsp || bsp->num_nodes == 0) return -1;
|
||||
i32 node_id = 0;
|
||||
while (node_id >= 0) {
|
||||
const demo3d_bsp_node* node = &bsp->nodes[node_id];
|
||||
const demo3d_bsp_plane* plane = &bsp->planes[node->plane_id];
|
||||
f32 dist = pxl8_vec3_dot(pos, plane->normal) - plane->dist;
|
||||
node_id = node->children[dist < 0 ? 1 : 0];
|
||||
}
|
||||
return -(node_id + 1);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -166,7 +178,6 @@ void demo3d_bsp_destroy(demo3d_bsp* bsp);
|
|||
u32 demo3d_bsp_face_count(const demo3d_bsp* bsp);
|
||||
pxl8_vec3 demo3d_bsp_face_normal(const demo3d_bsp* bsp, u32 face_id);
|
||||
void demo3d_bsp_face_set_material(demo3d_bsp* bsp, u32 face_id, u16 material_id);
|
||||
i32 demo3d_bsp_find_leaf(const demo3d_bsp* bsp, pxl8_vec3 pos);
|
||||
bool demo3d_bsp_is_leaf_visible(const demo3d_bsp* bsp, i32 leaf_from, i32 leaf_to);
|
||||
demo3d_bsp_lightmap demo3d_bsp_lightmap_mapped(u8 width, u8 height, u32 offset);
|
||||
demo3d_bsp_lightmap demo3d_bsp_lightmap_uniform(u8 r, u8 g, u8 b);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
#include "demo3d_bsp.h"
|
||||
#include "pxl8_gfx.h"
|
||||
#include "pxl8_mesh.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "pxl8_mesh.h"
|
||||
|
||||
typedef struct demo3d_bsp_render_state {
|
||||
pxl8_gfx_material* materials;
|
||||
pxl8_mesh* mesh;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "pxl8_net.h"
|
||||
#include "demo3d_chunk_cache.h"
|
||||
#include "demo3d_protocol.h"
|
||||
#include "pxl8_types.h"
|
||||
|
||||
|
|
@ -9,7 +10,6 @@
|
|||
#define DEMO3D_NET_TICK_RATE 30.0f
|
||||
|
||||
typedef struct demo3d_world demo3d_world;
|
||||
typedef struct demo3d_chunk_cache demo3d_chunk_cache;
|
||||
|
||||
typedef struct demo3d_net {
|
||||
pxl8_net* transport;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <miniz.h>
|
||||
|
||||
#include "pxl8_bytes.h"
|
||||
#include "pxl8_color.h"
|
||||
#include "pxl8_io.h"
|
||||
#include "pxl8_log.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "pxl8_io.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pxl8_bytes.h"
|
||||
#include "pxl8_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "pxl8_anim.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pxl8_ase.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "pxl8_font.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
pxl8_result pxl8_font_create_atlas(const pxl8_font* font, u8** atlas_data, i32* atlas_width, i32* atlas_height) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "pxl8_gfx2d.h"
|
||||
#include "pxl8_gfx3d.h"
|
||||
#include "pxl8_glows.h"
|
||||
#include "pxl8_platform.h"
|
||||
#include "pxl8_colormap.h"
|
||||
#include "pxl8_palette.h"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
#include "pxl8_gfx.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct pxl8_glows {
|
||||
pxl8_glow* data;
|
||||
u32 capacity;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "pxl8_lightmap.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
pxl8_lightmap* pxl8_lightmap_create(u32 width, u32 height, u32 scale) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#include "pxl8_lights.h"
|
||||
#include "pxl8_mem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct pxl8_lights {
|
||||
pxl8_light* data;
|
||||
u32 capacity;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "pxl8_mem.h"
|
||||
#include "pxl8_mesh.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
pxl8_mesh* pxl8_mesh_create(u32 vertex_capacity, u32 index_capacity) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#include "pxl8_particles.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "pxl8_gfx.h"
|
||||
#include "pxl8_mem.h"
|
||||
#include "pxl8_gfx2d.h"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
typedef struct pxl8_gfx pxl8_gfx;
|
||||
typedef struct pxl8_palette pxl8_palette;
|
||||
typedef struct pxl8_particles pxl8_particles;
|
||||
typedef struct pxl8_rng pxl8_rng;
|
||||
typedef struct pxl8_particles pxl8_particles;
|
||||
|
||||
typedef struct pxl8_particle {
|
||||
f32 angle;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "pxl8_tilemap.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pxl8_ase.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "pxl8_tilesheet.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pxl8_ase.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "pxl8_transition.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "pxl8_gfx.h"
|
||||
#include "pxl8_log.h"
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
#include "pxl8_types.h"
|
||||
|
||||
typedef struct {
|
||||
u32 active_id;
|
||||
bool cursor_clicked;
|
||||
bool cursor_down;
|
||||
i32 cursor_x;
|
||||
i32 cursor_y;
|
||||
bool cursor_down;
|
||||
bool cursor_clicked;
|
||||
u32 hot_id;
|
||||
u32 active_id;
|
||||
} pxl8_gui_state;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue