diff options
Diffstat (limited to 'src/systems/terrain.h')
-rw-r--r-- | src/systems/terrain.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/systems/terrain.h b/src/systems/terrain.h index a38e45e..2e05a14 100644 --- a/src/systems/terrain.h +++ b/src/systems/terrain.h @@ -23,12 +23,14 @@ typedef struct Heightmap { Str8 filepath; u32x2 pixel_dimensions; void* image_data; + u32 num_channels; bool is_uploaded; } Heightmap; typedef struct Terrain_Storage { // arena terrain_allocator; u32x2 grid_dimensions; + f32 grid_scale; u32 num_vertices; Heightmap heightmap; // NULL = no heightmap GPU_Renderpass* hmap_renderpass; @@ -37,6 +39,7 @@ typedef struct Heightmap { bool hmap_loaded; BufferHandle vertex_buffer; BufferHandle index_buffer; + u32 indices_count; } Terrain_Storage; // --- Public API @@ -46,7 +49,7 @@ PUB void Terrain_Draw( Terrain_Storage* storage); // NOTE: For now it renders directly to main framebuffer /** @brief Sets the active heightmap to be rendered and collided against. */ -PUB void Terrain_LoadHeightmap(Terrain_Storage* storage, Heightmap hmap, bool free_on_upload); +PUB void Terrain_LoadHeightmap(Terrain_Storage* storage, Heightmap hmap, f32 grid_scale, bool free_on_upload); PUB Heightmap Heightmap_FromImage(Str8 filepath); PUB Heightmap Heightmap_FromPerlin(/* TODO: perlin noise generation parameters */); @@ -58,10 +61,10 @@ PUB bool Terrain_IsActive(); // checks whether we have a loaded heightmap and i /** @brief Get the height (the Y component) for a vertex at a particular coordinate in the heightmap */ -f32 Heightmap_HeightXZ(Heightmap* hmap, f32 x, f32 z); +f32 Heightmap_HeightXZ(const Heightmap* hmap, u32 x, u32 z); /** @brief Calculate the normal vector of a vertex at a particular coordinate in the heightmap */ -Vec3 Heightmap_NormalXZ(Heightmap* hmap, f32 x, f32 z); +Vec3 Heightmap_NormalXZ(const Heightmap* hmap, f32 x, f32 z); // /** @brief Generate the `geometry_data` for a heightmap ready to be uploaded to the GPU */ // Geometry geo_heightmap(arena* a, Heightmap heightmap); |