-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathworld.h
75 lines (54 loc) · 1.58 KB
/
world.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include "config.h"
#include "vmath.h"
#include "noise.h"
#include "actor.h"
#include "socket.h"
#include "block.h"
#include "player.h"
#include <stdbool.h>
#include <glew.h>
#include <SDL.h>
#include <FTGL/ftgl.h>
#define SEGMENT_BITS 4
#define SEGMENT_MASK ((1<<SEGMENT_BITS)-1)
#define SEGMENT_SIZE (1<<SEGMENT_BITS)
#define SEGMENT_SIZEV (Vec4i){SEGMENT_SIZE,SEGMENT_SIZE,SEGMENT_SIZE,SEGMENT_SIZE}
#define VIEW_RANGE 32
#define TEXTURE_SIZE 16
typedef struct World World;
typedef struct
{
Block data[SEGMENT_SIZE][SEGMENT_SIZE][SEGMENT_SIZE];
GLuint vbo;
int n;
bool rendered;
bool empty;
}Segment;
struct World
{
Segment* segment[VIEW_RANGE][VIEW_RANGE][VIEW_RANGE];
uint64_t ticks;
uint64_t lastSyncTicks;
uint32_t lastSyncTime;
uint32_t drawStart;
int maxActors;
Actor** actor;
Vec4i scroll;
GLuint terrain;
Noise noise;
FTGLfont *font;
};
public void worldInit(World* this);
public void worldLock(World* this);
public void worldUnlock(World* this);
public void worldDestroy(World* this);
public void worldTick(World* this, float timeDelta);
public Vec4i worldRay(World* world, Vec4f pos0, Vec4f normal, int max_length);
public void worldSet(World* this, Vec4i pos, Block block);
public Block worldGet(World* this, Vec4i pos);
public void worldSpiral(World* this, void (f)(World*,int x,int y,int z));
public Segment* newSegment(void);
public void worldAddActor(World* world, uint eid, Actor* actor);
public Actor* worldRemoveActor(World* world, uint eid);
public Actor* worldGetActor(World* world, uint eid);