Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw committed Sep 23, 2023
1 parent 00c520a commit 03c46ba
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 32 deletions.
10 changes: 5 additions & 5 deletions Engine/Source/Editor/UILayers/AssetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))
{
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<int>(cd::MaterialTextureType::Count); ++textureTypeIndex)
for (int textureTypeIndex = 0; textureTypeIndex < nameof::enum_count<cd::MaterialTextureType>(); ++textureTypeIndex)
{
material.RemoveTexture(static_cast<cd::MaterialTextureType>(textureTypeIndex));
}
Expand Down
22 changes: 0 additions & 22 deletions Engine/Source/Editor/UILayers/AssetBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(IOAssetType::Count) == sizeof(IOAssetTypeName) / sizeof(char*),
"IO asset type and names mismatch.");

CD_FORCEINLINE const char* GetIOAssetTypeName(IOAssetType type)
{
return IOAssetTypeName[static_cast<size_t>(type)];
}

struct AssetImportOptions
{
IOAssetType AssetType = IOAssetType::Unknown;
Expand Down
4 changes: 2 additions & 2 deletions Engine/Source/Editor/UILayers/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void UpdateComponentWidget<engine::MaterialComponent>(engine::SceneWorld* pScene
}

// Textures
for (int textureTypeValue = 0; textureTypeValue < static_cast<int>(cd::MaterialTextureType::Count); ++textureTypeValue)
for (int textureTypeValue = 0; textureTypeValue < nameof::enum_count<cd::MaterialTextureType>(); ++textureTypeValue)
{
auto textureType = static_cast<cd::MaterialTextureType>(textureTypeValue);
bool allowNoTextures = textureType == cd::MaterialTextureType::BaseColor ||
Expand Down Expand Up @@ -386,7 +386,7 @@ void UpdateComponentWidget<engine::LightComponent>(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());
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/ECWorld/SceneWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <static_cast<int>(cd::MaterialTextureType::Count); ++textureTypeValue)
for (int textureTypeValue = 0; textureTypeValue < nameof::enum_count<cd::MaterialTextureType>(); ++textureTypeValue)
{
if (MaterialComponent::TextureInfo* textureInfo = pMaterialComponent->GetTextureInfo(static_cast<cd::MaterialPropertyGroup>(textureTypeValue)))
{
Expand Down
3 changes: 2 additions & 1 deletion Engine/Source/Runtime/ImGui/ImGuiUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Math/UnitSystem.hpp"

#include <imgui/imgui.h>

namespace ImGuiUtils
{

Expand All @@ -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<std::decay_t<EnumType>>;
auto enumCount = nameof::enum_count<EnumType>();
for (uint32_t enumIndex = 0U; enumIndex < enumCount; ++enumIndex)
{
EnumType enumValue = static_cast<EnumType>(enumIndex);
Expand Down

0 comments on commit 03c46ba

Please sign in to comment.