From f883d6ae6c2f067894c2de9ea5237e6349bae9cb Mon Sep 17 00:00:00 2001 From: brenocq Date: Sun, 14 Aug 2022 19:27:29 +0200 Subject: [PATCH] Fix: Implot not initialized #29 --- scripts/build.sh | 12 ++++++----- src/atta/component/factory.cpp | 8 ++++++++ src/atta/component/factory.h | 12 ++++++----- src/atta/component/manager.cpp | 6 ++---- src/atta/graphics/drawer.cpp | 20 +++++++++++++------ src/atta/graphics/drawer.h | 8 ++++---- src/atta/resource/manager.cpp | 2 -- src/atta/script/compilers/linuxCompiler.cpp | 8 ++++---- src/atta/script/linkers/linuxLinker.cpp | 2 +- src/atta/ui/layers/editor/editorLayer.cpp | 4 +++- .../ui/layers/editor/windows/logWindow.cpp | 2 +- src/atta/ui/layers/uiLayer.cpp | 4 ++-- 12 files changed, 53 insertions(+), 35 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 6268e597..b821d42b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -5,8 +5,9 @@ SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" SOURCE_PATH="$SCRIPT_PATH/.." BUILD_PATH="$SOURCE_PATH/build" CMAKE_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Release" -BUILD_PATH_TYPE="" -BUILD_PATH_SUFIX="release" +BUILD_NAME_PREFIX="" +BUILD_NAME="release" +BUILD_NAME_SUFIX="" CMAKE_ATTA_STATIC="" BUILD_TYPE="default" RUN_AFTER="false" @@ -139,7 +140,7 @@ while [[ $# -gt 0 ]]; do ;; -d|--debug) CMAKE_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Debug" - BUILD_PATH_SUFIX="debug" + BUILD_NAME="debug" shift # past argument ;; -g|--gdb) @@ -163,13 +164,14 @@ while [[ $# -gt 0 ]]; do -t|--type) BUILD_TYPE="$2" if [[ "$BUILD_TYPE" != "default" ]]; then - BUILD_PATH_TYPE="$BUILD_TYPE-" + BUILD_NAME_PREFIX="$BUILD_TYPE-" fi shift # past argument shift # past value ;; -s|--static) CMAKE_ATTA_STATIC="-DATTA_STATIC_PROJECT_FILE=$2" + BUILD_NAME_SUFIX="-static" shift # past argument shift # past value ;; @@ -182,7 +184,7 @@ done # Change to build directory -BUILD_PATH="$BUILD_PATH/$BUILD_PATH_TYPE$BUILD_PATH_SUFIX" +BUILD_PATH="$BUILD_PATH/$BUILD_NAME_PREFIX$BUILD_NAME$BUILD_NAME_SUFIX" mkdir -p $BUILD_PATH && cd $BUILD_PATH # Build diff --git a/src/atta/component/factory.cpp b/src/atta/component/factory.cpp index eb05cccf..7bbf835f 100644 --- a/src/atta/component/factory.cpp +++ b/src/atta/component/factory.cpp @@ -104,6 +104,14 @@ void Factory::runScripts(float dt) { //} } +EntityId Factory::getPrototypeId() const { return _prototypeId; } +EntityId Factory::getFirstCloneId() const { return _firstCloneEid; } +Entity Factory::getFirstClone() const { return Entity{_firstCloneEid}; } +Entity Factory::getLastClone() const { return Entity{_firstCloneEid + static_cast(_maxClones) - 1}; } +uint64_t Factory::getMaxClones() const { return _maxClones; } +uint64_t Factory::getNumClones() const { return _maxClones; } +std::vector>& Factory::getComponentMemories() { return _componentMemories; } + std::vector Factory::getComponentsIds() const { std::vector components; diff --git a/src/atta/component/factory.h b/src/atta/component/factory.h index 550ebd8d..63977246 100644 --- a/src/atta/component/factory.h +++ b/src/atta/component/factory.h @@ -23,13 +23,15 @@ class Factory { T* getComponent(uint64_t cloneId = 0); void runScripts(float dt); - EntityId getPrototypeId() const { return _prototypeId; } - EntityId getFirstCloneId() const { return _firstCloneEid; } + EntityId getPrototypeId() const; + EntityId getFirstCloneId() const; std::vector getClones() const; std::vector getCloneIds() const; - uint64_t getMaxClones() const { return _maxClones; } - uint64_t getNumClones() const { return _maxClones; } - std::vector>& getComponentMemories() { return _componentMemories; } + Entity getFirstClone() const; + Entity getLastClone() const; + uint64_t getMaxClones() const; + uint64_t getNumClones() const; + std::vector>& getComponentMemories(); std::vector getComponentsIds() const; std::vector getMemories() const; diff --git a/src/atta/component/manager.cpp b/src/atta/component/manager.cpp index e10c6d00..8211c7ab 100644 --- a/src/atta/component/manager.cpp +++ b/src/atta/component/manager.cpp @@ -275,7 +275,6 @@ void Manager::registerComponentImpl(ComponentRegistry* componentRegistry) { } if (oldIndex == -1) { - LOG_DEBUG("component::Manager", "Registered component [w]$0[]", componentRegistry->getTypeidName()); componentRegistry->setIndex(_componentRegistries.size()); _componentRegistries.push_back(componentRegistry); @@ -309,7 +308,6 @@ void Manager::createComponentPoolsFromRegistered() { for (auto reg : _componentRegistries) { // TODO Remove custom component registry when it is not loaded (pointer to random data) if (!reg->getPoolCreated()) { - LOG_DEBUG("component::Manager", "Create component pool [w]$0[]", reg->getDescription().name); createComponentPool(reg); reg->setPoolCreated(true); } @@ -329,8 +327,8 @@ void Manager::createComponentPool(ComponentRegistry* componentRegistry) { uint8_t* componentMemory = reinterpret_cast(_allocator->allocBytes(size, sizeofT)); DASSERT(componentMemory != nullptr, "Could not allocate component system memory for " + name); - LOG_INFO("component::Manager", "Allocated memory for component $0 ($1). $2MB ($5 instances) -> memory space:($3 $4)", name, typeidTName, - maxCount * sizeofT / (1024 * 1024.0f), (void*)(componentMemory), (void*)(componentMemory + maxCount * sizeofT), maxCount); + //LOG_INFO("component::Manager", "Allocated memory for component $0 ($1). $2MB ($5 instances) -> memory space:($3 $4)", name, typeidTName, + // maxCount * sizeofT / (1024 * 1024.0f), (void*)(componentMemory), (void*)(componentMemory + maxCount * sizeofT), maxCount); // Create pool allocator memory::registerAllocator(COMPONENT_POOL_SSID_BY_NAME(typeidTName), diff --git a/src/atta/graphics/drawer.cpp b/src/atta/graphics/drawer.cpp index d601bef4..84a73f71 100644 --- a/src/atta/graphics/drawer.cpp +++ b/src/atta/graphics/drawer.cpp @@ -48,12 +48,20 @@ Drawer& Drawer::getInstance() { return drawer; } -void Drawer::clear() { getInstance().clearImpl(); } -void Drawer::clearImpl() { - _currNumberOfLines = 0; - _currNumberOfPoints = 0; - _linesChanged = false; - _pointsChanged = false; +void Drawer::clear(StringId group) { getInstance().clearImpl(group); } +void Drawer::clearImpl(StringId group) { + if(group == "No group"_sid) + { + _currNumberOfLines = 0; + _currNumberOfPoints = 0; + _linesChanged = false; + _pointsChanged = false; + } + else + { + clearImpl(group); + clearImpl(group); + } } } // namespace atta::graphics diff --git a/src/atta/graphics/drawer.h b/src/atta/graphics/drawer.h index 3c21ed00..baabe803 100644 --- a/src/atta/graphics/drawer.h +++ b/src/atta/graphics/drawer.h @@ -41,7 +41,7 @@ class Drawer { static void add(T obj, StringId group = StringId("No group")); template static void clear(StringId group = StringId("No group")); // Clear lines or points of specific group - static void clear(); // Clear all lines and points + static void clear(StringId group = StringId("No group")); // Clear specific group or all groups // Get data template @@ -65,10 +65,10 @@ class Drawer { // Draw 3d objects implementation template - void addImpl(T obj, StringId group = StringId("No group")); + void addImpl(T obj, StringId group); template - void clearImpl(StringId group = StringId("No group")); - void clearImpl(); + void clearImpl(StringId group); + void clearImpl(StringId group); // Get data implementation template diff --git a/src/atta/resource/manager.cpp b/src/atta/resource/manager.cpp index 892ed4b5..9bbbf343 100644 --- a/src/atta/resource/manager.cpp +++ b/src/atta/resource/manager.cpp @@ -54,14 +54,12 @@ void Manager::loadResourcesRecursively(fs::path directory) { // Load as meshe for (auto& extension : meshExtensions) if (extension == file.extension().string()) { - LOG_DEBUG("resource::Manager", "Resource mesh: [w]$0[]", file.string()); resource::get(file.string()); break; } // Load as image for (auto& extension : imageExtensions) if (extension == file.extension().string()) { - LOG_DEBUG("resource::Manager", "Resource image: [w]$0[]", file.string()); resource::get(file.string()); break; } diff --git a/src/atta/script/compilers/linuxCompiler.cpp b/src/atta/script/compilers/linuxCompiler.cpp index a3c61244..222d565b 100644 --- a/src/atta/script/compilers/linuxCompiler.cpp +++ b/src/atta/script/compilers/linuxCompiler.cpp @@ -23,7 +23,7 @@ LinuxCompiler::~LinuxCompiler() {} void LinuxCompiler::compileAll() { std::chrono::time_point begin = std::chrono::system_clock::now(); - LOG_DEBUG("script::LinuxCompiler", "Compile all targets"); + //LOG_DEBUG("script::LinuxCompiler", "Compile all targets"); fs::path projectDir = file::getProject()->getDirectory(); fs::path buildDir = projectDir / "build"; @@ -54,13 +54,13 @@ void LinuxCompiler::compileAll() { // Show time std::chrono::time_point end = std::chrono::system_clock::now(); auto micro = std::chrono::duration_cast(end - begin); - LOG_INFO("script::LinuxCompiler", "Time to compile all: $0 ms", micro.count() / 1000.0f); + //LOG_INFO("script::LinuxCompiler", "Time to compile all: $0 ms", micro.count() / 1000.0f); } void LinuxCompiler::compileTarget(StringId target) { std::chrono::time_point begin = std::chrono::system_clock::now(); - LOG_DEBUG("script::LinuxCompiler", "Compile target $0", target); + //LOG_DEBUG("script::LinuxCompiler", "Compile target $0", target); // Check target if (_targetFiles.find(target) == _targetFiles.end()) { LOG_WARN("script::LinuxCompiler", "Could not find target $0", target); @@ -95,7 +95,7 @@ void LinuxCompiler::compileTarget(StringId target) { // Show time std::chrono::time_point end = std::chrono::system_clock::now(); auto micro = std::chrono::duration_cast(end - begin); - LOG_INFO("script::LinuxCompiler", "Time to compile target $1: $0 ms", micro.count() / 1000.0f, target); + //LOG_INFO("script::LinuxCompiler", "Time to compile target $1: $0 ms", micro.count() / 1000.0f, target); } void LinuxCompiler::updateTargets() { diff --git a/src/atta/script/linkers/linuxLinker.cpp b/src/atta/script/linkers/linuxLinker.cpp index 4a4f9518..a367e25b 100644 --- a/src/atta/script/linkers/linuxLinker.cpp +++ b/src/atta/script/linkers/linuxLinker.cpp @@ -60,7 +60,7 @@ void LinuxLinker::linkTarget(StringId target, Script** script, ProjectScript** p type = "Script " + name; else type = "Component"; - LOG_INFO("script::LinuxLinker", "Time to link [w]$0[]: $1 ms ($2)", target, micro.count() / 1000.0f, type); + //LOG_INFO("script::LinuxLinker", "Time to link [w]$0[]: $1 ms ($2)", target, micro.count() / 1000.0f, type); } else { LOG_WARN("script::LinuxLinker", "Cannot open library $0. Error: $1", lib.filename(), dlerror()); return; diff --git a/src/atta/ui/layers/editor/editorLayer.cpp b/src/atta/ui/layers/editor/editorLayer.cpp index 1c9d9fe9..90ede6d1 100644 --- a/src/atta/ui/layers/editor/editorLayer.cpp +++ b/src/atta/ui/layers/editor/editorLayer.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -33,8 +34,9 @@ void EditorLayer::onUIRender() { _dockSpace.render(); // Demo - // bool demo = true; + bool demo = true; // ImGui::ShowDemoWindow(&demo); + // ImPlot::ShowDemoWindow(&demo); // Top interface _topBar.render(); diff --git a/src/atta/ui/layers/editor/windows/logWindow.cpp b/src/atta/ui/layers/editor/windows/logWindow.cpp index afe95b74..4c9cee40 100644 --- a/src/atta/ui/layers/editor/windows/logWindow.cpp +++ b/src/atta/ui/layers/editor/windows/logWindow.cpp @@ -6,12 +6,12 @@ //-------------------------------------------------- #include #include +#include namespace atta::ui { void LogWindow::render() { ImGui::Begin("Log"); - ImGui::Text("Logging not implemented yet"); ImGui::End(); } diff --git a/src/atta/ui/layers/uiLayer.cpp b/src/atta/ui/layers/uiLayer.cpp index 9b16c9b8..5a69d7a4 100644 --- a/src/atta/ui/layers/uiLayer.cpp +++ b/src/atta/ui/layers/uiLayer.cpp @@ -8,10 +8,9 @@ // ImGui backends #include #include -// ImGui window managing #include -// ImGuizmo #include +#include namespace atta::ui { @@ -20,6 +19,7 @@ UILayer::UILayer() : graphics::Layer(StringId("GraphicsLayerUI")) {} void UILayer::onAttach() { IMGUI_CHECKVERSION(); ImGui::CreateContext(); + ImPlot::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io;