diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-18 12:55:02 +1100 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-18 12:55:02 +1100 |
commit | f5190745aed65b231e380fa3f25fce46d220dcbc (patch) | |
tree | f363f5c4b8e1e182609702c5a78e23da0a5b4558 | |
parent | de17d20f1848774f854903dcce40cd1e33b1cad9 (diff) |
removing some outdated docs files
-rw-r--r-- | TODO.md | 4 | ||||
-rw-r--r-- | archive/xmake.lua (renamed from xmake.lua) | 0 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/src/lib.rs | 43 | ||||
-rw-r--r-- | docs/getting-started.md | 7 | ||||
-rw-r--r-- | docs/index.md | 2 | ||||
-rw-r--r-- | docs/project-layout.md | 32 | ||||
-rw-r--r-- | include/celeritas.h | 95 | ||||
-rw-r--r-- | src/camera.c | 15 | ||||
-rw-r--r-- | src/mem.c | 2 | ||||
-rw-r--r-- | src/scene.c | 26 |
10 files changed, 142 insertions, 84 deletions
@@ -4,9 +4,9 @@ - ~~compile shared lib~~ - compile and run tests - compile example -- [ ] Consolidate down to a handful of examples +- [x] Consolidate down to a handful of examples - [x] Get rid of doxygen - [ ] make format - [ ] Move to Vulkan-first rendering -- [ ] Build in pipeline (needs vulkan) +- [ ] Build in CI pipeline (needs vulkan) - [ ] Incorporate vma
\ No newline at end of file diff --git a/xmake.lua b/archive/xmake.lua index 3c05a70..3c05a70 100644 --- a/xmake.lua +++ b/archive/xmake.lua diff --git a/bindgen/rust/celeritas-sys/src/lib.rs b/bindgen/rust/celeritas-sys/src/lib.rs index 3d877a4..5b65f5e 100644 --- a/bindgen/rust/celeritas-sys/src/lib.rs +++ b/bindgen/rust/celeritas-sys/src/lib.rs @@ -6,28 +6,29 @@ use serde::{Deserialize, Serialize}; include!(concat!(env!("OUT_DIR"), "/bindings.rs")); -// // --- Conversions -// pub mod conversions { -// use crate::{Mat4, Vec3, Vec4}; +// --- Conversions +pub mod conversions { + use crate::{mat4, vec3, vec4}; -// impl From<Vec3> for glam::Vec3 { -// fn from(v: Vec3) -> Self { -// Self { -// x: v.x, -// y: v.y, -// z: v.z, -// } -// } -// } -// impl From<glam::Vec3> for Vec3 { -// fn from(v: glam::Vec3) -> Self { -// Self { -// x: v.x, -// y: v.y, -// z: v.z, -// } -// } -// } + impl From<vec3> for glam::Vec3 { + fn from(v: vec3) -> Self { + Self { + x: v.x, + y: v.y, + z: v.z, + } + } + } + impl From<glam::Vec3> for vec3 { + fn from(v: glam::Vec3) -> Self { + Self { + x: v.x, + y: v.y, + z: v.z, + } + } + } +} // impl From<Vec4> for glam::Vec4 { // fn from(v: Vec4) -> Self { diff --git a/docs/getting-started.md b/docs/getting-started.md deleted file mode 100644 index 0baf21c..0000000 --- a/docs/getting-started.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Getting up and running ---- - -The main build tool we use is [xmake](https://xmake.io/#/getting_started) so installing that is the main prerequisite. - -Once that is installed you *should* be able to simply run `xmake build` in the top-level directory.
\ No newline at end of file diff --git a/docs/index.md b/docs/index.md index fd5b8f6..fb3b6e2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -20,7 +20,7 @@ Celeritas is the original Latin word for celerity that the English is derived fr ## Feature Set -[See here (README)](https://github.com/omnisci3nce/celeritas-core/blob/winter-cleaning/README.md#todo) +[See here (README)](https://github.com/omnisci3nce/celeritas-core/blob/masterREADME.md#goals) ## Getting started diff --git a/docs/project-layout.md b/docs/project-layout.md deleted file mode 100644 index 9a33e8f..0000000 --- a/docs/project-layout.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Project Structure ---- - -``` -assets/ - shaders and bundled assets for examples (must be licensed open) -bindgen/ - bindings generation -deps/ - third-party dependencies -docs/ - these docs you're reading now that get built with mkdocs -src/ - core/ - core game engine facilities - logos/ - - maths/ - platform/ - ral/ - render/ - resources/ - std/ - systems/ - ui/ -``` - - -#### Core - -Core holds specifically functionality vital to making games or 3D applications. Contrast this with `std` which contains -code that could form the base layer of almost any software out there. - -#### Std - -Data structures, algorithms, memory management, etc - all code here forms a foundation for everything above it and can conceivably -be reused in non-game applications.
\ No newline at end of file diff --git a/include/celeritas.h b/include/celeritas.h index 51a9a3d..6b8a673 100644 --- a/include/celeritas.h +++ b/include/celeritas.h @@ -1,5 +1,13 @@ #pragma once +/* + Common abbreviations: + buf = buffer + tex = texture + desc = description + idx = index +*/ + // Standard library includes #include <assert.h> #include <math.h> @@ -407,7 +415,7 @@ typedef struct shader_function { shader_stage stage; } shader_function; -typedef enum cull_mode { CULL_BACK_FACE, CULL_FRONT_FACE } cull_mode; +typedef enum cull_mode { Cull_BackFace, Cull_FrontFace } cull_mode; typedef struct gfx_pipeline_desc { const char* label; @@ -476,9 +484,9 @@ typedef struct u32_darray u32_darray; // --- Base Renderer types -DEFINE_HANDLE(MeshHandle); -DEFINE_HANDLE(MaterialHandle); -DEFINE_HANDLE(ModelHandle); +DEFINE_HANDLE(mesh_handle); +DEFINE_HANDLE(material_handle); +DEFINE_HANDLE(model_handle); typedef struct geometry { vertex_desc vertex_format; @@ -487,17 +495,30 @@ typedef struct geometry { u32_darray* indices; } geometry; +typedef u32 joint_idx; +typedef struct armature { +} armature; + +/** @brief Mesh data that has been uploaded to GPU and is ready to be rendered each frame + Gets stored in a pool */ typedef struct mesh { buf_handle vertex_buffer; buf_handle index_buffer; - MaterialHandle material; - geometry geometry; - // bool is_skinned; // false = its static - // Armature armature; - // bool is_uploaded; // has the data been uploaded to the GPU + // todo: material? + geometry geo; // the originating mesh data + const armature* skinning_data; } mesh; -// --- Render primitives +typedef struct draw_mesh_cmd { + mesh_handle mesh; + mat4 transform; + vec3 bounding_sphere_center; + f32 bounding_sphere_radius; + const armature* skinning_data; // NULL = static mesh + bool cast_shadows; +} draw_mesh_cmd; + +// --- Geometry/Mesh primitives geometry geo_plane(f32 x_scale, f32 z_scale, u32 tiling_u, u32 tiling_v); geometry geo_cuboid(f32 x_scale, f32 y_scale, f32 z_scale); @@ -505,31 +526,33 @@ geometry geo_cylinder(f32 radius, f32 height, u32 resolution); geometry geo_cone(f32 radius, f32 height, u32 resolution); geometry geo_uv_sphere(f32 radius, u32 north_south_lines, u32 east_west_lines); geometry geo_ico_sphere(f32 radius, f32 n_subdivisions); +void geo_scale_uniform(geometry* geo, f32 scale); +void geo_scale_xyz(geometry* geo, vec3 scale_xyz); // --- Renderer // void renderer_init(renderer* rend); // void renderer_shutdown(renderer* rend); -// --- Scene / Transform Hierarchy - -// --- Gameplay - typedef struct camera { vec3 position; - quat orientation; + // TODO: move to using a quaternion for the camera's orientation - need to update + // how the view transformation matrix is calculated + vec3 forwards; + vec3 up; f32 fov; } camera; -mat4 camera_view_proj(camera); - -// --- Reference Renderer +/** @brief calculates the view and projection matrices for a camera */ +mat4 camera_view_proj(camera camera, f32 lens_height, f32 lens_width, mat4* out_view, mat4* out_proj); // TODO: Filament PBR model -// --- Game and model data +// --- Scene / Transform Hierarchy -DEFINE_HANDLE(model_handle); +// --- Gameplay + +// --- Game and model data typedef struct model { } model; @@ -538,8 +561,40 @@ model_handle model_load_from_gltf(const char* path); // --- Animation +typedef enum keyframe_kind { Keyframe_Rotation, Keyframe_Translation, Keyframe_Scale, Keyframe_Weights } keyframe_kind; + +const char* keyframe_kind_strings[4] = { "ROTATION", "TRANSLATION", "SCALE", "WEIGHTS" }; + +typedef union keyframe { + quat rotation; + vec3 translation; + vec3 scale; + f32 weights[4]; +} keyframe; + +typedef struct keyframes { + keyframe_kind kind; + keyframe* values; + size_t n_frames; +} keyframes; + +typedef enum interpolation { + Interpolation_Step, + Interpolation_Linear, + Interpolation_Cubic +} interpolation; + +typedef struct animation_spline { + f32* timestamps; + size_t n_timestamps; + keyframes frames; +} animation_spline; + // Compute shader approach so we only need one kind of vertex format +// --- Input + + // --- Collisions // --- Physics diff --git a/src/camera.c b/src/camera.c new file mode 100644 index 0000000..79f9c19 --- /dev/null +++ b/src/camera.c @@ -0,0 +1,15 @@ +#include <celeritas.h> + +mat4 camera_view_proj(camera camera, f32 lens_height, f32 lens_width, mat4* out_view, mat4* out_proj) { + mat4 projection_matrix = mat4_perspective(camera.fov, lens_width / lens_height, 0.1, 1000.0); + // TODO: store near/far on camera rather than hard-coding here. + + vec3 camera_direction = vec3_add(camera.position, camera.forwards); + mat4 view_matrix = mat4_look_at(camera.position, camera_direction, camera.up); + if (out_view) + *out_view = view_matrix; + if (out_proj) + *out_proj = projection_matrix; + + return mat4_mult(view_matrix, projection_matrix); +}
\ No newline at end of file @@ -1,7 +1,7 @@ #include <celeritas.h> void_pool void_pool_create(void* storage, const char* debug_label, u64 capacity, u64 entry_size) { - size_t memory_requirements = capacity * entry_size; + size_t _memory_requirements = capacity * entry_size; // void* backing_buf = arena_alloc(a, memory_requirements); assert(entry_size >= sizeof(void_pool_header)); // TODO: create my own assert with error message diff --git a/src/scene.c b/src/scene.c new file mode 100644 index 0000000..fa4d9b5 --- /dev/null +++ b/src/scene.c @@ -0,0 +1,26 @@ +/** + * @file scene.c + * @author your name (you@domain.com) + * @brief + * @version 0.1 + * @date 2024-10-18 + * + * @copyright Copyright (c) 2024 + * + */ +#include <celeritas.h> + +// Retained mode scene tree that handles performant transform propagation, and allows systems, or other languages via bindings, to +// manipulate rendering/scene data without *owning* said data. + +typedef struct scene_tree_node { + const char* label; +} scene_tree_node; + +DEFINE_HANDLE(scene_node_handle); +TYPED_POOL(scene_tree_node, scene_node); + +typedef struct render_scene_tree { +} render_scene_tree; + +// What kind of operations and mutations can we perform on the tree? |