From bf4189bba00eee06098bd7138c467c5d2fadc08b019b8cd83a6e940013c878b8 Mon Sep 17 00:00:00 2001 From: Mexpert_PRO Date: Sun, 25 Jan 2026 10:55:06 +0100 Subject: [PATCH] fixed some small bugs and updated version to 0.1.3 --- TSE_Base/src/version.h | 2 +- TSE_Core/src/BehaviourScripts/Camera.cpp | 2 ++ TSE_Core/src/BehaviourScripts/Camera.hpp | 7 +++++ TSE_Core/src/elements/Transformable.cpp | 28 +++++++++++++++---- TSE_Core/src/elements/Transformable.hpp | 1 + TSE_Editor/src/UI/windows/CameraView.cpp | 2 +- TSE_Editor/src/UI/windows/HirearchieView.cpp | 6 ++-- TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp | 17 +++++++++++ .../src/OpenGLRenderingBackend.cpp | 2 ++ 9 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp diff --git a/TSE_Base/src/version.h b/TSE_Base/src/version.h index 2ad8699..be93a9f 100644 --- a/TSE_Base/src/version.h +++ b/TSE_Base/src/version.h @@ -5,7 +5,7 @@ namespace TSE { #define TSE_VERSION_MAJOR 0 #define TSE_VERSION_MINOR 1 - #define TSE_VERSION_BUILD 2 + #define TSE_VERSION_BUILD 3 #define TSE_VERSION_STRING std::to_string(TSE_VERSION_MAJOR) + "." + std::to_string(TSE_VERSION_MINOR) + "." + std::to_string(TSE_VERSION_BUILD) diff --git a/TSE_Core/src/BehaviourScripts/Camera.cpp b/TSE_Core/src/BehaviourScripts/Camera.cpp index d7e93c8..6734ef6 100644 --- a/TSE_Core/src/BehaviourScripts/Camera.cpp +++ b/TSE_Core/src/BehaviourScripts/Camera.cpp @@ -3,6 +3,7 @@ #include "interfaces/IRenderer.hpp" TSE::Camera* TSE::Camera::mainCamera = nullptr; +TSE::ICameraHelper* TSE::Camera::helper = nullptr; float TSE::Camera::GetRenderScale() const { @@ -182,6 +183,7 @@ void TSE::Camera::PreDraw(IShader *shader) viewMatrix = BuildView_Zplus_RH(worlmatrix); shader->SetUniform("camMatrix", &viewMatrix); + helper->OnRenderTargetChanged(lastRtSize.x, lastRtSize.y); } void TSE::Camera::PostDraw() diff --git a/TSE_Core/src/BehaviourScripts/Camera.hpp b/TSE_Core/src/BehaviourScripts/Camera.hpp index 477ae0f..0ee91c9 100644 --- a/TSE_Core/src/BehaviourScripts/Camera.hpp +++ b/TSE_Core/src/BehaviourScripts/Camera.hpp @@ -17,6 +17,12 @@ namespace TSE Perspective = 2, }; + class ICameraHelper + { + public: + inline virtual void OnRenderTargetChanged(float width, float height) {}; + }; + class Camera : public IResizeNotifiable, public BehaviourScript { private: @@ -35,6 +41,7 @@ namespace TSE Vector2 lastRtSize = {0, 0}; public: + static ICameraHelper* helper; static Camera* mainCamera; // Getter diff --git a/TSE_Core/src/elements/Transformable.cpp b/TSE_Core/src/elements/Transformable.cpp index aa6ff12..94a4493 100644 --- a/TSE_Core/src/elements/Transformable.cpp +++ b/TSE_Core/src/elements/Transformable.cpp @@ -15,10 +15,10 @@ namespace TSE objectEntries[id] = this; } - Transformable::Transformable(uuids::uuid id) - : id(id), position(0, 0, 0), scale(1, 1, 1), rotation(), name("") + Transformable::Transformable(uuids::uuid _id) + : id(_id), position(0, 0, 0), scale(1, 1, 1), rotation(), name("") { - objectEntries[id] = this; + objectEntries[_id] = this; } Transformable::Transformable(const string &name) @@ -28,10 +28,10 @@ namespace TSE objectEntries[id] = this; } - Transformable::Transformable(const string &name, uuids::uuid id) - : id(id), position(0, 0, 0), scale(1, 1, 1), rotation(), name(name) + Transformable::Transformable(const string &name, uuids::uuid _id) + : id(_id), position(0, 0, 0), scale(1, 1, 1), rotation(), name(name) { - objectEntries[id] = this; + objectEntries[_id] = this; } Transformable::~Transformable() @@ -370,10 +370,13 @@ namespace TSE { //deleting children if(!onlyThis) + { for(auto child : t->children) { HardDelete(child, onlyThis); } + t->children.clear(); + } //deleting atteched scripts for (auto& [_, script] : t->components) @@ -449,6 +452,19 @@ namespace TSE return objectEntries.size(); } + Transformable *Transformable::GetTansformableAt(int i) + { + int x = 0; + for(auto obj : objectEntries) + { + if(i == x++) + { + return obj.second; + } + } + return nullptr; + } + Transformable *Transformable::Find(string name) { for(auto obj : objectEntries) diff --git a/TSE_Core/src/elements/Transformable.hpp b/TSE_Core/src/elements/Transformable.hpp index fbc8990..0c49bf9 100644 --- a/TSE_Core/src/elements/Transformable.hpp +++ b/TSE_Core/src/elements/Transformable.hpp @@ -100,6 +100,7 @@ namespace TSE public: static int GetTansformableCount(); + static Transformable* GetTansformableAt(int i); static Transformable* Find(string name); static Transformable* Find(uuids::uuid id); }; diff --git a/TSE_Editor/src/UI/windows/CameraView.cpp b/TSE_Editor/src/UI/windows/CameraView.cpp index 58fdf9b..b01d91d 100644 --- a/TSE_Editor/src/UI/windows/CameraView.cpp +++ b/TSE_Editor/src/UI/windows/CameraView.cpp @@ -17,7 +17,7 @@ void TSE::EDITOR::CameraView::Define() } ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar; - if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2)) + if(ImGui::BeginChild("##CameraChild", {0,0}, ImGuiChildFlags_None, flags2)) { ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0}); auto vec2 = ImGui::GetWindowSize(); diff --git a/TSE_Editor/src/UI/windows/HirearchieView.cpp b/TSE_Editor/src/UI/windows/HirearchieView.cpp index fd6a767..88ab9bd 100644 --- a/TSE_Editor/src/UI/windows/HirearchieView.cpp +++ b/TSE_Editor/src/UI/windows/HirearchieView.cpp @@ -11,6 +11,8 @@ void TSE::EDITOR::HirearchieView::SetScene(Scene *s) currentScene = s; } +bool selectedFound = false; + void TSE::EDITOR::HirearchieView::Define() { if(currentScene == nullptr) return; @@ -32,6 +34,7 @@ void TSE::EDITOR::HirearchieView::Define() if(collapseOpen) { int layerCount = currentScene->GetLayerCount(); + selectedFound = false; for (int i = 0; i < layerCount; i++) { auto layer = currentScene->GetLayerAt(i); @@ -123,7 +126,6 @@ void TSE::EDITOR::HirearchieView::MenuBar() ImGui::EndMenuBar(); } -bool selectedFound = false; void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l) { @@ -182,7 +184,6 @@ void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l) } if(collapseOpen) { - selectedFound = false; for(int i = 0; i < l->GetAllObjects().size(); i++) { DisplayObj(l->GetAllObjects()[i], l); @@ -290,6 +291,7 @@ void TSE::EDITOR::HirearchieView::DisplayObj(Transformable *t, Layer *l) { selected = t->id; PropertiesView::SetInspectorElement(InspectableType::Transformable, t); + selectedFound = true; } if(open) { diff --git a/TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp b/TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp new file mode 100644 index 0000000..0c3d86a --- /dev/null +++ b/TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "BehaviourScripts/Camera.hpp" +#include "GL/gl3w.h" +#include "GL/gl.h" + +namespace TSE::GLFW +{ + class CameraHelperOpenGL : public ICameraHelper + { + public: + inline void OnRenderTargetChanged(float width, float height) override + { + glViewport(0, 0, width, height); + }; + }; +} // namespace TSE::GLFW diff --git a/TSE_GlfwOpenGlImpl/src/OpenGLRenderingBackend.cpp b/TSE_GlfwOpenGlImpl/src/OpenGLRenderingBackend.cpp index 76f2d9c..d716138 100644 --- a/TSE_GlfwOpenGlImpl/src/OpenGLRenderingBackend.cpp +++ b/TSE_GlfwOpenGlImpl/src/OpenGLRenderingBackend.cpp @@ -13,6 +13,7 @@ #include "interfaces/IRenderer.hpp" #include "BehaviourScripts/Camera.hpp" #include "RenderTextureCreatorOpenGL.hpp" +#include "CameraHelperOpenGL.hpp" TSE::GLFW::OpenGLRenderingBackend::OpenGLRenderingBackend(Color _backgroundColor, bool _vsync) : OpenGLRenderingBackend(_backgroundColor, _vsync, 0, false){ } @@ -39,6 +40,7 @@ void TSE::GLFW::OpenGLRenderingBackend::InitPreWindow() { IRenderTexture::factory = new RenderTextureCreatorOpenGL(); Texture::helper = new TextureHelperOpenGL(); + Camera::helper = new CameraHelperOpenGL(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, TSE_OPENGL_VERSION_MAJOR); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, TSE_OPENGL_VERSION_MINOR);