summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-04-27 16:35:11 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-04-27 16:35:11 +1000
commitfc35df8e999521b8be7c44800f4ff4665df3254a (patch)
tree2acc67b9830e712bef78270c6478c61e184f2047
parent55bb30899899d1e6f34e85d87909d5108d085adb (diff)
heightmap function signatures
-rw-r--r--src/core.h2
-rw-r--r--src/logos/jobs.h4
-rw-r--r--src/maths/primitives.c16
-rw-r--r--src/platform/mutex.c2
-rw-r--r--src/platform/mutex.h12
-rw-r--r--src/platform/thread.h6
-rw-r--r--src/renderer/cleanroom/backend_vulkan.h7
-rw-r--r--src/renderer/cleanroom/ral.h12
-rw-r--r--src/renderer/cleanroom/renderer.h2
-rw-r--r--src/renderer/cleanroom/types.h13
-rw-r--r--src/renderer/render_types.h3
-rw-r--r--src/std/containers/graphs.h7
-rw-r--r--src/std/containers/hashset.h6
-rw-r--r--src/std/containers/hashtable.h6
-rw-r--r--src/systems/physics.h2
-rw-r--r--src/systems/terrain.h37
-rw-r--r--src/systems/text.h2
-rw-r--r--src/transform_hierarchy.h2
18 files changed, 83 insertions, 58 deletions
diff --git a/src/core.h b/src/core.h
index dd5a695..be88c53 100644
--- a/src/core.h
+++ b/src/core.h
@@ -3,8 +3,8 @@
#include "defines.h"
#include "input.h"
#include "ral.h"
-#include "terrain.h"
#include "screenspace.h"
+#include "terrain.h"
#include "text.h"
#include "threadpool.h"
diff --git a/src/logos/jobs.h b/src/logos/jobs.h
index cc2c8fa..ef4eed7 100644
--- a/src/logos/jobs.h
+++ b/src/logos/jobs.h
@@ -1,3 +1,3 @@
/**
- * Common jobs that get run
-*/ \ No newline at end of file
+ * Common jobs that get run
+ */ \ No newline at end of file
diff --git a/src/maths/primitives.c b/src/maths/primitives.c
index 42c51ea..55ff5fc 100644
--- a/src/maths/primitives.c
+++ b/src/maths/primitives.c
@@ -13,20 +13,10 @@ geometry_data geo_create_plane(f32x2 extents) {
vertex_format format = VERTEX_STATIC_3D;
vertex_darray* vertices = vertex_darray_new(4);
- vertex_darray_push(
- vertices,
- (vertex) {.static_3d = {
- .position =
- }}
- );
-
- return (geometry_data) {
- .format = format,
- .vertices =
- .has_indices = true,
- }
-}
+ vertex_darray_push(vertices, (vertex){ .static_3d = { .position = } });
+ return (geometry_data) { .format = format, .vertices =.has_indices = true, }
+}
// OLD
diff --git a/src/platform/mutex.c b/src/platform/mutex.c
index 9735483..2aeb825 100644
--- a/src/platform/mutex.c
+++ b/src/platform/mutex.c
@@ -4,6 +4,6 @@
// TODO: implement in terms of pthreads
#endif
-#if defined (CEL_PLATFORM_WINDOWS)
+#if defined(CEL_PLATFORM_WINDOWS)
// TODO: implement using win32 api
#endif \ No newline at end of file
diff --git a/src/platform/mutex.h b/src/platform/mutex.h
index 0552ea2..a0a4208 100644
--- a/src/platform/mutex.h
+++ b/src/platform/mutex.h
@@ -1,12 +1,12 @@
/**
* @file mutex.h
* @author your name (you@domain.com)
- * @brief
+ * @brief
* @version 0.1
* @date 2024-04-27
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/
#include <stdbool.h>
@@ -16,10 +16,12 @@ cel_mutex mutex_create();
void mutex_destroy(cel_mutex* mutex);
-/** @brief Blocks until the mutex can be acquired. if returns false then an error occurred and can be checked (TODO) */
+/** @brief Blocks until the mutex can be acquired. if returns false then an error occurred and can
+ * be checked (TODO) */
bool mutex_lock(cel_mutex* mutex);
-/** @brief Tries to acquire the mutex like `mutex_lock` but returns immediately if the mutex has already been locked */
+/** @brief Tries to acquire the mutex like `mutex_lock` but returns immediately if the mutex has
+ * already been locked */
bool mutex_try_lock(cel_mutex* mutex);
/** @brief Releases a mutex. If it is already unlocked then does nothing */
diff --git a/src/platform/thread.h b/src/platform/thread.h
index a3560cb..af07d3f 100644
--- a/src/platform/thread.h
+++ b/src/platform/thread.h
@@ -1,12 +1,12 @@
/**
* @file thread.h
* @author your name (you@domain.com)
- * @brief
+ * @brief
* @version 0.1
* @date 2024-04-27
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/
typedef struct cel_thread cel_thread;
diff --git a/src/renderer/cleanroom/backend_vulkan.h b/src/renderer/cleanroom/backend_vulkan.h
index 6798b13..c8d5777 100644
--- a/src/renderer/cleanroom/backend_vulkan.h
+++ b/src/renderer/cleanroom/backend_vulkan.h
@@ -3,7 +3,8 @@
#define GPU_SWAPCHAIN_IMG_COUNT 2
-typedef struct gpu_swapchain {} gpu_swapchain;
+typedef struct gpu_swapchain {
+} gpu_swapchain;
typedef struct gpu_device {
// In Vulkan we store both physical and logical device here
VkPhysicalDevice physical_device;
@@ -13,7 +14,8 @@ typedef struct gpu_device {
VkPhysicalDeviceMemoryProperties memory;
VkCommandPool pool;
} gpu_device;
-typedef struct gpu_pipeline {} gpu_pipeline;
+typedef struct gpu_pipeline {
+} gpu_pipeline;
typedef struct gpu_renderpass {
VkRenderPass vk_handle;
@@ -21,7 +23,6 @@ typedef struct gpu_renderpass {
u32
} gpu_renderpass;
-
typedef struct gpu_cmd_encoder {
VkCommandBuffer cmd_buffer;
} gpu_cmd_encoder; \ No newline at end of file
diff --git a/src/renderer/cleanroom/ral.h b/src/renderer/cleanroom/ral.h
index a1e9929..15eb027 100644
--- a/src/renderer/cleanroom/ral.h
+++ b/src/renderer/cleanroom/ral.h
@@ -5,9 +5,9 @@
* @details API that a graphics backend *must* implement
* @version 0.1
* @date 2024-03-31
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/
#pragma once
@@ -19,8 +19,8 @@ typedef struct gpu_swapchain gpu_swapchain;
typedef struct gpu_device gpu_device;
typedef struct gpu_pipeline gpu_pipeline;
typedef struct gpu_renderpass gpu_renderpass;
-typedef struct gpu_cmd_encoder gpu_cmd_encoder; // Recording
-typedef struct gpu_cmd_buffer gpu_cmd_buffer; // Ready for submission
+typedef struct gpu_cmd_encoder gpu_cmd_encoder; // Recording
+typedef struct gpu_cmd_buffer gpu_cmd_buffer; // Ready for submission
enum pipeline_kind {
GRAPHICS,
@@ -29,8 +29,8 @@ enum pipeline_kind {
typedef struct shader_desc {
const char* debug_name;
- str8 filepath; // where it came from
- str8 glsl; // contents
+ str8 filepath; // where it came from
+ str8 glsl; // contents
} shader_desc;
struct pipeline_desc {
diff --git a/src/renderer/cleanroom/renderer.h b/src/renderer/cleanroom/renderer.h
index 8012b49..ff342b0 100644
--- a/src/renderer/cleanroom/renderer.h
+++ b/src/renderer/cleanroom/renderer.h
@@ -1,7 +1,7 @@
#pragma once
-#include "cleanroom/ral.h"
#include "cleanroom/backend_vulkan.h"
+#include "cleanroom/ral.h"
typedef struct renderer2 {
void* backend_state;
diff --git a/src/renderer/cleanroom/types.h b/src/renderer/cleanroom/types.h
index 98c2e21..b18b5b8 100644
--- a/src/renderer/cleanroom/types.h
+++ b/src/renderer/cleanroom/types.h
@@ -10,7 +10,8 @@ CORE_DEFINE_HANDLE(sampler_handle);
CORE_DEFINE_HANDLE(shader_handle);
CORE_DEFINE_HANDLE(model_handle);
-typedef struct transform_hierarchy {} transform_hierarchy;
+typedef struct transform_hierarchy {
+} transform_hierarchy;
/** @brief Texture Description - used by texture creation functions */
typedef struct texture_desc {
@@ -56,7 +57,12 @@ typedef struct model bp_material; // blinn-phong
#include "maths_types.h"
-typedef enum vertex_format { VERTEX_STATIC_3D, VERTEX_SPRITE, VERTEX_SKINNED, VERTEX_COUNT } vertex_format;
+typedef enum vertex_format {
+ VERTEX_STATIC_3D,
+ VERTEX_SPRITE,
+ VERTEX_SKINNED,
+ VERTEX_COUNT
+} vertex_format;
typedef union vertex {
struct {
@@ -79,7 +85,7 @@ typedef union vertex {
vec3 normal;
vec4i bone_ids; // Integer vector for bone IDs
vec4 bone_weights; // Weight of each bone's influence
- } skinned_3d; /** @brief vertex format for skeletal (animated) geometry in 3D */
+ } skinned_3d; /** @brief vertex format for skeletal (animated) geometry in 3D */
} vertex;
KITC_DECL_TYPED_ARRAY(vertex)
@@ -128,7 +134,6 @@ typedef struct model {
/* ral.h */
-
// command buffer gubbins
/* --- Backends */
diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h
index 387ac81..3bce88f 100644
--- a/src/renderer/render_types.h
+++ b/src/renderer/render_types.h
@@ -76,7 +76,8 @@ typedef struct texture {
// bool is_loaded;
// bool is_uploaded;
// } blinn_phong_material;
-// typedef blinn_phong_material material; // when we start using PBR, this will no longer be the case
+// typedef blinn_phong_material material; // when we start using PBR, this will no longer be the
+// case
// // the default blinn-phong material. MUST be initialised with the function below
// extern material DEFAULT_MATERIAL;
diff --git a/src/std/containers/graphs.h b/src/std/containers/graphs.h
index 47399e9..5dbec97 100644
--- a/src/std/containers/graphs.h
+++ b/src/std/containers/graphs.h
@@ -1,15 +1,14 @@
/**
* @file graphs.h
* @author your name (you@domain.com)
- * @brief
+ * @brief
* @version 0.1
* @date 2024-04-27
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/
-
// Adjacency list backed graphs
// Matrix backed graphs (not as useful) \ No newline at end of file
diff --git a/src/std/containers/hashset.h b/src/std/containers/hashset.h
index f8e7073..d153fd2 100644
--- a/src/std/containers/hashset.h
+++ b/src/std/containers/hashset.h
@@ -1,10 +1,10 @@
/**
* @file hashset.h
* @author your name (you@domain.com)
- * @brief
+ * @brief
* @version 0.1
* @date 2024-04-27
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/ \ No newline at end of file
diff --git a/src/std/containers/hashtable.h b/src/std/containers/hashtable.h
index c93dc19..f5d98e7 100644
--- a/src/std/containers/hashtable.h
+++ b/src/std/containers/hashtable.h
@@ -1,10 +1,10 @@
/**
* @file hashtable.h
* @author your name (you@domain.com)
- * @brief
+ * @brief
* @version 0.1
* @date 2024-04-27
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/ \ No newline at end of file
diff --git a/src/systems/physics.h b/src/systems/physics.h
index 5c96c6e..61d2008 100644
--- a/src/systems/physics.h
+++ b/src/systems/physics.h
@@ -15,7 +15,7 @@ enum collider_type {
/** @brief generic collider structure */
typedef struct physics_collider {
- u64 id; // ? Replace with handle?
+ u64 id; // ? Replace with handle?
enum collider_type shape;
transform transform;
u8 layer;
diff --git a/src/systems/terrain.h b/src/systems/terrain.h
index 96875d9..6558202 100644
--- a/src/systems/terrain.h
+++ b/src/systems/terrain.h
@@ -1,19 +1,46 @@
/**
* @file terrain.h
* @author your name (you@domain.com)
- * @brief
+ * @brief
* @version 0.1
* @date 2024-04-27
- *
+ *
* @copyright Copyright (c) 2024
- *
+ *
*/
+/*
+Future:
+ - Chunked terrain
+ - Dynamic LOD
+*/
+
+#include "cleanroom/types.h"
#include "defines.h"
+#include "maths_types.h"
+#include "mem.h"
typedef struct terrain_state {
-
} terrain_state;
+typedef struct heightmap {
+ u32x2 size;
+ void* image_data;
+} heightmap;
+
bool terrain_system_init(terrain_state* state);
-void terrain_system_shutdown(terrain_state* state); \ No newline at end of file
+void terrain_system_shutdown(terrain_state* state);
+void terrain_system_render_hmap(renderer* rend, terrain_state* state);
+
+heightmap heightmap_from_image(const char* filepath);
+heightmap heightmap_from_perlin(/* TODO: perlin noise generation parameters */);
+
+/** @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);
+
+/** @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);
+
+/** @brief Generate the `geometry_data` for a heightmap ready to be uploaded to the GPU */
+geometry_data geo_heightmap(arena* a, heightmap heightmap); \ No newline at end of file
diff --git a/src/systems/text.h b/src/systems/text.h
index 4fac0b8..dc396f0 100644
--- a/src/systems/text.h
+++ b/src/systems/text.h
@@ -8,8 +8,8 @@
#include "cleanroom/types.h"
#include "darray.h"
#include "defines.h"
-#include "render_types.h"
#include "ral.h"
+#include "render_types.h"
struct core;
diff --git a/src/transform_hierarchy.h b/src/transform_hierarchy.h
index d77b846..0921c19 100644
--- a/src/transform_hierarchy.h
+++ b/src/transform_hierarchy.h
@@ -4,8 +4,8 @@
#pragma once
#include "maths_types.h"
-#include "render_types.h"
#include "ral.h"
+#include "render_types.h"
#define MAX_TF_NODE_CHILDREN \
32 /** TEMP: Make it simpler to manage children in `transform_node`s */