From f246d0e227696e317bb3bc67bca6d09d215498c3 Mon Sep 17 00:00:00 2001 From: Chewico Date: Thu, 22 Jan 2026 17:01:46 +0100 Subject: [PATCH] Changed environment to entity environment --- Deer/Include/DeerCore/Enviroment.h | 32 ++-- Deer/Include/DeerCore/Scene.h | 4 +- Deer/Include/DeerRender/RenderPiperline.h | 31 ++-- Deer/src/DeerCore/Scene/Entity.cpp | 2 +- Deer/src/DeerCore/Scene/Enviroment.cpp | 22 +-- .../src/DeerCore/Scene/EnvironmentBuilder.cpp | 4 +- Deer/src/DeerCore/Scene/Scene.cpp | 1 + Deer/src/DeerCore/Scene/SceneData.cpp | 2 +- Deer/src/DeerCore/Scene/SceneData.h | 4 +- .../Serialization/EntitySerializationStruct.h | 6 +- .../Serialization/EnvironmentSerialization.h | 20 +-- .../Scene/Serialization/Serialization.h | 2 +- Deer/src/DeerRender/Scene/Environment.cpp | 2 +- .../DeerStudio/StudioAPI/Environment.h | 6 +- .../DeerStudio/StudioAPI/GenericRefStructs.h | 8 +- DeerStudio/headers/DeerStudio/StudioAPI/UI.h | 57 ++++--- .../AngelScriptEngine/AngelScriptEngine.cpp | 4 +- .../AngelScriptEngine/AngelScriptRegisters.h | 4 +- .../ModulePredefinedGenerator.cpp | 2 +- .../AngelScriptEngine/Registers/Engine.cpp | 8 +- .../Registers/Environment.cpp | 22 +-- .../AngelScriptEngine/Registers/UI.cpp | 150 +++++++++--------- .../src/DeerStudio/StudioAPI/Entity.cpp | 20 +-- .../src/DeerStudio/StudioAPI/Environment.cpp | 35 ++-- Editor/Modules/ActiveEntity/ActiveEntity.as | 2 +- .../EntityManipulation/AddComponent.as | 2 +- .../EntityManipulation/MeshProperties.as | 4 +- .../EntityManipulation/PropertiesPannel.as | 14 +- .../EntityManipulation/ShaderProperties.as | 8 +- Editor/Modules/Previewer/MeshPreview.as | 4 +- Editor/Modules/Test/ActiveEntity.as | 8 - Editor/Modules/Test/module.json | 5 - Editor/Modules/TreeExplorer/Tree.as | 8 +- Editor/Modules/Viewport/Viewport.as | 6 +- 34 files changed, 251 insertions(+), 258 deletions(-) delete mode 100644 Editor/Modules/Test/ActiveEntity.as delete mode 100644 Editor/Modules/Test/module.json diff --git a/Deer/Include/DeerCore/Enviroment.h b/Deer/Include/DeerCore/Enviroment.h index 6019841..cdcd8a3 100755 --- a/Deer/Include/DeerCore/Enviroment.h +++ b/Deer/Include/DeerCore/Enviroment.h @@ -20,22 +20,22 @@ namespace Deer { class Entity; - class Environment { + class EntityEnvironment { // Note: Outdated note ///////// NOTES /////////// - // - The entity id means the position in a array defined in Environment - // - The entity id is relative to a Environment so it can be a complete + // - The entity id means the position in a array defined in EntityEnvironment + // - The entity id is relative to a EntityEnvironment so it can be a complete // diferent entity in other environments // - The entity number 0 is allways the root // - There is a limit defined by ENVIRONMENT_MAX_ENTITIES of how many - // entities can be in an Environment + // entities can be in an EntityEnvironment ///////// NOTES /////////// public: - Environment(); - ~Environment(); + EntityEnvironment(); + ~EntityEnvironment(); // This class can not be copyed - Environment(const Environment&) = delete; - Environment& operator=(Environment&) = delete; + EntityEnvironment(const EntityEnvironment&) = delete; + EntityEnvironment& operator=(EntityEnvironment&) = delete; // Clears all entities void clear(); @@ -80,15 +80,15 @@ namespace Deer { int toDo; }; - struct EnvironmentData { + struct EntityEnvironmentData { std::vector entities; }; template <> - class ResourceBuilder { + class ResourceBuilder { public: - using BaseDataType = EnvironmentData; - static Scope buildResource(const BaseDataType& baseData); + using BaseDataType = EntityEnvironmentData; + static Scope buildResource(const BaseDataType& baseData); }; // Warning: This calss does not initialize for performance @@ -111,7 +111,7 @@ namespace Deer { void setParent(Entity& parent); bool isDescendantOf(Entity& parent) const; - Environment* getEnvironment() const { return environment; } + EntityEnvironment* getEntityEnvironment() const { return environment; } bool isRoot() const { return entId == 0; } glm::mat4 getWorldMatrix() const; @@ -123,14 +123,14 @@ namespace Deer { bool isValid() const; private: - Environment* environment = nullptr; + EntityEnvironment* environment = nullptr; entt::entity entHandle = entt::null; uint16_t entId = 0; uint16_t parentId = 0; - Entity(entt::entity handle, Environment* scene, uint16_t entityID); + Entity(entt::entity handle, EntityEnvironment* scene, uint16_t entityID); - friend class Environment; + friend class EntityEnvironment; public: template diff --git a/Deer/Include/DeerCore/Scene.h b/Deer/Include/DeerCore/Scene.h index 168ff5c..7c9e4b0 100755 --- a/Deer/Include/DeerCore/Scene.h +++ b/Deer/Include/DeerCore/Scene.h @@ -2,7 +2,7 @@ #include "DeerCore/Tools/TypeDefs.h" namespace Deer { - class Environment; + class EntityEnvironment; class SceneCamera; class GizmoRenderer; @@ -27,6 +27,6 @@ namespace Deer { extern GizmoRenderer gizmoRenderer; #endif - extern Environment environment; + extern EntityEnvironment environment; } // namespace Scene } // namespace Deer diff --git a/Deer/Include/DeerRender/RenderPiperline.h b/Deer/Include/DeerRender/RenderPiperline.h index 65aad30..faf650a 100644 --- a/Deer/Include/DeerRender/RenderPiperline.h +++ b/Deer/Include/DeerRender/RenderPiperline.h @@ -1,22 +1,23 @@ #pragma once +#include "DeerRender/Enviroment.h" #include "DeerRender/Render/FrameBuffer.h" #include "DeerRender/Tools/Memory.h" -#include "DeerRender/Enviroment.h" namespace Deer { - class RenderPiperline { - public: - RenderPiperline(RenderPiperline&) = delete; - RenderPiperline(PiperlineOptions); + class RenderPiperline { + public: + RenderPiperline(RenderPiperline&) = delete; + RenderPiperline(PiperlineOptions); - void render(const Environment&); - private: - Scope resultImage; - PiperlineOptions options; - }; + void render(const EntityEnvironment&); - struct PiperlineOptions { - int width = 100; - int height = 100; - }; -} \ No newline at end of file + private: + Scope resultImage; + PiperlineOptions options; + }; + + struct PiperlineOptions { + int width = 100; + int height = 100; + }; +} // namespace Deer \ No newline at end of file diff --git a/Deer/src/DeerCore/Scene/Entity.cpp b/Deer/src/DeerCore/Scene/Entity.cpp index f4e9573..c91598c 100755 --- a/Deer/src/DeerCore/Scene/Entity.cpp +++ b/Deer/src/DeerCore/Scene/Entity.cpp @@ -3,7 +3,7 @@ #include "DeerCore/Log.h" namespace Deer { - Entity::Entity(entt::entity handle, Environment* scene, uint16_t entityID) + Entity::Entity(entt::entity handle, EntityEnvironment* scene, uint16_t entityID) : entHandle(handle), environment(scene), entId(entityID) {} diff --git a/Deer/src/DeerCore/Scene/Enviroment.cpp b/Deer/src/DeerCore/Scene/Enviroment.cpp index 5e52ac8..9752e3f 100755 --- a/Deer/src/DeerCore/Scene/Enviroment.cpp +++ b/Deer/src/DeerCore/Scene/Enviroment.cpp @@ -7,14 +7,14 @@ #include "DeerRender/Render/Texture.h" namespace Deer { - Environment::Environment() { + EntityEnvironment::EntityEnvironment() { m_registry = MakeScope(); createEntityWithId(0, "root"); } - Environment::~Environment() {} + EntityEnvironment::~EntityEnvironment() {} - void Environment::clear() { + void EntityEnvironment::clear() { // Clear all existing entities and map m_registry->clear(); @@ -26,23 +26,23 @@ namespace Deer { createEntityWithId(0, "root"); } - uint16_t Environment::getEntityCount() const { + uint16_t EntityEnvironment::getEntityCount() const { return entities.size() - unused_entities_spaces.size(); } - Entity& Environment::getEntity(uint16_t id) { + Entity& EntityEnvironment::getEntity(uint16_t id) { DEER_CORE_ASSERT(entityExists(id), "Entity id {0} does not exist", id); return entities[id]; } - bool Environment::entityExists(uint16_t id) const { + bool EntityEnvironment::entityExists(uint16_t id) const { if (id >= entities.size()) return false; const Entity& refEntity = entities[id]; return refEntity.isValid(); } - Entity& Environment::createEntity(const std::string& name) { + Entity& EntityEnvironment::createEntity(const std::string& name) { uint16_t id; entt::entity entityID = m_registry->create(); @@ -67,7 +67,7 @@ namespace Deer { return entity; } - Entity& Environment::createEntityWithId(uint16_t id, const std::string& name) { + Entity& EntityEnvironment::createEntityWithId(uint16_t id, const std::string& name) { entt::entity entityID = m_registry->create(); // We allocate all the memory until that id @@ -118,7 +118,7 @@ namespace Deer { return entity; } - void Environment::destroyEntity(uint16_t entityID) { + void EntityEnvironment::destroyEntity(uint16_t entityID) { DEER_CORE_ASSERT(entityExists(entityID), "Entity id {0} does not exist", entityID); DEER_CORE_ASSERT(entityID != 0, "Cannot destroy root"); @@ -141,9 +141,9 @@ namespace Deer { unused_entities_spaces.push(entityID); } - uint16_t Environment::tryGetMainCamera() const { return m_mainCamera; } + uint16_t EntityEnvironment::tryGetMainCamera() const { return m_mainCamera; } - void Environment::setMainCamera(Entity& entity) { + void EntityEnvironment::setMainCamera(Entity& entity) { if (!entity.isValid()) m_mainCamera = 0; diff --git a/Deer/src/DeerCore/Scene/EnvironmentBuilder.cpp b/Deer/src/DeerCore/Scene/EnvironmentBuilder.cpp index 7fe6106..698363c 100644 --- a/Deer/src/DeerCore/Scene/EnvironmentBuilder.cpp +++ b/Deer/src/DeerCore/Scene/EnvironmentBuilder.cpp @@ -1,8 +1,8 @@ #include "DeerCore/Enviroment.h" namespace Deer { - Scope ResourceBuilder::buildResource(const BaseDataType& baseData) { - Scope env = MakeScope(); + Scope ResourceBuilder::buildResource(const BaseDataType& baseData) { + Scope env = MakeScope(); return env; } } // namespace Deer \ No newline at end of file diff --git a/Deer/src/DeerCore/Scene/Scene.cpp b/Deer/src/DeerCore/Scene/Scene.cpp index a5f1f1c..8d7e028 100755 --- a/Deer/src/DeerCore/Scene/Scene.cpp +++ b/Deer/src/DeerCore/Scene/Scene.cpp @@ -20,6 +20,7 @@ namespace Deer { ResourceManager::unloadResources(); ResourceManager::unloadResources(); ResourceManager::unloadResources(); + ResourceManager::unloadResources(); #endif } diff --git a/Deer/src/DeerCore/Scene/SceneData.cpp b/Deer/src/DeerCore/Scene/SceneData.cpp index 4fa1bb2..1cc7522 100644 --- a/Deer/src/DeerCore/Scene/SceneData.cpp +++ b/Deer/src/DeerCore/Scene/SceneData.cpp @@ -3,7 +3,7 @@ namespace Deer { namespace Scene { - Environment environment; + EntityEnvironment environment; bool isExecuting = false; } // namespace Scene diff --git a/Deer/src/DeerCore/Scene/SceneData.h b/Deer/src/DeerCore/Scene/SceneData.h index 9c14b57..aab0190 100644 --- a/Deer/src/DeerCore/Scene/SceneData.h +++ b/Deer/src/DeerCore/Scene/SceneData.h @@ -2,10 +2,10 @@ #include "DeerCore/Tools/Memory.h" namespace Deer { - class Environment; + class EntityEnvironment; namespace Scene { - extern Environment environment; + extern EntityEnvironment environment; extern bool isExecuting; } // namespace Scene diff --git a/Deer/src/DeerCore/Scene/Serialization/EntitySerializationStruct.h b/Deer/src/DeerCore/Scene/Serialization/EntitySerializationStruct.h index a46a05d..a413323 100644 --- a/Deer/src/DeerCore/Scene/Serialization/EntitySerializationStruct.h +++ b/Deer/src/DeerCore/Scene/Serialization/EntitySerializationStruct.h @@ -2,9 +2,9 @@ #include namespace Deer { - class Environment; + class EntityEnvironment; struct EntitySerializationStruct { uint16_t entityID; - Environment* env; + EntityEnvironment* env; }; -} // namespace Deer \ No newline at end of file +} // namespace Deer \ No newline at end of file diff --git a/Deer/src/DeerCore/Scene/Serialization/EnvironmentSerialization.h b/Deer/src/DeerCore/Scene/Serialization/EnvironmentSerialization.h index c16fd5a..0b0a3d0 100755 --- a/Deer/src/DeerCore/Scene/Serialization/EnvironmentSerialization.h +++ b/Deer/src/DeerCore/Scene/Serialization/EnvironmentSerialization.h @@ -6,25 +6,25 @@ #include "EntitySerializationStruct.h" namespace Deer { - struct EnvironmentEntity { - Environment& environment; - EnvironmentEntity(Environment& env) : environment(env) {} + struct EntityEnvironmentEntity { + EntityEnvironment& environment; + EntityEnvironmentEntity(EntityEnvironment& env) : environment(env) {} }; template - void save(Archive& archive, const Deer::Environment& environment) { - EnvironmentEntity envEnt(const_cast(environment)); + void save(Archive& archive, const Deer::EntityEnvironment& environment) { + EntityEnvironmentEntity envEnt(const_cast(environment)); archive(cereal::make_nvp("entities", envEnt)); } template - void load(Archive& archive, Deer::Environment& environment) { - EnvironmentEntity envEnt(environment); + void load(Archive& archive, Deer::EntityEnvironment& environment) { + EntityEnvironmentEntity envEnt(environment); archive(cereal::make_nvp("entities", envEnt)); } template - void save(Archive& archive, EnvironmentEntity const& m_entities) { + void save(Archive& archive, EntityEnvironmentEntity const& m_entities) { archive(cereal::make_size_tag(static_cast( m_entities.environment.getEntityCount()))); @@ -35,7 +35,7 @@ namespace Deer { EntitySerializationStruct serializationStruct; serializationStruct.env = - const_cast(&m_entities.environment); + const_cast(&m_entities.environment); serializationStruct.entityID = i; archive(serializationStruct); @@ -43,7 +43,7 @@ namespace Deer { } template - void load(Archive& archive, EnvironmentEntity& m_entities) { + void load(Archive& archive, EntityEnvironmentEntity& m_entities) { cereal::size_type size; archive(cereal::make_size_tag(size)); diff --git a/Deer/src/DeerCore/Scene/Serialization/Serialization.h b/Deer/src/DeerCore/Scene/Serialization/Serialization.h index af1c1fc..762c6e5 100755 --- a/Deer/src/DeerCore/Scene/Serialization/Serialization.h +++ b/Deer/src/DeerCore/Scene/Serialization/Serialization.h @@ -12,8 +12,8 @@ #include "DeerCore/Scene/Serialization/Vec3Serialization.h" // SCENE SPECIFIC +#include "DeerCore/Scene/Serialization/EntityEnvironmentSerialization.h" #include "DeerCore/Scene/Serialization/EntitySerialization.h" -#include "DeerCore/Scene/Serialization/EnvironmentSerialization.h" // COMPONENTS SPECIFIC #include "DeerCore/Scene/Serialization/Components/RelationshipComponentSerialization.h" diff --git a/Deer/src/DeerRender/Scene/Environment.cpp b/Deer/src/DeerRender/Scene/Environment.cpp index a3b67ac..3cc13b0 100755 --- a/Deer/src/DeerRender/Scene/Environment.cpp +++ b/Deer/src/DeerRender/Scene/Environment.cpp @@ -13,7 +13,7 @@ #include "DeerRender/Log.h" namespace Deer { - void Environment::render(const SceneCamera& camera) { + void EntityEnvironment::render(const SceneCamera& camera) { glm::mat4 camMatrix = glm::inverse(camera.transform.getMatrix()); glm::mat4 projectionMatrix = camera.camera.getMatrix(); glm::mat4 invertZ = glm::scale(glm::mat4(1.0f), glm::vec3(1, 1, -1)); diff --git a/DeerStudio/headers/DeerStudio/StudioAPI/Environment.h b/DeerStudio/headers/DeerStudio/StudioAPI/Environment.h index a8a9686..4a2776a 100644 --- a/DeerStudio/headers/DeerStudio/StudioAPI/Environment.h +++ b/DeerStudio/headers/DeerStudio/StudioAPI/Environment.h @@ -7,14 +7,14 @@ namespace Deer { class SceneCamera; namespace StudioAPI { - struct EnvironmentStruct : EnvironmentHandleStruct { + struct EntityEnvironmentStruct : EntityEnvironmentHandleStruct { void render(FrameBufferHandleStruct, SceneCamera&); EntityHandleStruct getRootEntity(); EntityHandleStruct getEntity(int); }; - EnvironmentHandleStruct getMainEnvironment(); - EnvironmentHandleStruct createLoadEnvironment(std::string& envId); + EntityEnvironmentHandleStruct getMainEntityEnvironment(); + EntityEnvironmentHandleStruct createLoadEntityEnvironment(std::string& envId); } // namespace StudioAPI } // namespace Deer \ No newline at end of file diff --git a/DeerStudio/headers/DeerStudio/StudioAPI/GenericRefStructs.h b/DeerStudio/headers/DeerStudio/StudioAPI/GenericRefStructs.h index 1b47249..39f5b2b 100644 --- a/DeerStudio/headers/DeerStudio/StudioAPI/GenericRefStructs.h +++ b/DeerStudio/headers/DeerStudio/StudioAPI/GenericRefStructs.h @@ -2,11 +2,11 @@ #include "DeerRender/Tools/TypeDefs.h" namespace Deer { - class Environment; + class EntityEnvironment; namespace StudioAPI { - struct EnvironmentHandleStruct { - EnvironmentHandleStruct(int32_t _id = -1) : environmentId(_id) {} + struct EntityEnvironmentHandleStruct { + EntityEnvironmentHandleStruct(int32_t _id = -1) : environmentId(_id) {} int32_t environmentId; }; @@ -18,7 +18,7 @@ namespace Deer { int32_t environmentId; bool assertEntity(const char* funcName); - Environment* getEntityEnvironment(); + EntityEnvironment* getEntityEntityEnvironment(); }; struct FrameBufferHandleStruct { diff --git a/DeerStudio/headers/DeerStudio/StudioAPI/UI.h b/DeerStudio/headers/DeerStudio/StudioAPI/UI.h index 1fba061..18d436e 100644 --- a/DeerStudio/headers/DeerStudio/StudioAPI/UI.h +++ b/DeerStudio/headers/DeerStudio/StudioAPI/UI.h @@ -13,21 +13,7 @@ namespace Deer { extern CScriptAny* payload; } - void sameline(); - void separator(); - void disablePanelPadding(bool); - - int getAvailableSizeX(); - int getAvailableSizeY(); - - bool button(std::string&); - bool buttonCenter(std::string&); - bool buttonEnd(std::string&); - - bool cartIconButton(const std::string& label, const std::string& icon, int iconSize, int width); - bool cartIconButton_frameBuffer(const std::string& label, FrameBufferHandleStruct frameBuffer, int iconSize, int width); - - + // Text & titles void text(std::string&); void textCenter(std::string&); void textEnd(std::string&); @@ -38,6 +24,15 @@ namespace Deer { void titleEnd(std::string&); void titleCenterY(std::string&, int); + // Buttons + bool button(std::string&); + bool buttonCenter(std::string&); + bool buttonEnd(std::string&); + + bool cartIconButton(const std::string& label, const std::string& icon, int iconSize, int width); + bool cartIconButton_frameBuffer(const std::string& label, FrameBufferHandleStruct frameBuffer, int iconSize, int width); + + // Icons void drawIcon(std::string& iconId, int size); void drawIconCentered(std::string& iconId, int size); void drawIconHighlight(std::string& iconId, int size); @@ -48,9 +43,22 @@ namespace Deer { void drawIconHighlight_resource(Resource texture, int size); void drawIconCenteredHighlight_resource(Resource texture, int size); - void drawFrameBuffer(FrameBufferHandleStruct frameBuffer, int sizeX, int sizeY); - void drawFrameBufferCentered(FrameBufferHandleStruct frameBuffer, int sizeX, int sizeY); + int getIconId(const std::string& name); + // Layout & panel + void sameline(); + void separator(); + void disablePanelPadding(bool); + + void space(); + void space_params(int x, int y); + + int getAvailableSizeX(); + int getAvailableSizeY(); + + bool isPanelActive(); + + // Input widgets bool inputText(std::string& label, std::string&, std::string&); bool checkbox(std::string& label, bool); bool checkboxDisabled(std::string& label, bool); @@ -61,30 +69,31 @@ namespace Deer { float magicSlider(std::string&, float, float); glm::vec3 magicSlider3(std::string&, glm::vec3, float); + // Menus bool menuItem(std::string&); void menuItemDisabled(std::string&); void subMenu(std::string&, asIScriptFunction*); + // Drag & Drop void dragDropSource(std::string&, CScriptAny*, std::string&); void dragDropTarget(std::string&, asIScriptFunction*); + // Mouse & keyboard input state bool isItemClicked(int mouse); bool isMouseDoubleClicked(int mouse); - bool isKeyDown(int); - bool isKeyPressed(int); - bool isMouseDragging(int); float getMouseDragDeltaX(); float getMouseDragDeltaY(); float getMouseDeltaX(); float getMouseDeltaY(); - bool isPanelActive(); + bool isKeyDown(int); + bool isKeyPressed(int); - void space(); - void space_params(int x, int y); + // Rendering helpers + void drawFrameBuffer(FrameBufferHandleStruct frameBuffer, int sizeX, int sizeY); + void drawFrameBufferCentered(FrameBufferHandleStruct frameBuffer, int sizeX, int sizeY); - int getIconId(const std::string& name); } // namespace StudioAPI } // namespace Deer diff --git a/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptEngine.cpp b/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptEngine.cpp index acf3fc2..f03acd7 100644 --- a/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptEngine.cpp +++ b/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptEngine.cpp @@ -98,7 +98,7 @@ namespace Deer { void AngelScriptEngine::registerStructs() { registerMathStructs(); registerResourceStructs(); - registerEnvironmentStructs(); + registerEntityEnvironmentStructs(); registerEntityStructs(); registerEngineStructs(); registerFrameBufferStructs(); @@ -109,7 +109,7 @@ namespace Deer { registerUIFunctions(); registerMathFunctions(); registerResourceFunctions(); - registerEnvironmentFunctions(); + registerEntityEnvironmentFunctions(); registerEntityFunctions(); registerEngineFunctions(); registerFrameBufferFunctions(); diff --git a/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptRegisters.h b/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptRegisters.h index d11a442..70f77c8 100644 --- a/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptRegisters.h +++ b/DeerStudio/src/DeerStudio/AngelScriptEngine/AngelScriptRegisters.h @@ -33,7 +33,7 @@ namespace Deer { void registerUIFunctions(); void registerMathFunctions(); void registerResourceFunctions(); - void registerEnvironmentFunctions(); + void registerEntityEnvironmentFunctions(); void registerEntityFunctions(); void registerEngineFunctions(); void registerFrameBufferFunctions(); @@ -41,7 +41,7 @@ namespace Deer { void registerMathStructs(); void registerUIStructs(); void registerResourceStructs(); - void registerEnvironmentStructs(); + void registerEntityEnvironmentStructs(); void registerEntityStructs(); void registerEngineStructs(); void registerFrameBufferStructs(); diff --git a/DeerStudio/src/DeerStudio/AngelScriptEngine/ModulePredefinedGenerator.cpp b/DeerStudio/src/DeerStudio/AngelScriptEngine/ModulePredefinedGenerator.cpp index 9a773c2..48a30c8 100644 --- a/DeerStudio/src/DeerStudio/AngelScriptEngine/ModulePredefinedGenerator.cpp +++ b/DeerStudio/src/DeerStudio/AngelScriptEngine/ModulePredefinedGenerator.cpp @@ -273,7 +273,7 @@ namespace Deer { stream.clear(); stream.str(""); str.clear(); - stream << "// This file is autogenerated"; + stream << "// This file is autogenerated\n"; printFuncList(*scriptEngine); printEnumList(*scriptEngine); diff --git a/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Engine.cpp b/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Engine.cpp index cc0da66..3b25728 100644 --- a/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Engine.cpp +++ b/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Engine.cpp @@ -22,11 +22,9 @@ namespace Deer { AS_RET_CHECK(scriptEngine->RegisterInterface("Service")); - AS_CHECK(scriptEngine->RegisterFuncdef("void Callback()")); - AS_CHECK(scriptEngine->RegisterFuncdef("void AnyCallback(any@)")); - - AS_CHECK(scriptEngine->RegisterFuncdef("void ReciverFunc(any@)")); - AS_CHECK(scriptEngine->RegisterFuncdef("void TransferFunc(any@, any@)")); + AS_CHECK(scriptEngine->RegisterFuncdef("void SimpleFunction()")); + AS_CHECK(scriptEngine->RegisterFuncdef("void ReciverFunction(any@)")); + AS_CHECK(scriptEngine->RegisterFuncdef("void TransferFunction(any@, any@)")); } void AngelScriptEngine::extractBaseTypes() { diff --git a/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Environment.cpp b/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Environment.cpp index 6dbd805..6de2479 100644 --- a/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Environment.cpp +++ b/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/Environment.cpp @@ -1,22 +1,22 @@ -#include "DeerStudio/StudioAPI/Environment.h" #include "DeerStudio/AngelScriptEngine/AngelScriptRegisters.h" +#include "DeerStudio/StudioAPI/EntityEnvironment.h" namespace Deer { - void registerEnvironmentStructs(); - void registerEnvironmentFunctions(); + void registerEntityEnvironmentStructs(); + void registerEntityEnvironmentFunctions(); - void AngelScriptEngine::registerEnvironmentStructs() { - AS_CHECK(scriptEngine->RegisterObjectType("Environment", sizeof(StudioAPI::EnvironmentStruct), asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + void AngelScriptEngine::registerEntityEnvironmentStructs() { + AS_CHECK(scriptEngine->RegisterObjectType("EntityEnvironment", sizeof(StudioAPI::EntityEnvironmentStruct), asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); } - void AngelScriptEngine::registerEnvironmentFunctions() { + void AngelScriptEngine::registerEntityEnvironmentFunctions() { scriptEngine->SetDefaultNamespace("Resource"); - REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", StudioAPI::getMainEnvironment); - REGISTER_GLOBAL_FUNC("Environment createLoadEnvironment(const string&in envId)", StudioAPI::createLoadEnvironment); + REGISTER_GLOBAL_FUNC("EntityEnvironment getMainEntityEnvironment()", StudioAPI::getMainEntityEnvironment); + REGISTER_GLOBAL_FUNC("EntityEnvironment createLoadEntityEnvironment(const string&in envId)", StudioAPI::createLoadEntityEnvironment); scriptEngine->SetDefaultNamespace(""); - REGISTER_OBJECT_METHOD("Environment", "void render(FrameBuffer, SceneCamera&in)", StudioAPI::EnvironmentStruct, render); - REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", StudioAPI::EnvironmentStruct, getRootEntity); - REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", StudioAPI::EnvironmentStruct, getEntity); + REGISTER_OBJECT_METHOD("EntityEnvironment", "void render(FrameBuffer, SceneCamera&in)", StudioAPI::EntityEnvironmentStruct, render); + REGISTER_OBJECT_METHOD("EntityEnvironment", "Entity getRootEntity()", StudioAPI::EntityEnvironmentStruct, getRootEntity); + REGISTER_OBJECT_METHOD("EntityEnvironment", "Entity getEntity(int)", StudioAPI::EntityEnvironmentStruct, getEntity); } } // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/UI.cpp b/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/UI.cpp index 7fd2db3..5b9b3c7 100644 --- a/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/UI.cpp +++ b/DeerStudio/src/DeerStudio/AngelScriptEngine/Registers/UI.cpp @@ -30,7 +30,7 @@ namespace Deer { // Menus REGISTER_GLOBAL_FUNC("bool menuItem(const string& in text)", StudioAPI::menuItem); REGISTER_GLOBAL_FUNC("void menuItemDisabled(const string& in text)", StudioAPI::menuItemDisabled); - REGISTER_GLOBAL_FUNC("void subMenu(const string& in text, Callback@+ func)", StudioAPI::subMenu); + REGISTER_GLOBAL_FUNC("void subMenu(const string& in text, SimpleFunction@+ func)", StudioAPI::subMenu); // Text REGISTER_GLOBAL_FUNC("void text(const string& in text)", StudioAPI::text); @@ -90,96 +90,94 @@ namespace Deer { // Tree & Components REGISTER_GLOBAL_FUNC("void treeNodeLeaf(const string& in, bool)", StudioAPI::treeNodeLeaf); - REGISTER_GLOBAL_FUNC("bool treeNode(const string& in, bool, Callback@+)", StudioAPI::treeNode); - REGISTER_GLOBAL_FUNC("bool componentNode(const string& in, Callback@+)", StudioAPI::componentNode); - REGISTER_GLOBAL_FUNC("bool componentNodeContextMenu(const string& in, Callback@+, Callback@+)", StudioAPI::componentNodeContextMenu); + REGISTER_GLOBAL_FUNC("bool treeNode(const string& in, bool, SimpleFunction@+)", StudioAPI::treeNode); + REGISTER_GLOBAL_FUNC("bool componentNode(const string& in, SimpleFunction@+)", StudioAPI::componentNode); + REGISTER_GLOBAL_FUNC("bool componentNodeContextMenu(const string& in, SimpleFunction@+, SimpleFunction@+)", StudioAPI::componentNodeContextMenu); // Popups & Modals - REGISTER_GLOBAL_FUNC("void contextItemPopup(const string& in, Callback@+)", StudioAPI::contextItemPopup); - REGISTER_GLOBAL_FUNC("void contextMenuPopup(const string& in, Callback@+)", StudioAPI::contextMenuPopup); - REGISTER_GLOBAL_FUNC("void modalPopup(const string& in, Callback@+)", StudioAPI::modalPopup); - REGISTER_GLOBAL_FUNC("void simplePopup(const string& in, Callback@+)", StudioAPI::simplePopup); + REGISTER_GLOBAL_FUNC("void contextItemPopup(const string& in, SimpleFunction@+)", StudioAPI::contextItemPopup); + REGISTER_GLOBAL_FUNC("void contextMenuPopup(const string& in, SimpleFunction@+)", StudioAPI::contextMenuPopup); + REGISTER_GLOBAL_FUNC("void modalPopup(const string& in, SimpleFunction@+)", StudioAPI::modalPopup); + REGISTER_GLOBAL_FUNC("void simplePopup(const string& in, SimpleFunction@+)", StudioAPI::simplePopup); REGISTER_GLOBAL_FUNC("void openPopup(const string& in, any@)", StudioAPI::openPopup); REGISTER_GLOBAL_FUNC("void closePopup()", StudioAPI::closePopup); // Drag & Drop REGISTER_GLOBAL_FUNC("void dragDropSource(const string& in, any@+, const string& in)", StudioAPI::dragDropSource); - REGISTER_GLOBAL_FUNC("void dragDropTarget(const string& in, AnyCallback@+)", StudioAPI::dragDropTarget); + REGISTER_GLOBAL_FUNC("void dragDropTarget(const string& in, ReciverFunction@+)", StudioAPI::dragDropTarget); scriptEngine->SetDefaultNamespace(""); } + void AngelScriptEngine::registerUIStructs() { + AS_CHECK(scriptEngine->RegisterEnum("key")); - void AngelScriptEngine::registerUIStructs() { - AS_CHECK(scriptEngine->RegisterEnum("key")); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "A", ImGuiKey_A)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "B", ImGuiKey_B)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "C", ImGuiKey_C)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "D", ImGuiKey_D)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "E", ImGuiKey_E)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "F", ImGuiKey_F)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "G", ImGuiKey_G)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "H", ImGuiKey_H)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "I", ImGuiKey_I)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "J", ImGuiKey_J)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K", ImGuiKey_K)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "L", ImGuiKey_L)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "M", ImGuiKey_M)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "N", ImGuiKey_N)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "O", ImGuiKey_O)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "P", ImGuiKey_P)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Q", ImGuiKey_Q)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "R", ImGuiKey_R)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "S", ImGuiKey_S)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "T", ImGuiKey_T)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "U", ImGuiKey_U)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "V", ImGuiKey_V)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "W", ImGuiKey_W)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "X", ImGuiKey_X)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Y", ImGuiKey_Y)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Z", ImGuiKey_Z)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "A", ImGuiKey_A)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "B", ImGuiKey_B)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "C", ImGuiKey_C)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "D", ImGuiKey_D)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "E", ImGuiKey_E)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "F", ImGuiKey_F)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "G", ImGuiKey_G)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "H", ImGuiKey_H)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "I", ImGuiKey_I)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "J", ImGuiKey_J)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K", ImGuiKey_K)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "L", ImGuiKey_L)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "M", ImGuiKey_M)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "N", ImGuiKey_N)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "O", ImGuiKey_O)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "P", ImGuiKey_P)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Q", ImGuiKey_Q)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "R", ImGuiKey_R)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "S", ImGuiKey_S)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "T", ImGuiKey_T)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "U", ImGuiKey_U)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "V", ImGuiKey_V)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "W", ImGuiKey_W)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "X", ImGuiKey_X)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Y", ImGuiKey_Y)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Z", ImGuiKey_Z)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K0", ImGuiKey_0)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K1", ImGuiKey_1)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K2", ImGuiKey_2)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K3", ImGuiKey_3)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K4", ImGuiKey_4)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K5", ImGuiKey_5)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K6", ImGuiKey_6)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K7", ImGuiKey_7)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K8", ImGuiKey_8)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "K9", ImGuiKey_9)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K0", ImGuiKey_0)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K1", ImGuiKey_1)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K2", ImGuiKey_2)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K3", ImGuiKey_3)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K4", ImGuiKey_4)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K5", ImGuiKey_5)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K6", ImGuiKey_6)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K7", ImGuiKey_7)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K8", ImGuiKey_8)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "K9", ImGuiKey_9)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Tab", ImGuiKey_Tab)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Enter", ImGuiKey_Enter)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Escape", ImGuiKey_Escape)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Backspace", ImGuiKey_Backspace)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Space", ImGuiKey_Space)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Delete", ImGuiKey_Delete)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Insert", ImGuiKey_Insert)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Home", ImGuiKey_Home)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "End", ImGuiKey_End)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageUp", ImGuiKey_PageUp)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageDown", ImGuiKey_PageDown)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Tab", ImGuiKey_Tab)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Enter", ImGuiKey_Enter)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Escape", ImGuiKey_Escape)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Backspace", ImGuiKey_Backspace)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Space", ImGuiKey_Space)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Delete", ImGuiKey_Delete)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Insert", ImGuiKey_Insert)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Home", ImGuiKey_Home)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "End", ImGuiKey_End)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageUp", ImGuiKey_PageUp)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageDown", ImGuiKey_PageDown)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Right", ImGuiKey_RightArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Up", ImGuiKey_UpArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Down", ImGuiKey_DownArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "Left", ImGuiKey_LeftArrow)); - - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightCtrl", ImGuiKey_RightCtrl)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftShift", ImGuiKey_LeftShift)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightShift", ImGuiKey_RightShift)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftAlt", ImGuiKey_LeftAlt)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightAlt", ImGuiKey_RightAlt)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftSuper", ImGuiKey_LeftSuper)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightSuper", ImGuiKey_RightSuper)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftCtrl", ImGuiKey_LeftCtrl)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Right", ImGuiKey_RightArrow)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Up", ImGuiKey_UpArrow)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Down", ImGuiKey_DownArrow)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "Left", ImGuiKey_LeftArrow)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseLeft", ImGuiKey_MouseLeft)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseRight", ImGuiKey_MouseRight)); - AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseMiddle", ImGuiKey_MouseMiddle)); - } + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightCtrl", ImGuiKey_RightCtrl)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftShift", ImGuiKey_LeftShift)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightShift", ImGuiKey_RightShift)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftAlt", ImGuiKey_LeftAlt)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightAlt", ImGuiKey_RightAlt)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftSuper", ImGuiKey_LeftSuper)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightSuper", ImGuiKey_RightSuper)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftCtrl", ImGuiKey_LeftCtrl)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseLeft", ImGuiKey_MouseLeft)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseRight", ImGuiKey_MouseRight)); + AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseMiddle", ImGuiKey_MouseMiddle)); + } } // namespace Deer \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/StudioAPI/Entity.cpp b/DeerStudio/src/DeerStudio/StudioAPI/Entity.cpp index cb8035c..d4a2a05 100644 --- a/DeerStudio/src/DeerStudio/StudioAPI/Entity.cpp +++ b/DeerStudio/src/DeerStudio/StudioAPI/Entity.cpp @@ -9,7 +9,7 @@ #include -#define GET_ENV(env) ((env < 0) ? Scene::environment : Deer::Resource::unsafeFromId(environmentId).getData()) +#define GET_ENV(env) ((env < 0) ? Scene::environment : Deer::Resource::unsafeFromId(environmentId).getData()) #define GET_ENTITY(env, id) GET_ENV(env).getEntity(id) #define GET_MESH_COMPONENT(env, id) \ @@ -34,7 +34,7 @@ namespace Deer { namespace StudioAPI { - extern std::vector> environments; + extern std::vector> environments; EntityHandleStruct getRoot() { return EntityStruct(0); } @@ -46,14 +46,14 @@ namespace Deer { EntityStruct::EntityStruct(uint16_t _entId, int32_t _envId) : EntityHandleStruct(_entId, _envId) {} - Environment* EntityHandleStruct::getEntityEnvironment() { + EntityEnvironment* EntityHandleStruct::getEntityEntityEnvironment() { if (environmentId < 0) return &Scene::environment; - return &Resource::unsafeFromId(environmentId).getData(); + return &Resource::unsafeFromId(environmentId).getData(); } bool EntityHandleStruct::assertEntity(const char* funcName) { - Environment* env = getEntityEnvironment(); + EntityEnvironment* env = getEntityEntityEnvironment(); if (!env->entityExists(entityId)) { DEER_EDITOR_ENGINE_ERROR( "Error, invalid entity calling {0}, entityId : {1}, environmentId : {2}", @@ -196,11 +196,11 @@ namespace Deer { if (!assertEntity(funcName)) return false; - Environment* env; + EntityEnvironment* env; if (environmentId < 0) env = &Scene::environment; else - env = &Resource::unsafeFromId(environmentId).getData(); + env = &Resource::unsafeFromId(environmentId).getData(); Entity& ent = env->getEntity(entityId); @@ -241,7 +241,7 @@ namespace Deer { EntityHandleStruct EntityStruct::createChild(std::string& name) { ASSERT_ENTITY("createChild()", return *this); - Environment* entityEnv = getEntityEnvironment(); + EntityEnvironment* entityEnv = getEntityEntityEnvironment(); Entity& newEnt = entityEnv->createEntity(name); Entity& me = GET_ENTITY(environmentId, entityId); @@ -437,7 +437,7 @@ namespace Deer { bool ShaderComponentStruct::assertShaderComponent(const char* funcName) { if (!assertEntity(funcName)) return false; - Environment* env = getEntityEnvironment(); + EntityEnvironment* env = getEntityEntityEnvironment(); Entity& ent = env->getEntity(entityId); @@ -488,7 +488,7 @@ namespace Deer { bool CameraComponentStruct::assertCameraComponent(const char* funcName) { if (!assertEntity(funcName)) return false; - Environment* env = getEntityEnvironment(); + EntityEnvironment* env = getEntityEntityEnvironment(); Entity& ent = env->getEntity(entityId); diff --git a/DeerStudio/src/DeerStudio/StudioAPI/Environment.cpp b/DeerStudio/src/DeerStudio/StudioAPI/Environment.cpp index f292c8b..7080a7f 100644 --- a/DeerStudio/src/DeerStudio/StudioAPI/Environment.cpp +++ b/DeerStudio/src/DeerStudio/StudioAPI/Environment.cpp @@ -1,9 +1,9 @@ #include "DeerRender/Enviroment.h" +#include "DeerRender/Resource.h" #include "DeerRender/Scene.h" #include "DeerRender/Tools/Memory.h" -#include "DeerRender/Resource.h" -#include "DeerStudio/StudioAPI/Environment.h" +#include "DeerStudio/StudioAPI/EntityEnvironment.h" #include "DeerRender/FrameBuffer.h" #include "DeerRender/Scene.h" @@ -13,21 +13,21 @@ namespace Deer { namespace StudioAPI { // The first element has to allways point to the main scene env - std::vector environments{&Scene::environment}; + std::vector environments{&Scene::environment}; - void EnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, SceneCamera& sc) { + void EntityEnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, SceneCamera& sc) { Resource frameBufferResource = Resource::unsafeFromId(frameBuffer_handle.frameBufferId); FrameBuffer& frameBuffer = frameBufferResource.getData(); - Environment* envPtr = nullptr; + EntityEnvironment* envPtr = nullptr; if (environmentId < 0) { - envPtr = &Scene::environment; + envPtr = &Scene::environment; } else { - Resource environmentResource = Resource::unsafeFromId(environmentId); - envPtr = &environmentResource.getData(); + Resource environmentResource = Resource::unsafeFromId(environmentId); + envPtr = &environmentResource.getData(); } - Environment& env = *envPtr; + EntityEnvironment& env = *envPtr; frameBuffer.bind(); @@ -37,24 +37,23 @@ namespace Deer { frameBuffer.unbind(); } - EntityHandleStruct EnvironmentStruct::getRootEntity() { + EntityHandleStruct EntityEnvironmentStruct::getRootEntity() { return EntityHandleStruct(0, environmentId); } - EntityHandleStruct EnvironmentStruct::getEntity(int id) { + EntityHandleStruct EntityEnvironmentStruct::getEntity(int id) { return EntityHandleStruct(id, environmentId); } - EnvironmentHandleStruct getMainEnvironment() { - return EnvironmentHandleStruct(-1); + EntityEnvironmentHandleStruct getMainEntityEnvironment() { + return EntityEnvironmentHandleStruct(-1); } - EnvironmentHandleStruct createLoadEnvironment(std::string& envId) { - EnvironmentData envData; - Resource environmentResource = ResourceManager::loadResourceFromData(envData, envId); - - return EnvironmentHandleStruct(environmentResource.getResourceId()); + EntityEnvironmentHandleStruct createLoadEntityEnvironment(std::string& envId) { + EntityEnvironmentData envData; + Resource environmentResource = ResourceManager::loadResourceFromData(envData, envId); + return EntityEnvironmentHandleStruct(environmentResource.getResourceId()); } } // namespace StudioAPI } // namespace Deer \ No newline at end of file diff --git a/Editor/Modules/ActiveEntity/ActiveEntity.as b/Editor/Modules/ActiveEntity/ActiveEntity.as index 956d6ed..b6fc700 100644 --- a/Editor/Modules/ActiveEntity/ActiveEntity.as +++ b/Editor/Modules/ActiveEntity/ActiveEntity.as @@ -11,7 +11,7 @@ class ActiveEntity : Service { } void init() { - entity = Resource::getMainEnvironment().getRootEntity(); + entity = Resource::getMainEntityEnvironment().getRootEntity(); } [Expose] diff --git a/Editor/Modules/EntityManipulation/AddComponent.as b/Editor/Modules/EntityManipulation/AddComponent.as index b3ccd1f..185fd10 100644 --- a/Editor/Modules/EntityManipulation/AddComponent.as +++ b/Editor/Modules/EntityManipulation/AddComponent.as @@ -7,7 +7,7 @@ class AddComponentRender { void addComponentPopup() { UI::titleCenter("\uf055 Add Component"); UI::separator(); - UI::subMenu("Rendering", Callback(this.addComponentRendering)); + UI::subMenu("Rendering", SimpleFunction(this.addComponentRendering)); if (UI::menuItem("Script Component")) { } } diff --git a/Editor/Modules/EntityManipulation/MeshProperties.as b/Editor/Modules/EntityManipulation/MeshProperties.as index 79bfe34..a84da50 100644 --- a/Editor/Modules/EntityManipulation/MeshProperties.as +++ b/Editor/Modules/EntityManipulation/MeshProperties.as @@ -17,7 +17,7 @@ class MeshComponentRender { UI::drawIcon("empty.png", 32); } - UI::dragDropTarget("MESH", AnyCallback(this.setMesh)); + UI::dragDropTarget("MESH", ReciverFunction(this.setMesh)); if (meshComponent.hasMesh) { UI::sameline(); @@ -25,7 +25,7 @@ class MeshComponentRender { UI::sameline(); UI::titleCenterY(meshComponent.meshResource.name, 32); - UI::dragDropTarget("MESH", AnyCallback(this.setMesh)); + UI::dragDropTarget("MESH", ReciverFunction(this.setMesh)); } UI::space(20, 20); diff --git a/Editor/Modules/EntityManipulation/PropertiesPannel.as b/Editor/Modules/EntityManipulation/PropertiesPannel.as index a8f6e9c..174a550 100644 --- a/Editor/Modules/EntityManipulation/PropertiesPannel.as +++ b/Editor/Modules/EntityManipulation/PropertiesPannel.as @@ -10,7 +10,7 @@ class PropertiesPanel : Panel { // Id:0 [+ add component] UI::title("\uf1b2 " + entity.name); if (!entity.isRoot) - UI::contextItemPopup("##MenuOptions", Callback(this.renameEntityMenu)); + UI::contextItemPopup("##MenuOptions", SimpleFunction(this.renameEntityMenu)); UI::separator(); UI::textColor(0.5, 0.5, 0.5f, "Id : " + entity.id); @@ -26,21 +26,21 @@ class PropertiesPanel : Panel { UI::space(); TransformPropertiesRender transformComponentRender(entity); - UI::componentNode("\uf0b2 Transform Component", Callback(transformComponentRender.renderTransformComponent)); + UI::componentNode("\uf0b2 Transform Component", SimpleFunction(transformComponentRender.renderTransformComponent)); if (entity.hasMeshComponent()) { MeshComponentRender meshComponentRender(entity); - UI::componentNodeContextMenu("\uf248 Mesh Component", Callback(meshComponentRender.render), Callback(meshComponentRender.remove)); + UI::componentNodeContextMenu("\uf248 Mesh Component", SimpleFunction(meshComponentRender.render), SimpleFunction(meshComponentRender.remove)); } if (entity.hasShaderComponent()) { ShaderComponentRender shaderComponentRender(entity); - UI::componentNodeContextMenu("\uf248 Shader Component", Callback(shaderComponentRender.render), Callback(shaderComponentRender.remove)); + UI::componentNodeContextMenu("\uf248 Shader Component", SimpleFunction(shaderComponentRender.render), SimpleFunction(shaderComponentRender.remove)); } if (entity.hasCameraComponent()) { CameraComponentRender cameraComponentRender(entity); - UI::componentNodeContextMenu("\uf030 Camera Component", Callback(cameraComponentRender.render), Callback(cameraComponentRender.remove)); + UI::componentNodeContextMenu("\uf030 Camera Component", SimpleFunction(cameraComponentRender.render), SimpleFunction(cameraComponentRender.remove)); } UI::space(); @@ -52,8 +52,8 @@ class PropertiesPanel : Panel { } AddComponentRender addComponentRender(entity); - UI::simplePopup("ADD_COMPONENT", Callback(addComponentRender.addComponentPopup)); - UI::modalPopup("Rename entity", Callback(this.renameEntityMenu)); + UI::simplePopup("ADD_COMPONENT", SimpleFunction(addComponentRender.addComponentPopup)); + UI::modalPopup("Rename entity", SimpleFunction(this.renameEntityMenu)); } void renameEntityMenu() { diff --git a/Editor/Modules/EntityManipulation/ShaderProperties.as b/Editor/Modules/EntityManipulation/ShaderProperties.as index 401138a..294140a 100644 --- a/Editor/Modules/EntityManipulation/ShaderProperties.as +++ b/Editor/Modules/EntityManipulation/ShaderProperties.as @@ -31,7 +31,7 @@ class ShaderComponentRender { } else { UI::drawIcon("empty.png", 32); } - UI::dragDropTarget("SHADER", AnyCallback(this.setShader)); + UI::dragDropTarget("SHADER", ReciverFunction(this.setShader)); if (shaderComponent.hasShader) { UI::sameline(); @@ -39,7 +39,7 @@ class ShaderComponentRender { UI::sameline(); UI::titleCenterY(shaderComponent.shader.name, 32); - UI::dragDropTarget("SHADER", AnyCallback(this.setShader)); + UI::dragDropTarget("SHADER", ReciverFunction(this.setShader)); } UI::space(); @@ -49,7 +49,7 @@ class ShaderComponentRender { } else { UI::drawIcon("empty.png", 32); } - UI::dragDropTarget("TEXTURE", AnyCallback(this.setTexture)); + UI::dragDropTarget("TEXTURE", ReciverFunction(this.setTexture)); if (shaderComponent.texture.isValid()) { UI::sameline(); @@ -57,7 +57,7 @@ class ShaderComponentRender { UI::sameline(); UI::titleCenterY(shaderComponent.texture.name, 32); - UI::dragDropTarget("TEXTURE", AnyCallback(this.setTexture)); + UI::dragDropTarget("TEXTURE", ReciverFunction(this.setTexture)); } UI::space(20, 20); diff --git a/Editor/Modules/Previewer/MeshPreview.as b/Editor/Modules/Previewer/MeshPreview.as index 2ab801d..a0ee1ca 100644 --- a/Editor/Modules/Previewer/MeshPreview.as +++ b/Editor/Modules/Previewer/MeshPreview.as @@ -1,11 +1,11 @@ class RenderService : Service { - Environment env; + EntityEnvir nment env; SceneCamera sceneCamera; MeshComponent meshC; Entity child; void init() { - env = Resource::createLoadEnvironment("PreviewerEnv"); + env = Resource::createLoadEntityEnvironment("PreviewerEnv"); child = env.getRootEntity().createChild("Render"); meshC = child.createMeshComponent(); diff --git a/Editor/Modules/Test/ActiveEntity.as b/Editor/Modules/Test/ActiveEntity.as deleted file mode 100644 index 26ff27c..0000000 --- a/Editor/Modules/Test/ActiveEntity.as +++ /dev/null @@ -1,8 +0,0 @@ -class Test : Service { - void init() { - Engine::print("Initing"); - Entity entity = ActiveEntity::getActiveEntity(); - Engine::print(entity.name); - Engine::print("Ending"); - } -} diff --git a/Editor/Modules/Test/module.json b/Editor/Modules/Test/module.json deleted file mode 100644 index 80c3aec..0000000 --- a/Editor/Modules/Test/module.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "patch": 1, - "name": "Test", - "requires": ["ActiveEntity"] -} diff --git a/Editor/Modules/TreeExplorer/Tree.as b/Editor/Modules/TreeExplorer/Tree.as index 428dd34..f1fd1d0 100644 --- a/Editor/Modules/TreeExplorer/Tree.as +++ b/Editor/Modules/TreeExplorer/Tree.as @@ -23,7 +23,7 @@ class EntityTreeRender { interaction(); } else { // ADD ANOTHER NODE - bool opened = UI::treeNode(displayName, isActiveEntity(), Callback(this.renderChilds)); + bool opened = UI::treeNode(displayName, isActiveEntity(), SimpleFunction(this.renderChilds)); if (!opened) { interaction(); } @@ -40,8 +40,8 @@ class EntityTreeRender { void interaction() { UI::dragDropSource("ENTITY", any(entity), entity.name); - UI::dragDropTarget("ENTITY", AnyCallback(this.entityDrop)); - UI::contextItemPopup("POP_ENTITY_" + entity.id, Callback(this.renderContextMenu)); + UI::dragDropTarget("ENTITY", ReciverFunction(this.entityDrop)); + UI::contextItemPopup("POP_ENTITY_" + entity.id, SimpleFunction(this.renderContextMenu)); if (UI::isItemClicked(0)) { ActiveEntity::setActiveEntity(entity); @@ -86,7 +86,7 @@ class TreePanel : Panel { Entity root = Engine::getRoot(); EntityTreeRender rootTree(root); - UI::contextMenuPopup("Window popup", Callback(rootTree.renderContextMenu)); + UI::contextMenuPopup("Window popup", SimpleFunction(rootTree.renderContextMenu)); rootTree.renderEntity(); } } diff --git a/Editor/Modules/Viewport/Viewport.as b/Editor/Modules/Viewport/Viewport.as index 4a2dba4..825ddc3 100644 --- a/Editor/Modules/Viewport/Viewport.as +++ b/Editor/Modules/Viewport/Viewport.as @@ -1,7 +1,7 @@ class ViewportPanel : Panel { FrameBuffer frameBuffer; SceneCamera sceneCamera; - Environment mainEnv; + EntityEnvir nment mainEnv; float pitch = 0; float yaw = 0; @@ -70,7 +70,7 @@ class ViewportPanel : Panel { void init() { frameBuffer = Resource::createLoadRGBA8FrameBuffer("MainFrameBuffer", 1000, 1000); - mainEnv = Resource::getMainEnvironment(); + mainEnv = Resource::getMainEntityEnvironment(); sceneCamera.transform.position = vec3(0, 1, -2); sceneCamera.camera.nearZ = 0.1; @@ -87,7 +87,7 @@ class ViewportPanel : Panel { UI::openPopup("ViewportCameraProps", any()); } - UI::simplePopup("ViewportCameraProps", Callback(this.viewportCameraProps)); + UI::simplePopup("ViewportCameraProps", SimpleFunction(this.viewportCameraProps)); } void viewportCameraProps() {