File: caveview.h

package info (click to toggle)
libstb 0.0~git20180212.15.e6afb9c-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,440 kB
  • sloc: ansic: 65,656; cpp: 1,020; makefile: 54
file content (50 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef INCLUDE_CAVEVIEW_H
#define INCLUDE_CAVEVIEW_H

#include "stb.h"

#include "stb_voxel_render.h"

typedef struct
{
   int cx,cy;

   stbvox_mesh_maker mm;

   uint8 *build_buffer;
   uint8 *face_buffer;

   int num_quads;
   float transform[3][3];
   float bounds[2][3];

   uint8 sv_blocktype[34][34][18];
   uint8 sv_lighting [34][34][18];
} raw_mesh;

// a 3D checkerboard of empty,solid would be: 32x32x255x6/2 ~= 800000
// an all-leaf qchunk would be: 32 x 32 x 255 x 6 ~= 1,600,000

#define BUILD_QUAD_MAX     400000
#define BUILD_BUFFER_SIZE  (4*4*BUILD_QUAD_MAX) // 4 bytes per vertex, 4 vertices per quad
#define FACE_BUFFER_SIZE   (  4*BUILD_QUAD_MAX) // 4 bytes per quad


extern void mesh_init(void);
extern void render_init(void);
extern void world_init(void);
extern void ods(char *fmt, ...); // output debug string
extern void reset_cache_size(int size);


extern void render_caves(float pos[3]);


#include "cave_parse.h"  // fast_chunk

extern fast_chunk *get_converted_fastchunk(int chunk_x, int chunk_y);
extern void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh *rm);
extern void reset_cache_size(int size);
extern void deref_fastchunk(fast_chunk *fc);

#endif