diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-12 00:15:33 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-12 00:15:33 +1000 |
commit | 72b8d26fcfcee36ca67f963b9c6a4b616e2d5d4d (patch) | |
tree | 76ab2c18db5a834c6282ab4e2afa2db33f70be27 /src | |
parent | a8f98ddcf5ddeb3588492f4ad8f9a289147ad7ec (diff) |
scale is a vec3 now instead of float.
Diffstat (limited to 'src')
-rw-r--r-- | src/collision.c | 9 | ||||
-rw-r--r-- | src/collision.h | 20 | ||||
-rw-r--r-- | src/core/core.c | 4 | ||||
-rw-r--r-- | src/maths/maths.h | 10 | ||||
-rw-r--r-- | src/maths/maths_types.h | 2 | ||||
-rw-r--r-- | src/physics.h | 23 | ||||
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.c | 3 | ||||
-rw-r--r-- | src/render/immdraw.c | 10 |
8 files changed, 49 insertions, 32 deletions
diff --git a/src/collision.c b/src/collision.c new file mode 100644 index 0000000..81cbcfc --- /dev/null +++ b/src/collision.c @@ -0,0 +1,9 @@ +#include "immdraw.h" +#include "maths.h" +#include "maths_types.h" +#include "physics.h" + +PUB void Debug_DrawOBB(OBB obb) { + Transform t = transform_create(obb.center, obb.rotation, vec3_sub(obb.bbox.max, obb.bbox.min)); + Immdraw_Cuboid(t, vec4(0.0, 0.8, 0.1, 1.0), true); +} diff --git a/src/collision.h b/src/collision.h deleted file mode 100644 index 4ac9ec3..0000000 --- a/src/collision.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "geometry.h" - -enum ColliderType { - CuboidCollider, - SphereCollider, -}; - -/** @brief generic collider structure */ -typedef struct Collider { - u64 id; // ? Replace with handle? - enum ColliderType shape; - union collider_data { - Cuboid cuboid; - Sphere sphere; - } geometry; - Transform transform; - u8 layer; - bool on_ground; -} Collider; diff --git a/src/core/core.c b/src/core/core.c index af7daeb..64f59f3 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -76,8 +76,6 @@ Core* get_global_core() { return &g_core; } GLFWwindow* Core_GetGlfwWindowPtr(Core* core) { return g_core.window; } -struct Renderer* Core_GetRenderer(Core* core) { - return core->renderer; -} +struct Renderer* Core_GetRenderer(Core* core) { return core->renderer; } Model* Model_Get(ModelHandle h) { return Model_pool_get(&g_core.models, h); } diff --git a/src/maths/maths.h b/src/maths/maths.h index 9e71f79..fc23517 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -147,11 +147,11 @@ static Mat4 mat4_translation(Vec3 position) { return out_matrix; } -static Mat4 mat4_scale(f32 scale) { +static Mat4 mat4_scale(Vec3 scale) { Mat4 out_matrix = mat4_ident(); - out_matrix.data[0] = scale; - out_matrix.data[5] = scale; - out_matrix.data[10] = scale; + out_matrix.data[0] = scale.x; + out_matrix.data[5] = scale.y; + out_matrix.data[10] = scale.z; return out_matrix; } @@ -307,7 +307,7 @@ static inline Mat4 mat4_look_at(Vec3 position, Vec3 target, Vec3 up) { .scale = 1.0, \ .is_dirty = false }) -static Transform transform_create(Vec3 pos, Quat rot, f32 scale) { +static Transform transform_create(Vec3 pos, Quat rot, Vec3 scale) { return (Transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = true }; } diff --git a/src/maths/maths_types.h b/src/maths/maths_types.h index 2f84774..ef1fe4a 100644 --- a/src/maths/maths_types.h +++ b/src/maths/maths_types.h @@ -53,7 +53,7 @@ typedef Bbox_3D Aabb_3D; typedef struct Transform { Vec3 position; Quat rotation; - f32 scale; + Vec3 scale; bool is_dirty; } Transform; diff --git a/src/physics.h b/src/physics.h index e0e3b89..3485d1b 100644 --- a/src/physics.h +++ b/src/physics.h @@ -20,4 +20,25 @@ physics_world physics_init(physics_settings settings); void physics_shutdown(physics_world* phys_world); /** @brief perform one or more simulation steps */ -void physics_system_update(physics_world* phys_world, f64 deltatime);
\ No newline at end of file +void physics_system_update(physics_world* phys_world, f64 deltatime); + +// enum ColliderType { +// CuboidCollider, +// SphereCollider, +// }; + +/** @brief Oriented Bounding Box */ +typedef struct OBB { + Vec3 center; + Bbox_3D bbox; + Quat rotation; +} OBB; + +PUB void Debug_DrawOBB(OBB obb); + +/** @brief generic collider structure */ +typedef struct Collider { + u64 id; // ? Replace with handle? + OBB shape; // NOTE: We're only supporting the one collider type for now + bool on_ground; +} Collider; diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index 97fd362..3822220 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -57,8 +57,7 @@ bool GPU_Backend_Init(const char* window_name, struct GLFWwindow* window, } // All of these are no-ops in OpenGL -void GPU_Backend_Shutdown() { /* TODO */ -} +void GPU_Backend_Shutdown() { /* TODO */ } bool GPU_Device_Create(GPU_Device* out_device) { return true; } void GPU_Device_Destroy(GPU_Device* device) {} bool GPU_Swapchain_Create(GPU_Swapchain* out_swapchain) { return true; } diff --git a/src/render/immdraw.c b/src/render/immdraw.c index cb823d3..142087a 100644 --- a/src/render/immdraw.c +++ b/src/render/immdraw.c @@ -86,6 +86,16 @@ void Immdraw_Primitive(Transform tf, f32 size, Vec4 colour, bool wireframe, Mesh // bind pipeline GPU_EncodeBindPipeline(enc, imm->colour_pipeline); + // TODO: implement wireframe in other apis +#if defined(CEL_REND_BACKEND_OPENGL) +#include <glad/glad.h> + if (wireframe) { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } else { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } +#endif + // update uniforms ImmediateUniforms uniforms = { .model = transform_to_mat(&tf), |