diff options
author | Omniscient <omniscient.oce@gmail.com> | 2024-07-11 18:03:34 +1000 |
---|---|---|
committer | Omniscient <omniscient.oce@gmail.com> | 2024-07-11 18:03:34 +1000 |
commit | 9f23f65ec631bcd08f200b3ef517da8acf8d6b17 (patch) | |
tree | bc0e9d9fc0c687b646ddcb5c44122bfc70b4cfed /src/systems/terrain.h | |
parent | 65d74bdb26af833b5380046dec204f685f745cc1 (diff) |
new
Diffstat (limited to 'src/systems/terrain.h')
-rw-r--r-- | src/systems/terrain.h | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/src/systems/terrain.h b/src/systems/terrain.h index 888b6f4..a65ecec 100644 --- a/src/systems/terrain.h +++ b/src/systems/terrain.h @@ -1,14 +1,10 @@ /** * @file terrain.h - * @author your name (you@domain.com) * @brief - * @version 0.1 - * @date 2024-04-27 - * - * @copyright Copyright (c) 2024 - * */ +#pragma once + /* Future: - Chunked terrain @@ -22,37 +18,33 @@ Future: #include "render.h" #include "str.h" -typedef struct heightmap { +typedef struct Heightmap { str8 filepath; u32x2 size; void* image_data; bool is_uploaded; -} heightmap; +} Heightmap; + +typedef struct Terrain_Storage Terrain_Storage; + +// --- Public API +PUB bool Terrain_Init(Terrain_Storage* storage); +PUB void Terrain_Shutdown(Terrain_Storage* storage); +PUB void Terrain_Run(Terrain_Storage* storage); // NOTE: For now it renders directly to main framebuffer -typedef struct terrain_state { - arena terrain_allocator; - heightmap* heightmap; // NULL = no heightmap - gpu_renderpass* hmap_renderpass; - gpu_pipeline* hmap_pipeline; -} terrain_state; +PUB Heightmap Heightmap_FromImage(str8 filepath); +PUB Heightmap Heightmap_FromPerlin(/* TODO: perlin noise generation parameters */); -bool terrain_system_init(terrain_state* state); -void terrain_system_shutdown(terrain_state* state); -void terrain_system_render_hmap(renderer* rend, terrain_state* state); +// --- Internal -heightmap heightmap_from_image(str8 filepath); -heightmap heightmap_from_perlin(/* TODO: perlin noise generation parameters */); +// TODO: void terrain_system_render_hmap(renderer* rend, terrain_state* state); /** @brief Get the height (the Y component) for a vertex at a particular coordinate in the heightmap */ -f32 heightmap_height_at_xz(heightmap* hmap, f32 x, f32 z); +f32 Heightmap_HeightXZ(Heightmap* hmap, f32 x, f32 z); /** @brief Calculate the normal vector of a vertex at a particular coordinate in the heightmap */ -vec3 heightmap_normal_at_xz(heightmap* hmap, f32 x, f32 z); +Vec3 Heightmap_NormalXZ(Heightmap* hmap, f32 x, f32 z); /** @brief Generate the `geometry_data` for a heightmap ready to be uploaded to the GPU */ -geometry_data geo_heightmap(arena* a, heightmap heightmap); - -// somewhere there will be an easy way to add a heightmap - -// TODO: scene_add_heightmap +Geometry geo_heightmap(arena* a, Heightmap heightmap); |