From 1a05b8970c46b9f2c8130fd1584e186ae95c9ce7 Mon Sep 17 00:00:00 2001 From: Evgeny Prikazchikov Date: Sun, 1 Feb 2026 22:22:42 +0300 Subject: [PATCH] Editor: Unable to render icons for imported sprites #1246 --- engine/includes/editor/assetconverter.h | 5 +++++ engine/src/editor/assetconverter.cpp | 15 ++++++++++++++- engine/src/editor/assetmanager.cpp | 16 ++++++++-------- .../particletools/converter/effectbuilder.cpp | 1 + .../editor/particletools/editor/particleedit.cpp | 2 +- .../editor/shadertools/editor/materialedit.ui | 2 +- .../src/managers/assetimporter/iconrender.cpp | 12 ++++++++---- 7 files changed, 38 insertions(+), 15 deletions(-) diff --git a/engine/includes/editor/assetconverter.h b/engine/includes/editor/assetconverter.h index fe880783f..7a4b0f000 100644 --- a/engine/includes/editor/assetconverter.h +++ b/engine/includes/editor/assetconverter.h @@ -53,6 +53,9 @@ class ENGINE_EXPORT AssetConverterSettings : public Object { AssetConverterSettings(); ~AssetConverterSettings(); + AssetConverter *converter(); + void setConverter(AssetConverter *converter); + uint32_t type() const; virtual StringList typeNames() const; @@ -139,6 +142,8 @@ class ENGINE_EXPORT AssetConverterSettings : public Object { static std::map m_defaultIcons; + AssetConverter *m_converter; + }; #endif // ASSETCONVERTER_H diff --git a/engine/src/editor/assetconverter.cpp b/engine/src/editor/assetconverter.cpp index 87802b3fa..4d5da5754 100644 --- a/engine/src/editor/assetconverter.cpp +++ b/engine/src/editor/assetconverter.cpp @@ -45,12 +45,25 @@ AssetConverterSettings::AssetConverterSettings() : m_modified(false), m_dir(false), m_version(0), - m_currentVersion(0) { + m_currentVersion(0), + m_converter(nullptr) { } AssetConverterSettings::~AssetConverterSettings() { +} +/*! + Returns assotiated AssetConverter. +*/ +AssetConverter *AssetConverterSettings::converter() { + return m_converter; +} +/*! + Sets assotiated asset \a converter. +*/ +void AssetConverterSettings::setConverter(AssetConverter *converter) { + m_converter = converter; } /*! Returns the asset type for conversion for more details see MetaType. diff --git a/engine/src/editor/assetmanager.cpp b/engine/src/editor/assetmanager.cpp index d4d9960c5..9878d45ff 100644 --- a/engine/src/editor/assetmanager.cpp +++ b/engine/src/editor/assetmanager.cpp @@ -309,12 +309,12 @@ AssetConverterSettings *AssetManager::fetchSettings(const TString &source) { AssetConverterSettings *settings = nullptr; if(!path.isEmpty() && File::exists(source)) { - TString suffix(Url(source).completeSuffix().toLower()); - auto it = m_converters.find(suffix); - - if(it != m_converters.end()) { - settings = it->second->createSettings(); + AssetConverter *converter = getConverter(source); + if(converter) { + settings = converter->createSettings(); + settings->setConverter(converter); } else { + TString suffix(Url(source).suffix().toLower()); CodeBuilder *currentBuilder = m_projectManager->currentBuilder(); CodeBuilder *builder = nullptr; for(auto it : m_builders) { @@ -424,7 +424,7 @@ Actor *AssetManager::createActor(const TString &source) { if(!source.isEmpty()) { TString uuid; TString path = source; - if(source.at(0) == '{') { + if(source.front() == '{') { uuid = source; path = uuidToPath(uuid); } else { @@ -433,7 +433,7 @@ Actor *AssetManager::createActor(const TString &source) { AssetConverterSettings *settings = fetchSettings(path); if(settings) { - AssetConverter *converter = getConverter(path); + AssetConverter *converter = settings->converter(); if(converter) { return converter->createActor(settings, uuid); } @@ -534,7 +534,7 @@ void AssetManager::onPerform() { } AssetConverter *AssetManager::getConverter(const TString &source) { - auto it = m_converters.find(Url(source).suffix().toLower()); + auto it = m_converters.find(Url(source).completeSuffix().toLower()); if(it != m_converters.end()) { return it->second; } diff --git a/modules/editor/particletools/converter/effectbuilder.cpp b/modules/editor/particletools/converter/effectbuilder.cpp index 1d5082dac..92b8378f7 100644 --- a/modules/editor/particletools/converter/effectbuilder.cpp +++ b/modules/editor/particletools/converter/effectbuilder.cpp @@ -49,6 +49,7 @@ float EffectBuilderSettings::thumbnailWarmup() const { void EffectBuilderSettings::setThumbnailWarmup(float value) { if(m_thumbnailWarmup != value) { m_thumbnailWarmup = value; + setModified(); } } diff --git a/modules/editor/particletools/editor/particleedit.cpp b/modules/editor/particletools/editor/particleedit.cpp index eba87e4b3..1dce467af 100644 --- a/modules/editor/particletools/editor/particleedit.cpp +++ b/modules/editor/particletools/editor/particleedit.cpp @@ -65,7 +65,7 @@ class ParticleProxy : public Object { ParticleEdit::ParticleEdit() : ui(new Ui::ParticleEdit), m_builder(new EffectBuilder), - m_controller(new CameraController()), + m_controller(new CameraController), m_light(nullptr), m_effect(nullptr), m_render(nullptr), diff --git a/modules/editor/shadertools/editor/materialedit.ui b/modules/editor/shadertools/editor/materialedit.ui index 426403643..845f844fb 100644 --- a/modules/editor/shadertools/editor/materialedit.ui +++ b/modules/editor/shadertools/editor/materialedit.ui @@ -7,7 +7,7 @@ 0 0 1024 - 800 + 600 diff --git a/worldeditor/src/managers/assetimporter/iconrender.cpp b/worldeditor/src/managers/assetimporter/iconrender.cpp index 5f882f1fb..430d55918 100644 --- a/worldeditor/src/managers/assetimporter/iconrender.cpp +++ b/worldeditor/src/managers/assetimporter/iconrender.cpp @@ -83,15 +83,19 @@ const QImage IconRender::render(const TString &uuid) { m_render->update(m_world); + QImage result; + if(m_color) { ByteArray data(m_color->getPixels(0)); - QImage result(data.data(), m_color->width(), m_color->height(), QImage::Format_RGBA8888); + result = QImage(data.data(), m_color->width(), m_color->height(), QImage::Format_RGBA8888); + + result = result.mirrored(); + } + if(object) { object->setParent(nullptr); delete object; - - return result.mirrored(); } - return QImage(); + return result; }