From a5380c441787fc5c650e6190037326ced8f53cfc Mon Sep 17 00:00:00 2001 From: tulpenkiste Date: Mon, 26 Jun 2023 16:08:19 +0200 Subject: [PATCH] Remove node class --- TODO.md | 18 +++++++++--------- core/engine/engine.cpp | 38 +++++++++++++------------------------- core/engine/engine.hpp | 8 ++------ core/node/node.hpp | 9 --------- test/app.cpp | 2 -- 5 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 core/node/node.hpp diff --git a/TODO.md b/TODO.md index 27e3ccd..8b812ca 100644 --- a/TODO.md +++ b/TODO.md @@ -1,21 +1,18 @@ # Hibis Engine - Feature TODOs -## Core +## Core Module - [ ] BetterC compatibility - [ ] Texture loading - [ ] Model loading - [ ] Base Renderer class - [ ] Base Physics class -- [ ] Base Node class -- [ ] Base UI Node class -- [ ] Base Audio Playback Node class +- [ ] Figure out how scenes should be handled - [ ] Split other sections into seperate libraries (renderers, physics) -## Audio +## Audio Module - [ ] OGG and WAV support (do first) - [ ] MP3 (later) -- [ ] Audio playing nodes -## Hibis UI (NEED A NAME) +## Hibis UI (NEEDS A NAME) - [ ] GUI creation -- [ ] Text Object (rendering via SDL2_TTF (RSDL) or FreeType2 (EVERYTHING ELSE)) +- [ ] Text Object (rendering via FreeType2) ## RGLCore (2D AND 3D) - [X] Window creation - [ ] Renderer creation @@ -35,6 +32,9 @@ ## Hibis Physics (NEED A NAME) - [ ] Physics Shape creation - [ ] Collision via raycasting -- [ ] Option to *allow* for Physics Shapes to be able to be drawn (on by default, both compile time and run time, turn off at compile time via version(`-version=NoPhysShapeDraw`?)) +- [ ] Option to *allow* for Physics Shapes to be able to be drawn (on by default, both compile time and run time, turn off at compile time via a flag (`-DNoPhysShapeDraw=1`?)) ## Examples +- [ ] Example: UI test - [ ] Example Game: Megaman clone +- [ ] Stress test using sprites +- [ ] Stress test using models diff --git a/core/engine/engine.cpp b/core/engine/engine.cpp index 9fc702c..64dd6a4 100644 --- a/core/engine/engine.cpp +++ b/core/engine/engine.cpp @@ -25,36 +25,24 @@ namespace hibis { //watch.stop(); } - void Engine::runNodeProcesses() { - TODO("check if delta calc is correct") - TODO("get workaround for MSVC being fucking stupid (std::chrono + std::this_thread)") + float Engine::calculateDelta(bool isPhysics) { const std::chrono::time_point current = std::chrono::steady_clock::now(); - auto delta = std::chrono::duration(current - mPreviousProcessTick); + if (isPhysics) { + auto delta = std::chrono::duration(current - mPreviousPhysicsProcessTick); - for (Node* node : mNodeList) { - node->process(delta.count()); + return delta.count(); + } else { + auto delta = std::chrono::duration(current - mPreviousProcessTick); + + return delta.count(); } - - mPreviousProcessTick = std::chrono::steady_clock::now(); } - void Engine::runNodePhysicsProcesses() { - const std::chrono::time_point current = std::chrono::steady_clock::now(); - auto delta = std::chrono::duration(current - mPreviousProcessTick); - - for (Node* node : mNodeList) { - node->physicsProcess(delta.count()); - } - - mPreviousProcessTick = std::chrono::steady_clock::now(); - } - - void Engine::drawNodes() { - TODO("check if this works") - for (Node* node : mNodeList) { - if (Drawable* drawNode = (Drawable*)&node) { - drawNode->draw(mRenderer); - } + void Engine::updateDelta(bool isPhysics) { + if (isPhysics) { + mPreviousPhysicsProcessTick = std::chrono::steady_clock::now(); + } else { + mPreviousProcessTick = std::chrono::steady_clock::now(); } } diff --git a/core/engine/engine.hpp b/core/engine/engine.hpp index 3b1d7e0..c4ed0ca 100644 --- a/core/engine/engine.hpp +++ b/core/engine/engine.hpp @@ -6,7 +6,6 @@ #include "../renderer/renderer.hpp" #include "../callback.hpp" -#include "../node/node.hpp" namespace hibis { class Engine { @@ -14,11 +13,9 @@ namespace hibis { Engine(Renderer* renderer, LoggerCallback logger); ~Engine(); - void runNodeProcesses(); + float calculateDelta(bool isPhysics); - void runNodePhysicsProcesses(); - - void drawNodes(); + void updateDelta(bool isPhysics); const char* getEngineVersion(); @@ -29,7 +26,6 @@ namespace hibis { std::chrono::time_point mPreviousProcessTick; std::chrono::time_point mPreviousPhysicsProcessTick; - std::vector mNodeList; LoggerCallback mLoggerCallback; }; } diff --git a/core/node/node.hpp b/core/node/node.hpp deleted file mode 100644 index 33f15a4..0000000 --- a/core/node/node.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -namespace hibis { - class Node { - public: - virtual void process(float delta) {} - virtual void physicsProcess(float delta) {} - }; -} diff --git a/test/app.cpp b/test/app.cpp index 123d1ed..45cc90a 100644 --- a/test/app.cpp +++ b/test/app.cpp @@ -70,8 +70,6 @@ int main() { logger(Information, "Started Hibis test app! BEHOLD: Colours."); while (renderer.mKeepOpen) { - engine.runNodeProcesses(); - // Colour changing background! if ((red == 255 && increaseRed) || (red == 0 && !increaseRed)) { increaseRed = !increaseRed;