#include "utils.h" #include "assets.h" #include "entity.h" #ifndef WORLD_H #define WORLD_H #define WORLD_ENTITY_MAX 3000 #define WORLD_PLANT_COUNT 1000 #define WORLD_PLACE_COUNT 1 #define WORLD_SIZE (Vector3){4096.0, 256.0, 4096.0} #define WORLD_IMAGE_WIDTH 512 #define WORLD_IMAGE_HEIGHT 512 #define WORLD_IMAGE_SCALE 5.0 #define WORLD_GROUND_COLOR GREEN #define WORLD_GROUND_BLUR 2 #define WORLD_GROUND_CONTRAST -30 #define WORLD_GROUND_IMAGE_NOISE 0.3 #define BVH_MAX 4 // Max entities per node. #define BVH_MAX_BRANCH_COUNT 8 #define BVH_BOX_MAX 100.0 // Places. #define PLACE_POND_MAX_DISTANCE 100 // Max distance from center. // UID for anything in the world. typedef int16_t WorldUID; typedef int Seed; // Places. enum { PLACE_POND }; typedef struct BVHNode { BoundingBox box; Vector3 position; WorldUID entities[BVH_MAX]; // Only for leafs. struct BVHNode* branches[BVH_MAX_BRANCH_COUNT]; int8_t branchCount; } BVHNode; struct World { Vector3 size; Texture heightmapTexture; Model heightmap; Entity entities[WORLD_ENTITY_MAX]; BVHNode bvh; WorldUID places[WORLD_PLACE_COUNT]; int bvhDebugSelect; }; World createWorld(Seed seed); void updateWorld(World* world, Game* game); void freeWorld(World world); // Dam, I wanta live in a free world ): float getWorldHeightAtLocation(const World* world, float x, float y); WorldUID castRayAtWorld(const World* world, Ray ray, int* tests); #endif