summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-05 12:48:05 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-05 12:48:05 +1000
commitdfb6adbcbcc7d50b770b6d5ea82efdd8f8c32e25 (patch)
treea470b91a90716d7ea46fde53ed395449c24583a2 /src/core
parent54354e32c6498cc7f8839ab4deb1208d37216cc5 (diff)
delete documentation workflow
Diffstat (limited to 'src/core')
-rw-r--r--src/core/README.md3
-rw-r--r--src/core/animation.c0
-rw-r--r--src/core/camera.c90
-rw-r--r--src/core/camera.h39
-rw-r--r--src/core/core.c81
-rw-r--r--src/core/core.h43
-rw-r--r--src/core/input.c0
-rw-r--r--src/core/triggers.h17
-rw-r--r--src/core/vfs.h38
9 files changed, 0 insertions, 311 deletions
diff --git a/src/core/README.md b/src/core/README.md
deleted file mode 100644
index 19cc1d0..0000000
--- a/src/core/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Core
-
-Core engine facilities
diff --git a/src/core/animation.c b/src/core/animation.c
deleted file mode 100644
index e69de29..0000000
--- a/src/core/animation.c
+++ /dev/null
diff --git a/src/core/camera.c b/src/core/camera.c
deleted file mode 100644
index 77ddad6..0000000
--- a/src/core/camera.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#include "camera.h"
-
-#include "input.h"
-#include "keys.h"
-#include "maths.h"
-
-#define CAMERA_SPEED 0.2
-#define CAMERA_SENSITIVITY 0.5
-
-Camera Camera_Create(Vec3 pos, Vec3 front, Vec3 up, f32 fov) {
- Camera c = { .position = pos, .front = front, .up = up, .fov = fov };
- return c;
-}
-
-Mat4 Camera_ViewProj(Camera* c, f32 lens_height, f32 lens_width, Mat4* out_view, Mat4* out_proj) {
- Mat4 proj = mat4_perspective(c->fov, lens_width / lens_height, 0.1, 1000.0);
- Vec3 camera_direction = vec3_add(c->position, c->front);
- Mat4 view = mat4_look_at(c->position, camera_direction, c->up);
- if (out_view) {
- *out_view = view;
- }
- if (out_proj) {
- *out_proj = proj;
- }
- return mat4_mult(view, proj);
-}
-
-void FlyCamera_Update(Camera* camera) {
- static f32 yaw = 0.0;
- static f32 pitch = 0.0;
-
- // Keyboard
- f32 speed = CAMERA_SPEED;
- Vec3 horizontal = vec3_cross(camera->front, camera->up);
- if (key_is_pressed(KEYCODE_A) || key_is_pressed(KEYCODE_KEY_LEFT)) {
- Vec3 displacement = vec3_mult(horizontal, -speed);
- camera->position = vec3_add(camera->position, displacement);
- }
- if (key_is_pressed(KEYCODE_D) || key_is_pressed(KEYCODE_KEY_RIGHT)) {
- Vec3 displacement = vec3_mult(horizontal, speed);
- camera->position = vec3_add(camera->position, displacement);
- }
- if (key_is_pressed(KEYCODE_W) || key_is_pressed(KEYCODE_KEY_UP)) {
- Vec3 displacement = vec3_mult(camera->front, speed);
- camera->position = vec3_add(camera->position, displacement);
- }
- if (key_is_pressed(KEYCODE_S) || key_is_pressed(KEYCODE_KEY_DOWN)) {
- Vec3 displacement = vec3_mult(camera->front, -speed);
- camera->position = vec3_add(camera->position, displacement);
- }
- if (key_is_pressed(KEYCODE_Q)) {
- Vec3 displacement = vec3_mult(camera->up, speed);
- camera->position = vec3_add(camera->position, displacement);
- }
- if (key_is_pressed(KEYCODE_E)) {
- Vec3 displacement = vec3_mult(camera->up, -speed);
- camera->position = vec3_add(camera->position, displacement);
- }
-
- // Mouse
- if (MouseBtn_Held(MOUSEBTN_LEFT)) {
- mouse_state mouse = Input_GetMouseState();
- // printf("Delta x: %d Delta y %d\n",mouse.x_delta, mouse.y_delta );
-
- f32 x_offset = mouse.x_delta;
- f32 y_offset = -mouse.y_delta;
-
- f32 sensitivity = CAMERA_SENSITIVITY; // change this value to your liking
- x_offset *= sensitivity;
- y_offset *= sensitivity;
-
- yaw += x_offset;
- pitch += y_offset;
-
- // make sure that when pitch is out of bounds, screen doesn't get flipped
- if (pitch > 89.0f) pitch = 89.0f;
- if (pitch < -89.0f) pitch = -89.0f;
-
- Vec3 front;
- front.x = cos(deg_to_rad(yaw) * cos(deg_to_rad(pitch)));
- front.y = sin(deg_to_rad(pitch));
- front.z = sin(deg_to_rad(yaw)) * cos(deg_to_rad(pitch));
- front = vec3_normalise(front);
- camera->front.x = front.x;
- camera->front.y = front.y;
- camera->front.z = front.z;
- }
-
- // TODO: Right mouse => pan in screen space
-}
diff --git a/src/core/camera.h b/src/core/camera.h
deleted file mode 100644
index 4300f87..0000000
--- a/src/core/camera.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#include "defines.h"
-#include "maths_types.h"
-
-// TODO: swap to position + quaternion
-
-typedef struct Camera {
- Vec3 position;
- Vec3 front;
- Vec3 up;
- f32 fov;
-} Camera;
-
-/** @brief create a camera */
-PUB Camera Camera_Create(Vec3 pos, Vec3 front, Vec3 up, f32 fov);
-
-/**
- * @brief Get 3D camera transform matrix
- * @param out_view optionally stores just the view matrix
- * @param out_proj optionally stores just the projection matrix
- * @returns the camera's view projection matrix pre-multiplied
- */
-PUB Mat4 Camera_ViewProj(Camera* c, f32 lens_height, f32 lens_width, Mat4* out_view,
- Mat4* out_proj);
-
-/** @brief Get 2D camera transform matrix */
-PUB Mat4 Camera_View2D(Camera* c); // TODO: 2D cameras
-
-struct Input_State;
-
-PUB void FlyCamera_Update(Camera* camera);
-
-// TODO: (HIGH) Basic reusable camera controls
-/*
-Right click + move = pan
-Left click = orbit camera
-WASD = forward/backward/left/right
-*/
diff --git a/src/core/core.c b/src/core/core.c
deleted file mode 100644
index 64f59f3..0000000
--- a/src/core/core.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "core.h"
-
-#include <stdlib.h>
-
-#include "glfw3.h"
-#include "input.h"
-#include "keys.h"
-#include "log.h"
-#include "mem.h"
-#include "render.h"
-#include "render_types.h"
-
-// These are only the initial window dimensions
-#define SCR_WIDTH 1000
-#define SCR_HEIGHT 1000
-
-Core g_core; /** @brief global `Core` that other files can use */
-
-/** @brief Gets the global `Core` singleton */
-inline Core* GetCore() { return &g_core; }
-
-void Core_Bringup(const char* window_name, struct GLFWwindow* optional_window) {
- INFO("Initiate Core bringup");
- memset(&g_core, 0, sizeof(Core));
-
- RendererConfig conf = { .window_name = window_name,
- .scr_width = SCR_WIDTH,
- .scr_height = SCR_HEIGHT,
- .clear_colour = (Vec3){ .08, .08, .1 } };
-
- g_core.renderer = malloc(Renderer_GetMemReqs());
-
- // Initialise all subsystems
-
- // renderer config, renderer ptr, ptr to store a window, and optional preexisting glfw window
- if (!Renderer_Init(conf, g_core.renderer, &g_core.window, optional_window)) {
- // FATAL("Failed to start renderer");
- ERROR_EXIT("Failed to start renderer\n");
- }
- if (optional_window != NULL) {
- g_core.window = optional_window;
- }
-
- if (!Input_Init(&g_core.input, g_core.window)) {
- // the input system needs the glfw window which is created by the renderer
- // hence the order here is important
- ERROR_EXIT("Failed to start input system\n");
- }
-
- size_t model_data_max = 1024 * 1024 * 1024;
- arena model_arena = arena_create(malloc(model_data_max), model_data_max);
-
- Model_pool model_pool = Model_pool_create(&model_arena, 256, sizeof(Model));
- g_core.models = model_pool;
- INFO("Created model pool allocator");
-}
-
-void Core_Shutdown() {
- Input_Shutdown(&g_core.input);
- Renderer_Shutdown(g_core.renderer);
- free(g_core.renderer);
-}
-
-bool ShouldExit() {
- return key_just_released(KEYCODE_ESCAPE) || glfwWindowShouldClose(g_core.window);
-}
-
-void Frame_Begin() {
- Input_Update(&g_core.input);
- Render_FrameBegin(g_core.renderer);
-}
-void Frame_Draw() {}
-void Frame_End() { Render_FrameEnd(g_core.renderer); }
-
-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; }
-
-Model* Model_Get(ModelHandle h) { return Model_pool_get(&g_core.models, h); }
diff --git a/src/core/core.h b/src/core/core.h
deleted file mode 100644
index 14ba65d..0000000
--- a/src/core/core.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma once
-
-#include "input.h"
-#include "mem.h"
-#include "render_types.h"
-#include "screenspace.h"
-#include "terrain.h"
-#include "text.h"
-
-TYPED_POOL(Model, Model)
-#define MODEL_GET(h) (Model_pool_get(&g_core.models, h))
-Model* Model_Get(ModelHandle h);
-
-typedef struct GLFWwindow GLFWwindow;
-
-typedef struct Core {
- const char* app_name;
- GLFWwindow* window;
- Renderer* renderer;
- Input_State input;
- // Model_pool models;
-} Core;
-extern Core g_core;
-
-struct Renderer;
-
-Core* get_global_core();
-
-/**
- @brief Throws error if the core cannot be instantiated
- @param [in] optional_window - Leave NULL if you want Celeritas to instantiate its own window with
- GLFW, if you want to provide the glfw window then pass it in here.
-*/
-void Core_Bringup(const char* window_name, GLFWwindow* optional_window);
-void Core_Shutdown();
-bool ShouldExit();
-
-GLFWwindow* Core_GetGlfwWindowPtr(Core* core);
-struct Renderer* Core_GetRenderer(Core* core);
-
-void Frame_Begin();
-void Frame_Draw();
-void Frame_End();
diff --git a/src/core/input.c b/src/core/input.c
deleted file mode 100644
index e69de29..0000000
--- a/src/core/input.c
+++ /dev/null
diff --git a/src/core/triggers.h b/src/core/triggers.h
deleted file mode 100644
index a823890..0000000
--- a/src/core/triggers.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-#include "defines.h"
-
-// Events/signals that get triggered by certain things that happen
-
-/*
-e.g.
-collider enters volume (collider)
-collider exits volume (collider)
-
-you could create a custom signal that only triggers when a collider has been inside a volume for 3
-seconds listen for Enter, start timer, if hits 3 -> emit signal. Else, reset state
-
-Top-level triggers:
-level loaded
-
-*/ \ No newline at end of file
diff --git a/src/core/vfs.h b/src/core/vfs.h
deleted file mode 100644
index 41033f5..0000000
--- a/src/core/vfs.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-#include "defines.h"
-
-#define MAX_VIRTUAL_FILENAME_LEN 256
-
-typedef struct VFS_Pack VFS_Pack;
-
-const char VFS_OpenErr_DoesNotExist[] = "PATH DOES NOT EXIST";
-
-typedef struct VFS_File {
- size_t n_bytes;
- void* data;
-} VFS_File;
-
-// virtual file open result
-typedef struct VFS_FileRes {
- bool success;
- const char* error_reason;
- VFS_File file;
-} VFS_FileRes;
-
-VFS_Pack* VFS_Open(const char* filepath);
-
-bool VFS_Close(VFS_Pack*);
-
-VFS_FileRes VFS_VirtualRead(VFS_Pack* vfs, const char* unique_path);
-
-typedef struct VFS_PackBuilder {
- const char* pack_filename;
-} VFS_PackBuilder;
-
-typedef struct VFS_FileEntry {
- char filename[MAX_VIRTUAL_FILENAME_LEN];
- size_t offset;
- size_t size;
-} VFS_FileEntry;
-
-VFS_PackBuilder VFS_Pack_Create(); \ No newline at end of file