From c5ca30dcfbe3cddce83ba4be10bc80e1be46417d Mon Sep 17 00:00:00 2001 From: Arnau Alier Torres Date: Sat, 10 May 2025 20:49:17 +0200 Subject: [PATCH] Improved tree pannel --- Deer/Include/DeerRender/FrameBuffer.h | 21 +++++ Deer/Include/DeerRender/Render/FrameBuffer.h | 2 +- Deer/src/Deer/Scene/Scene.cpp | 4 + .../FrameBuffer/FrameBufferManager.cpp | 76 +++++++++++++++++++ .../Plattform/OpenGL/OpenGLFrameBuffer.cpp | 4 +- .../src/DeerStudio/Editor/GamePanel.cpp | 2 +- DeerStudio/src/DeerStudio/Editor/GamePanel.h | 2 +- DeerStudio/src/DeerStudio/Editor/Viewport.cpp | 4 +- DeerStudio/src/DeerStudio/EditorEngine/API.h | 3 +- .../src/DeerStudio/EditorEngine/API/Entity.h | 38 +++++----- .../DeerStudio/EditorEngine/API/Environment.h | 19 +++++ .../DeerStudio/EditorEngine/API/FrameBuffer.h | 23 ++++++ .../EditorEngine/API/GenericRefStructs.h | 22 ++++++ .../API_Implementation/Entity.cpp | 24 +++--- .../API_Implementation/Entity_Register.cpp | 26 +++---- .../API_Implementation/FrameBuffer.cpp | 32 ++++++++ .../FrameBuffer_Register.cpp | 48 ++++++++++++ .../EditorEngine/RegisterFunctions.cpp | 1 + .../EditorEngine/RegisterStructs.cpp | 1 + roe/editor/active_entity.as | 2 +- roe/editor/tree_pannel.as | 10 +-- roe/imgui.ini | 38 +++++----- 22 files changed, 319 insertions(+), 83 deletions(-) create mode 100644 Deer/Include/DeerRender/FrameBuffer.h create mode 100644 Deer/src/DeerRender/FrameBuffer/FrameBufferManager.cpp create mode 100644 DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h create mode 100644 DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h create mode 100644 DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h create mode 100644 DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp create mode 100644 DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer_Register.cpp diff --git a/Deer/Include/DeerRender/FrameBuffer.h b/Deer/Include/DeerRender/FrameBuffer.h new file mode 100644 index 0000000..5d42e9d --- /dev/null +++ b/Deer/Include/DeerRender/FrameBuffer.h @@ -0,0 +1,21 @@ +#pragma once +#include "DeerRender/Render/FrameBuffer.h" + +#include +#include + +namespace Deer { + // TODO: Add safety + namespace FrameBufferManager { + uint16_t createRGBA8FrameBuffer(std::string& name, int, int); + void resizeFrameBuffer(uint16_t frameBufferId, int, int); + + int getFrameBufferWidth(uint16_t frameBufferId); + int getFrameBufferHeight(uint16_t frameBufferId); + + const std::string& getFrameBufferName(uint16_t); + uint16_t getFrameBufferId(std::string& name); + + void unloadAllFrameBuffer(); + } +} \ No newline at end of file diff --git a/Deer/Include/DeerRender/Render/FrameBuffer.h b/Deer/Include/DeerRender/Render/FrameBuffer.h index bdca8ac..81ac883 100755 --- a/Deer/Include/DeerRender/Render/FrameBuffer.h +++ b/Deer/Include/DeerRender/Render/FrameBuffer.h @@ -38,7 +38,7 @@ namespace Deer { virtual int getTextureBufferPixel(int id, unsigned int x, unsigned int y) = 0; - static Ref create(const FrameBufferSpecification& spec); + static FrameBuffer* create(const FrameBufferSpecification& spec); }; } diff --git a/Deer/src/Deer/Scene/Scene.cpp b/Deer/src/Deer/Scene/Scene.cpp index dc057a0..e88f228 100755 --- a/Deer/src/Deer/Scene/Scene.cpp +++ b/Deer/src/Deer/Scene/Scene.cpp @@ -18,6 +18,8 @@ #ifdef DEER_RENDER #include "DeerRender/Voxels/VoxelWorldRenderData.h" #include "DeerRender/Mesh.h" +#include "DeerRender/Shader.h" +#include "DeerRender/FrameBuffer.h" #endif namespace Deer { @@ -26,6 +28,8 @@ namespace Deer { VoxelWorld::clear(); #ifdef DEER_RENDER MeshManager::unloadAllModels(); + ShaderManager::unloadAllShaders(); + FrameBufferManager::unloadAllFrameBuffer(); #endif } diff --git a/Deer/src/DeerRender/FrameBuffer/FrameBufferManager.cpp b/Deer/src/DeerRender/FrameBuffer/FrameBufferManager.cpp new file mode 100644 index 0000000..726c981 --- /dev/null +++ b/Deer/src/DeerRender/FrameBuffer/FrameBufferManager.cpp @@ -0,0 +1,76 @@ +#include "DeerRender/FrameBuffer.h" +#include + +#define FRAME_BUFFER_MAX_COUNT 256 + +namespace Deer { + namespace FrameBufferManager { + struct FrameBufferContainer { + FrameBuffer* frameBuffer_data = nullptr; + std::string frameBuffer_name; + }; + + uint16_t maxFrameBufferId = 1; + FrameBufferContainer frameBuffers[FRAME_BUFFER_MAX_COUNT]{}; + std::unordered_map frameBuffers_name_id_map; + } + + uint16_t FrameBufferManager::createRGBA8FrameBuffer(std::string& name, int x, int y) { + FrameBufferSpecification specs( + x, y, + {TextureBufferType::RGBA8}, 4, + false); + + FrameBuffer* frameBuffer = FrameBuffer::create(specs); + + uint16_t frameBufferId = maxFrameBufferId; + maxFrameBufferId++; + + frameBuffers[frameBufferId].frameBuffer_data = frameBuffer; + frameBuffers[frameBufferId].frameBuffer_name = name; + + frameBuffers_name_id_map[name] = frameBufferId; + return frameBufferId; + } + + void FrameBufferManager::resizeFrameBuffer(uint16_t frameBufferId, int x, int y) { + FrameBuffer* frameBuffer = frameBuffers[frameBufferId].frameBuffer_data; + + frameBuffer->resize(x, y); + } + + int FrameBufferManager::getFrameBufferWidth(uint16_t frameBufferId) { + FrameBuffer* frameBuffer = frameBuffers[frameBufferId].frameBuffer_data; + + return frameBuffer->getSpecification().width; + } + int FrameBufferManager::getFrameBufferHeight(uint16_t frameBufferId) { + FrameBuffer* frameBuffer = frameBuffers[frameBufferId].frameBuffer_data; + + return frameBuffer->getSpecification().height; + } + + const std::string& FrameBufferManager::getFrameBufferName(uint16_t id) { + DEER_CORE_ASSERT(id >= 0 && id < maxFrameBufferId, "Invalid frame buffer id {0}", id); + + return frameBuffers[id].frameBuffer_name; + } + + uint16_t FrameBufferManager::getFrameBufferId(std::string& name) { + return frameBuffers_name_id_map[name]; + } + + void FrameBufferManager::unloadAllFrameBuffer() { + for (int x = 1; x < maxFrameBufferId; x++) { + delete frameBuffers[x].frameBuffer_data; + frameBuffers[x].frameBuffer_data = nullptr; + } + + frameBuffers_name_id_map.clear(); + + maxFrameBufferId = 1; + frameBuffers[0].frameBuffer_data = nullptr; + frameBuffers[0].frameBuffer_name = "NULL"; + frameBuffers_name_id_map["NULL"] = 0; + } +} \ No newline at end of file diff --git a/Deer/src/Plattform/OpenGL/OpenGLFrameBuffer.cpp b/Deer/src/Plattform/OpenGL/OpenGLFrameBuffer.cpp index 2f9e1f3..fc2bc17 100755 --- a/Deer/src/Plattform/OpenGL/OpenGLFrameBuffer.cpp +++ b/Deer/src/Plattform/OpenGL/OpenGLFrameBuffer.cpp @@ -5,8 +5,8 @@ #include "glad/glad.h" namespace Deer { - Ref FrameBuffer::create(const FrameBufferSpecification& spec) { - return Ref(new OpenGLFrameBuffer(spec)); + FrameBuffer* FrameBuffer::create(const FrameBufferSpecification& spec) { + return new OpenGLFrameBuffer(spec); } OpenGLFrameBuffer::OpenGLFrameBuffer(const FrameBufferSpecification& frameBufferSpecification) diff --git a/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp b/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp index 9367bd8..a0f8ec2 100755 --- a/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp +++ b/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp @@ -11,7 +11,7 @@ namespace Deer { GamePanel::GamePanel() { FrameBufferSpecification fbSpecs = FrameBufferSpecification( 100, 100, {TextureBufferType::RGBA8}, 1, false); - m_frameBuffer = FrameBuffer::create(fbSpecs); + m_frameBuffer = Scope(FrameBuffer::create(fbSpecs)); } void GamePanel::onImGui() { diff --git a/DeerStudio/src/DeerStudio/Editor/GamePanel.h b/DeerStudio/src/DeerStudio/Editor/GamePanel.h index c4b1de8..810793b 100755 --- a/DeerStudio/src/DeerStudio/Editor/GamePanel.h +++ b/DeerStudio/src/DeerStudio/Editor/GamePanel.h @@ -15,7 +15,7 @@ namespace Deer { void onImGui() override; private: - Ref m_frameBuffer; + Scope m_frameBuffer; glm::vec2 m_lastWindowSize; }; diff --git a/DeerStudio/src/DeerStudio/Editor/Viewport.cpp b/DeerStudio/src/DeerStudio/Editor/Viewport.cpp index 7e114af..aa4bb14 100755 --- a/DeerStudio/src/DeerStudio/Editor/Viewport.cpp +++ b/DeerStudio/src/DeerStudio/Editor/Viewport.cpp @@ -51,10 +51,10 @@ namespace Deer { processMovment(); if (!m_frameBuffer) { - m_frameBuffer = FrameBuffer::create(FrameBufferSpecification( + m_frameBuffer = Scope(FrameBuffer::create(FrameBufferSpecification( 100, 100, {TextureBufferType::RGBA8, TextureBufferType::RED_INTEGER}, 4, - false)); + false))); } ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API.h b/DeerStudio/src/DeerStudio/EditorEngine/API.h index 7e3d5e5..cb91393 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API.h @@ -6,4 +6,5 @@ #include "DeerStudio/EditorEngine/API/Menu.h" #include "DeerStudio/EditorEngine/API/Resource.h" #include "DeerStudio/EditorEngine/API/UI.h" -#include "DeerStudio/EditorEngine/API/Math.h" \ No newline at end of file +#include "DeerStudio/EditorEngine/API/Math.h" +#include "DeerStudio/EditorEngine/API/FrameBuffer.h" \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h index 83901e6..b03851f 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h @@ -1,4 +1,6 @@ #pragma once +#include "DeerStudio/EditorEngine/API/GenericRefStructs.h" + #include #include #include "glm/glm.hpp" @@ -25,9 +27,8 @@ namespace Deer { // // bool == //} - struct EntityStruct { - EntityStruct(uint16_t entId = 0) : entityId(entId) { } - uint16_t entityId; + struct EntityStruct : EntityRefStruct { + EntityStruct(uint16_t entId = 0) { entityId = entId; } std::string getName(); void setName(std::string&); @@ -38,36 +39,33 @@ namespace Deer { bool isRoot(); void destroy(); - EntityStruct createChild(std::string&); + EntityRefStruct createChild(std::string&); - void setParent(EntityStruct parent); - EntityStruct getParent(); + void setParent(EntityRefStruct parent); + EntityRefStruct getParent(); - bool isDescendantOf(EntityStruct parent); - bool opEquals(const EntityStruct& other); + bool isDescendantOf(EntityRefStruct parent); + bool opEquals(const EntityRefStruct& other); //COMPONENTS - EntityStruct getMeshComponent(); + EntityRefStruct getMeshComponent(); bool hasMeshComponent(); void removeMeshComponent(); - EntityStruct getShaderComponent(); + EntityRefStruct getShaderComponent(); bool hasShaderComponent(); void removeShaderComponent(); - // This is an internal function to avoid undefined behaviour from angelscript and avoid problems - bool assertEntity(const char* funcName); - // This function can be adapted to get a specific transform since the data is the same - EntityStruct getSelf(); + EntityRefStruct getSelf(); }; - struct EntityChildArrayStruct : EntityStruct{ + struct EntityChildArrayStruct : EntityRefStruct { int getChildCount(); - EntityStruct getChild(int); + EntityRefStruct getChild(int); }; - struct TransformComponentStruct : EntityStruct { + struct TransformComponentStruct : EntityRefStruct { glm::vec3 getPosition(); glm::vec3 getScale(); glm::vec3 getRotation(); @@ -77,7 +75,7 @@ namespace Deer { void setRotation(glm::vec3); }; - struct MeshComponentStruct : EntityStruct { + struct MeshComponentStruct : EntityRefStruct { bool isActive(); void setActive(bool); @@ -90,7 +88,7 @@ namespace Deer { bool assertMeshComponent(const char* funcName); }; - struct ShaderComponentStruct : EntityStruct { + struct ShaderComponentStruct : EntityRefStruct { bool hasShader(); void clear(); @@ -100,7 +98,7 @@ namespace Deer { bool assertShaderComponent(const char* funcName); }; - EntityStruct getRoot(); + EntityRefStruct getRoot(); void constructEntityStruct(int id, void* memory); void copyEntityStruct(int id, void* memory); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h new file mode 100644 index 0000000..978c2ba --- /dev/null +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h @@ -0,0 +1,19 @@ +#pragma once +#include "GenericRefStructs.h" +#include + +namespace Deer { + namespace EditorEngine { + struct EnvironmentStruct : EnvironmentRefStruct { + void render(EntityRefStruct cameraEntity, FrameBufferRefStruct); + + EntityRefStruct getRootEntity(); + EntityRefStruct getEntity(int); + }; + + EnvironmentRefStruct getMainEnvironment(); + + EnvironmentRefStruct createEnvironment(std::string&); + EnvironmentRefStruct getEnvironment(std::string&); + } +} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h b/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h new file mode 100644 index 0000000..31db95b --- /dev/null +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include + +namespace Deer { + namespace EditorEngine { + struct FrameBufferStruct : FrameBufferRefStruct{ + FrameBufferStruct(uint16_t _id) { frameBufferId = _id; } + + int getWidth(); + int getHeight(); + + void resize(int, int); + std::string getName(); + }; + + FrameBufferStruct createRGBA8FrameBuffer(std::string& name, int, int); + FrameBufferStruct getFrameBuffer(std::string& name); + + void registerFrameBufferStructs(); + void registerFrameBufferFunctions(); + } +} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h b/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h new file mode 100644 index 0000000..7e39a9d --- /dev/null +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h @@ -0,0 +1,22 @@ +#pragma once +#include + +namespace Deer { + namespace EditorEngine { + struct EntityRefStruct { + uint16_t entityId; + uint16_t environmentId; + + // This is an internal function to avoid undefined behaviour from angelscript and avoid problems + bool assertEntity(const char* funcName); + }; + + struct EnvironmentRefStruct { + uint16_t environmentId; + }; + + struct FrameBufferRefStruct { + uint16_t frameBufferId; + }; + } +} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp index 4c9115e..a6a5e75 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp @@ -15,9 +15,7 @@ namespace Deer { namespace EditorEngine { - EntityStruct activeEntity; - - EntityStruct getRoot() { + EntityRefStruct getRoot() { return EntityStruct(0); } @@ -29,7 +27,7 @@ namespace Deer { return entityId; } - bool EntityStruct::assertEntity(const char* funcName) { + bool EntityRefStruct::assertEntity(const char* funcName) { if (!Scene::environment.entityExists(entityId)) { DEER_UI_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId); if (currentDockPanelExecution) @@ -76,7 +74,7 @@ namespace Deer { .entityExists(entityId); } - void EntityStruct::setParent(EntityStruct parent_struct) { + void EntityStruct::setParent(EntityRefStruct parent_struct) { ASSERT_ENTITY("setParent()", return); Entity& parent = GET_ENTITY(parent_struct.entityId); @@ -85,7 +83,7 @@ namespace Deer { .setParent(parent); } - EntityStruct EntityStruct::getParent() { + EntityRefStruct EntityStruct::getParent() { ASSERT_ENTITY("getParent()", return *this); Entity& self = GET_ENTITY(entityId); @@ -95,7 +93,7 @@ namespace Deer { return EntityStruct(self.getParentId()); } - bool EntityStruct::isDescendantOf(EntityStruct parent_struct) { + bool EntityStruct::isDescendantOf(EntityRefStruct parent_struct) { ASSERT_ENTITY("isDescendantOf()", return false); Entity& parent = GET_ENTITY(parent_struct.entityId); @@ -104,13 +102,13 @@ namespace Deer { .isDescendantOf(parent); } - bool EntityStruct::opEquals(const EntityStruct& other) { + bool EntityStruct::opEquals(const EntityRefStruct& other) { ASSERT_ENTITY("opEquals()", return false); return entityId == other.entityId; } - EntityStruct EntityStruct::getSelf() { + EntityRefStruct EntityStruct::getSelf() { ASSERT_ENTITY("getSelf()", return *this); return *this; @@ -179,7 +177,7 @@ namespace Deer { return true; } - EntityStruct EntityChildArrayStruct::getChild(int i) { + EntityRefStruct EntityChildArrayStruct::getChild(int i) { ASSERT_ENTITY("getChild()", return *this); RelationshipComponent& rc = GET_ENTITY(entityId) @@ -196,7 +194,7 @@ namespace Deer { return EntityStruct(rc.getChildrenId(i)); } - EntityStruct EntityStruct::createChild(std::string& name) { + EntityRefStruct EntityStruct::createChild(std::string& name) { ASSERT_ENTITY("createChild()", return *this); Entity& me = GET_ENTITY(entityId); @@ -209,7 +207,7 @@ namespace Deer { return EntityStruct(newEnt.getId()); } - EntityStruct EntityStruct::getMeshComponent() { + EntityRefStruct EntityStruct::getMeshComponent() { ASSERT_ENTITY("getMeshComponent()", return *this); Entity& self = GET_ENTITY(entityId); @@ -239,7 +237,7 @@ namespace Deer { } } - EntityStruct EntityStruct::getShaderComponent() { + EntityRefStruct EntityStruct::getShaderComponent() { ASSERT_ENTITY("getShaderComponent()", return *this); Entity& self = GET_ENTITY(entityId); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp index bcf7757..611b55d 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp @@ -13,26 +13,20 @@ namespace Deer { void registerShaderComponentFunctions(); void registerEntityStructs() { - AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityRefStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectBehaviour( - "Entity", asBEHAVE_CONSTRUCT, "void f(int)", - asFunctionPtr(constructEntityStruct), - asCALL_CDECL_OBJLAST - )); + AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityRefStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityRefStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityRefStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - - AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityRefStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); } void registerEntityFunctions() { diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp new file mode 100644 index 0000000..a9cf0b2 --- /dev/null +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer.cpp @@ -0,0 +1,32 @@ +#include "DeerStudio/EditorEngine/API/FrameBuffer.h" +#include "DeerRender/FrameBuffer.h" + +namespace Deer { + namespace EditorEngine { + + int FrameBufferStruct::getWidth() { + return FrameBufferManager::getFrameBufferWidth(frameBufferId); + } + + int FrameBufferStruct::getHeight() { + return FrameBufferManager::getFrameBufferWidth(frameBufferId); + } + + void FrameBufferStruct::resize(int x, int y) { + FrameBufferManager::resizeFrameBuffer(frameBufferId, x, y); + } + + std::string FrameBufferStruct::getName() { + return FrameBufferManager::getFrameBufferName(frameBufferId); + } + + FrameBufferStruct createRGBA8FrameBuffer(std::string& name, int x, int y) { + uint16_t id = FrameBufferManager::createRGBA8FrameBuffer(name, x, y); + return FrameBufferStruct(id); + } + + FrameBufferStruct getFrameBuffer(std::string& name) { + return FrameBufferManager::getFrameBufferId(name); + } + } +} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer_Register.cpp new file mode 100644 index 0000000..e4777c3 --- /dev/null +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/FrameBuffer_Register.cpp @@ -0,0 +1,48 @@ +#include "DeerStudio/EditorEngine/API/FrameBuffer.h" +#include "DeerStudio/EditorEngine/ErrorHandle.h" +#include "DeerStudio/EditorEngine.h" +#include "angelscript.h" + +namespace Deer { + namespace EditorEngine { + void registerFrameBufferStructs() { + AS_CHECK(scriptEngine->RegisterObjectType("FrameBuffer", sizeof(FrameBufferStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + + } + + void registerFrameBufferFunctions() { + AS_CHECK(scriptEngine->RegisterObjectMethod( + "FrameBuffer", "int get_width() const property", + asMETHOD(FrameBufferStruct, getWidth), asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "FrameBuffer", "int get_height() const property", + asMETHOD(FrameBufferStruct, getHeight), asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "FrameBuffer", "void resize(int, int)", + asMETHOD(FrameBufferStruct, resize), asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "FrameBuffer", "string get_name() const property", + asMETHOD(FrameBufferStruct, getName), asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterGlobalFunction( + "FrameBuffer createRGBA8FrameBuffer(const string&in, int, int)", + asFUNCTION(createRGBA8FrameBuffer), + asCALL_CDECL + )); + + AS_CHECK(scriptEngine->RegisterGlobalFunction( + "FrameBuffer getFrameBuffer(const string&in)", + asFUNCTION(getFrameBuffer), + asCALL_CDECL + )); + } + } +} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp b/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp index 2bad282..12103e6 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp @@ -9,6 +9,7 @@ namespace Deer { registerEntityFunctions(); registerMathFunctions(); registerUIFunctions(); + registerFrameBufferFunctions(); AS_CHECK(scriptEngine->RegisterGlobalFunction( "void setupAutomaticColumns(int)", diff --git a/DeerStudio/src/DeerStudio/EditorEngine/RegisterStructs.cpp b/DeerStudio/src/DeerStudio/EditorEngine/RegisterStructs.cpp index 612e283..ca65ddd 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/RegisterStructs.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/RegisterStructs.cpp @@ -24,6 +24,7 @@ namespace Deer { registerResourceTypeEnum(); registerEntityStructs(); registerMathStructs(); + registerFrameBufferStructs(); } } } \ No newline at end of file diff --git a/roe/editor/active_entity.as b/roe/editor/active_entity.as index 078f064..f470cde 100644 --- a/roe/editor/active_entity.as +++ b/roe/editor/active_entity.as @@ -1 +1 @@ -Entity activeEntity(0); \ No newline at end of file +Entity activeEntity = getRoot(); \ No newline at end of file diff --git a/roe/editor/tree_pannel.as b/roe/editor/tree_pannel.as index 15ced03..8d3741a 100644 --- a/roe/editor/tree_pannel.as +++ b/roe/editor/tree_pannel.as @@ -2,11 +2,8 @@ class TreePannel : DockPanel { void onRender() { Entity root = getRoot(); contextMenuPopup("Window popup", any(root), ReciverFunc(this.entityContextMenu)); - - bool opened = treeNode(root.name, false, any(root), ReciverFunc(this.renderNode)); - if (!opened) { - contextItemPopup("POP_ENTITY_" + root.id, any(root), ReciverFunc(this.entityContextMenu)); - } + + renderNode(any(root)); modalPopup("Rename entity", renameEntity); } @@ -28,7 +25,8 @@ class TreePannel : DockPanel { Entity entity; data.retrieve(entity); - entityInteraction(entity); + if (!entity.isRoot) + entityInteraction(entity); // Maybe we deleted the entity in the context menu if (!entity.exists) diff --git a/roe/imgui.ini b/roe/imgui.ini index caf4aef..63a45b2 100644 --- a/roe/imgui.ini +++ b/roe/imgui.ini @@ -15,8 +15,8 @@ Collapsed=0 DockId=0x00000004,1 [Window][Game Window] -Pos=258,24 -Size=499,490 +Pos=365,24 +Size=504,503 Collapsed=0 DockId=0x00000006,0 @@ -27,14 +27,14 @@ Collapsed=0 DockId=0x00000001,0 [Window][Terrain Editor] -Pos=759,24 -Size=521,490 +Pos=871,24 +Size=409,503 Collapsed=0 DockId=0x00000004,0 [Window][Viewport] -Pos=258,24 -Size=499,490 +Pos=365,24 +Size=504,503 Collapsed=0 DockId=0x00000006,1 @@ -57,14 +57,14 @@ Collapsed=0 DockId=0x00000008,1 [Window][MeshExplorer] -Pos=0,516 -Size=1280,204 +Pos=0,529 +Size=1280,191 Collapsed=0 DockId=0x00000008,0 [Window][TreePannel] Pos=0,24 -Size=256,490 +Size=363,503 Collapsed=0 DockId=0x00000005,0 @@ -79,8 +79,8 @@ Size=351,75 Collapsed=0 [Window][PropertiesPannel] -Pos=759,24 -Size=521,490 +Pos=871,24 +Size=409,503 Collapsed=0 DockId=0x00000004,1 @@ -91,19 +91,19 @@ Collapsed=0 DockId=0x00000004,1 [Window][ShaderExplorer] -Pos=0,516 -Size=1280,204 +Pos=0,529 +Size=1280,191 Collapsed=0 DockId=0x00000008,1 [Docking][Data] DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y - DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,490 Split=Y + DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,503 Split=Y DockNode ID=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=757,338 Split=X Selected=0x13926F0B - DockNode ID=0x00000005 Parent=0x00000003 SizeRef=256,446 Selected=0xE45B9F93 - DockNode ID=0x00000006 Parent=0x00000003 SizeRef=499,446 CentralNode=1 Selected=0x13926F0B - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=521,338 Selected=0xA35A27E3 + DockNode ID=0x00000003 Parent=0x00000001 SizeRef=869,338 Split=X Selected=0x13926F0B + DockNode ID=0x00000005 Parent=0x00000003 SizeRef=363,446 Selected=0xE45B9F93 + DockNode ID=0x00000006 Parent=0x00000003 SizeRef=504,446 CentralNode=1 Selected=0x13926F0B + DockNode ID=0x00000004 Parent=0x00000001 SizeRef=409,338 Selected=0x2A2C795E DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702 - DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,204 Selected=0xD962995A + DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,191 Selected=0xD962995A