From 03c46ba712ad459cd00e81c88b7c1b32c73b4b73 Mon Sep 17 00:00:00 2001 From: "t.rvw" <429601557@qq.com> Date: Sat, 23 Sep 2023 19:55:24 +0800 Subject: [PATCH] update --- .../Source/Editor/UILayers/AssetBrowser.cpp | 10 ++++----- Engine/Source/Editor/UILayers/AssetBrowser.h | 22 ------------------- Engine/Source/Editor/UILayers/Inspector.cpp | 4 ++-- Engine/Source/Runtime/ECWorld/SceneWorld.cpp | 2 +- Engine/Source/Runtime/ImGui/ImGuiUtils.hpp | 3 ++- Engine/Source/ThirdParty/AssetPipeline | 2 +- 6 files changed, 11 insertions(+), 32 deletions(-) diff --git a/Engine/Source/Editor/UILayers/AssetBrowser.cpp b/Engine/Source/Editor/UILayers/AssetBrowser.cpp index 898b8c95..0c17ca7e 100644 --- a/Engine/Source/Editor/UILayers/AssetBrowser.cpp +++ b/Engine/Source/Editor/UILayers/AssetBrowser.cpp @@ -348,7 +348,7 @@ void AssetBrowser::UpdateAssetFolderTree() //m_pImportFileBrowser->SetTypeFilters({ ".dds", "*.exr", "*.hdr", "*.ktx", ".tga" }); m_pImportFileBrowser->Open(); - CD_INFO("Import asset type: {}", GetIOAssetTypeName(m_importOptions.AssetType)); + CD_INFO("Import asset type: {}", nameof::nameof_enum(m_importOptions.AssetType)); } else if (ImGui::Selectable("Shader")) @@ -358,7 +358,7 @@ void AssetBrowser::UpdateAssetFolderTree() //m_pImportFileBrowser->SetTypeFilters({ ".sc" }); // ".hlsl" m_pImportFileBrowser->Open(); - CD_INFO("Import asset type: {}", GetIOAssetTypeName(m_importOptions.AssetType)); + CD_INFO("Import asset type: {}", nameof::nameof_enum(m_importOptions.AssetType)); } else if (ImGui::Selectable("Model")) { @@ -367,7 +367,7 @@ void AssetBrowser::UpdateAssetFolderTree() //m_pImportFileBrowser->SetTypeFilters({ ".fbx", ".gltf" }); // ".obj", ".dae", ".ogex" m_pImportFileBrowser->Open(); - CD_INFO("Import asset type: {}", GetIOAssetTypeName(m_importOptions.AssetType)); + CD_INFO("Import asset type: {}", nameof::nameof_enum(m_importOptions.AssetType)); } #ifdef ENABLE_DDGI @@ -402,7 +402,7 @@ void AssetBrowser::UpdateAssetFolderTree() m_pExportFileBrowser->SetTitle("ExportAssets - SceneDatabase"); m_pExportFileBrowser->Open(); - CD_INFO("Export asset type: {}", GetIOAssetTypeName(m_exportOptions.AssetType)); + CD_INFO("Export asset type: {}", nameof::nameof_enum(m_exportOptions.AssetType)); } ImGui::EndPopup(); @@ -875,7 +875,7 @@ void AssetBrowser::ProcessSceneDatabase(cd::SceneDatabase* pSceneDatabase, bool pSceneDatabase->GetTextures().clear(); for (auto& material : pSceneDatabase->GetMaterials()) { - for (int textureTypeIndex = 0; textureTypeIndex < static_cast(cd::MaterialTextureType::Count); ++textureTypeIndex) + for (int textureTypeIndex = 0; textureTypeIndex < nameof::enum_count(); ++textureTypeIndex) { material.RemoveTexture(static_cast(textureTypeIndex)); } diff --git a/Engine/Source/Editor/UILayers/AssetBrowser.h b/Engine/Source/Editor/UILayers/AssetBrowser.h index ad18a10c..3fb19549 100644 --- a/Engine/Source/Editor/UILayers/AssetBrowser.h +++ b/Engine/Source/Editor/UILayers/AssetBrowser.h @@ -39,30 +39,8 @@ enum class IOAssetType Terrain, Light, Unknown, - - Count, -}; - -constexpr const char *IOAssetTypeName[] = -{ - "CubeMap", - "DDGIModel", - "Model", - "Shader", - "SceneDatabase", - "Terrain", - "Light", - "Unknown", }; -static_assert(static_cast(IOAssetType::Count) == sizeof(IOAssetTypeName) / sizeof(char*), - "IO asset type and names mismatch."); - -CD_FORCEINLINE const char* GetIOAssetTypeName(IOAssetType type) -{ - return IOAssetTypeName[static_cast(type)]; -} - struct AssetImportOptions { IOAssetType AssetType = IOAssetType::Unknown; diff --git a/Engine/Source/Editor/UILayers/Inspector.cpp b/Engine/Source/Editor/UILayers/Inspector.cpp index 8594b27d..821f9a3b 100644 --- a/Engine/Source/Editor/UILayers/Inspector.cpp +++ b/Engine/Source/Editor/UILayers/Inspector.cpp @@ -200,7 +200,7 @@ void UpdateComponentWidget(engine::SceneWorld* pScene } // Textures - for (int textureTypeValue = 0; textureTypeValue < static_cast(cd::MaterialTextureType::Count); ++textureTypeValue) + for (int textureTypeValue = 0; textureTypeValue < nameof::enum_count(); ++textureTypeValue) { auto textureType = static_cast(textureTypeValue); bool allowNoTextures = textureType == cd::MaterialTextureType::BaseColor || @@ -386,7 +386,7 @@ void UpdateComponentWidget(engine::SceneWorld* pSceneWor if (isOpen) { cd::LightType lightType = pLightComponent->GetType(); - std::string lightTypeName = cd::GetLightTypeName(lightType); + std::string lightTypeName(nameof::nameof_enum(lightType)); ImGuiUtils::ImGuiStringProperty("Type", lightTypeName); ImGuiUtils::ColorPickerProperty("Color", pLightComponent->GetColor()); diff --git a/Engine/Source/Runtime/ECWorld/SceneWorld.cpp b/Engine/Source/Runtime/ECWorld/SceneWorld.cpp index 080c99cc..6d69e27f 100644 --- a/Engine/Source/Runtime/ECWorld/SceneWorld.cpp +++ b/Engine/Source/Runtime/ECWorld/SceneWorld.cpp @@ -251,7 +251,7 @@ void SceneWorld::AddMaterialToSceneDatabase(engine::Entity entity) pMaterialData->SetFloatProperty(cd::MaterialPropertyGroup::Roughness, cd::MaterialProperty::Factor, pMaterialComponent->GetRoughnessFactor()); pMaterialData->SetBoolProperty(cd::MaterialPropertyGroup::General, cd::MaterialProperty::TwoSided, pMaterialComponent->GetTwoSided()); - for (int textureTypeValue = 0; textureTypeValue (cd::MaterialTextureType::Count); ++textureTypeValue) + for (int textureTypeValue = 0; textureTypeValue < nameof::enum_count(); ++textureTypeValue) { if (MaterialComponent::TextureInfo* textureInfo = pMaterialComponent->GetTextureInfo(static_cast(textureTypeValue))) { diff --git a/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp b/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp index 3b440c1b..d929a147 100644 --- a/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp +++ b/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp @@ -7,6 +7,7 @@ #include "Math/UnitSystem.hpp" #include + namespace ImGuiUtils { @@ -27,7 +28,7 @@ static bool ImGuiEnumProperty(const char* pName, EnumType& value) if (ImGui::BeginCombo("##combo", nameof::nameof_enum(value).data())) { - auto enumCount = nameof::detail::count_v>; + auto enumCount = nameof::enum_count(); for (uint32_t enumIndex = 0U; enumIndex < enumCount; ++enumIndex) { EnumType enumValue = static_cast(enumIndex); diff --git a/Engine/Source/ThirdParty/AssetPipeline b/Engine/Source/ThirdParty/AssetPipeline index a136b098..c5ad7de0 160000 --- a/Engine/Source/ThirdParty/AssetPipeline +++ b/Engine/Source/ThirdParty/AssetPipeline @@ -1 +1 @@ -Subproject commit a136b09867907e5adf72fa3d72602f05a60bf4eb +Subproject commit c5ad7de0bde5229052423badc9f2d40cfd79472c