aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.h
blob: 69f81bd0dcae40ff0a506105c50f6e6e639b57d3 (plain) (blame)
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
#include "utils.h"
#include "assets.h"
#include "entity.h"

// This file is likely completely change.

#ifndef WORLD_H
#define WORLD_H

#define BVH_MAX 4 // Max entities per node.
#define BVH_LEAF_COUNT 250
#define BVH_OVERLAP_MULTIPLIER 100.0

#define WORLD_ENTITY_MAX 1000
#define WORLD_SIZE (Vector3){1000.0, 100.0, 1000.0}
#define WORLD_IMAGE_WIDTH 100
#define WORLD_IMAGE_HEIGHT 100
#define WORLD_IMAGE_SCALE 5.0

// UID for anything in the world.x
typedef int16_t WorldUID;

typedef struct BVHNode {
  BoundingBox box;
  WorldUID entities[BVH_MAX]; // Only for leafs.
  struct BVHNode* branch1;
  struct BVHNode* branch2;
} BVHNode;

typedef struct {
  Vector3 size;
  Texture texture;
  Model heightmap;
  Entity entities[WORLD_ENTITY_MAX];
  BVHNode bvh;
  BVHNode bvhTest[BVH_LEAF_COUNT];
  int bvhTestSize;
} World;

World createWorld(int seed);
void updateWorld(World* world, Game* game);
void freeWorld(World world);
// Dam, I wanta live in a free world ):

float getWorldHeightAtLocation(World world, float x, float y);

#endif