diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-30 15:46:38 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-30 15:46:38 +1000 |
commit | 4505fb6585885866ff9a76f76c00ed727d3bb818 (patch) | |
tree | 5a6fb84426827e818513632cf9bde8dca0300b4b | |
parent | bfae2fd3f7b367709f21a8b4fccab107e2e81797 (diff) |
wip
-rw-r--r-- | bindgen/rust/src/lib.rs | 10 | ||||
-rw-r--r-- | bindgen/rust/src/prelude.rs | 11 | ||||
-rw-r--r-- | bindgen/rust/src/ral.rs | 2 | ||||
-rw-r--r-- | include/amalgamation.h | 3 | ||||
-rw-r--r-- | src/core/core.c | 6 | ||||
-rw-r--r-- | src/core/core.h | 1 | ||||
-rw-r--r-- | src/maths/maths.c | 8 | ||||
-rw-r--r-- | src/maths/maths.h | 8 |
8 files changed, 34 insertions, 15 deletions
diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs index c8e56df..cfb999c 100644 --- a/bindgen/rust/src/lib.rs +++ b/bindgen/rust/src/lib.rs @@ -21,14 +21,14 @@ use serde::{Deserialize, Serialize}; /// Wrapper around a string that is the path to a gltf model **relative** to the configured /// `ASSETS` folder -#[derive(Debug, Serialize, Deserialize)] -pub struct ModelPath(String); +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ModelPath(pub String); /// #[derive(Debug, Serialize, Deserialize)] pub struct ModelNode { - model_path: ModelPath, - transform: Transform, + pub model_path: ModelPath, + pub transform: Transform, } /// Scene that can be saved and loaded from disk @@ -63,4 +63,4 @@ pub enum Light { Point(ffi::PointLight), Directional(ffi::DirectionalLight), // Spot(ffi::Spotlight) -} +}
\ No newline at end of file diff --git a/bindgen/rust/src/prelude.rs b/bindgen/rust/src/prelude.rs index 097239a..c81fbe0 100644 --- a/bindgen/rust/src/prelude.rs +++ b/bindgen/rust/src/prelude.rs @@ -1,4 +1,15 @@ +/// --- maths types pub use celeritas_sys::Mat4; pub use celeritas_sys::Vec2; pub use celeritas_sys::Vec3; pub use celeritas_sys::Vec4; + +// --- handles +pub use celeritas_sys::BufferHandle; +pub use celeritas_sys::TextureHandle; +pub use celeritas_sys::MeshHandle; +pub use celeritas_sys::MaterialHandle; +pub use celeritas_sys::ModelHandle; +pub use celeritas_sys::PipelineHandle; +pub use celeritas_sys::RenderpassHandle; +pub use celeritas_sys::PipelineLayoutHandle;
\ No newline at end of file diff --git a/bindgen/rust/src/ral.rs b/bindgen/rust/src/ral.rs index f9c44e4..5568954 100644 --- a/bindgen/rust/src/ral.rs +++ b/bindgen/rust/src/ral.rs @@ -1,7 +1,7 @@ //! Wrapper around the RAL code in celeritas-core use celeritas_sys::{ - BufferHandle, GPU_Buffer, GPU_CmdEncoder, GPU_CmdEncoder_BeginRender, GPU_CmdEncoder_EndRender, GPU_GetDefaultEncoder + BufferHandle, GPU_CmdEncoder, GPU_CmdEncoder_BeginRender, GPU_CmdEncoder_EndRender, GPU_GetDefaultEncoder }; pub struct FrameRenderEncoder(*mut GPU_CmdEncoder); diff --git a/include/amalgamation.h b/include/amalgamation.h index 03e1c95..85bf5b2 100644 --- a/include/amalgamation.h +++ b/include/amalgamation.h @@ -15,4 +15,5 @@ #include "maths_types.h" #include "maths.h" #include "skybox.h" -#include "shadows.h"
\ No newline at end of file +#include "shadows.h" +#include "loaders.h"
\ No newline at end of file diff --git a/src/core/core.c b/src/core/core.c index fffb43d..b18b807 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -78,4 +78,8 @@ 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; }
\ No newline at end of file +struct Renderer* Core_GetRenderer(Core* core) { return core->renderer; } + +Model* Model_Get(ModelHandle h) { + return Model_pool_get(&g_core.models, h); +}
\ No newline at end of file diff --git a/src/core/core.h b/src/core/core.h index 54e6ec3..86f5b01 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -10,6 +10,7 @@ TYPED_POOL(Model, Model) #define MODEL_GET(h) (Model_pool_get(&g_core.models, h)) +Model* Model_Get(ModelHandle h); typedef struct GLFWwindow GLFWwindow; diff --git a/src/maths/maths.c b/src/maths/maths.c index adeee3e..aedee76 100644 --- a/src/maths/maths.c +++ b/src/maths/maths.c @@ -24,4 +24,12 @@ c_static_inline Vec3 vec3_cross(Vec3 a, Vec3 b) { Mat4 mat4_ident() { return (Mat4){ .data = { 1.0, 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.0 } }; +} + +Mat4 transform_to_mat(Transform *tf) { + Mat4 scale = mat4_scale(tf->scale); + Mat4 rotation = mat4_rotation(tf->rotation); + Mat4 translation = mat4_translation(tf->position); + return mat4_mult(translation, mat4_mult(rotation, scale)); + // return mat4_mult(mat4_mult(scale, rotation), translation); }
\ No newline at end of file diff --git a/src/maths/maths.h b/src/maths/maths.h index 5055637..0b3760e 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -311,13 +311,7 @@ static Transform transform_create(Vec3 pos, Quat rot, f32 scale) { return (Transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = true }; } -static Mat4 transform_to_mat(Transform *tf) { - Mat4 scale = mat4_scale(tf->scale); - Mat4 rotation = mat4_rotation(tf->rotation); - Mat4 translation = mat4_translation(tf->position); - return mat4_mult(translation, mat4_mult(rotation, scale)); - // return mat4_mult(mat4_mult(scale, rotation), translation); -} + Mat4 transform_to_mat(Transform *tf); // --- Sizing asserts |