From 564fe325920fc51b09a475b38655485ecf911f85 Mon Sep 17 00:00:00 2001 From: T-rvw <429601557@qq.com> Date: Thu, 21 Sep 2023 18:33:52 +0800 Subject: [PATCH] update --- Engine/Source/Editor/UILayers/Inspector.cpp | 5 ++++- Engine/Source/Runtime/ECWorld/StaticMeshComponent.cpp | 5 +++-- Engine/Source/Runtime/ECWorld/StaticMeshComponent.h | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Engine/Source/Editor/UILayers/Inspector.cpp b/Engine/Source/Editor/UILayers/Inspector.cpp index 6dace72c..f6b51930 100644 --- a/Engine/Source/Editor/UILayers/Inspector.cpp +++ b/Engine/Source/Editor/UILayers/Inspector.cpp @@ -92,6 +92,9 @@ void UpdateComponentWidget(engine::SceneWorld* pSce return; } + ImGuiUtils::ImGuiStringProperty("Vertex Count", std::to_string(pStaticMeshComponent->GetVertexCount())); + ImGuiUtils::ImGuiStringProperty("Triangle Count", std::to_string(static_cast(pStaticMeshComponent->GetIndexCount() / 3))); + if (!pStaticMeshComponent->IsProgressiveMeshValid()) { if (ImGui::Button(reinterpret_cast("Build ProgressiveMesh"))) @@ -101,7 +104,7 @@ void UpdateComponentWidget(engine::SceneWorld* pSce } else { - ImGuiUtils::ImGuiFloatProperty("LOD Percent", pStaticMeshComponent->GetProgressiveMeshLODPercent(), cd::Unit::None, 0.05f, 1.0f, false, 0.01f); + ImGuiUtils::ImGuiFloatProperty("LOD Percent", pStaticMeshComponent->GetProgressiveMeshReductionPercent(), cd::Unit::None, 0.05f, 1.0f, false, 0.01f); } } diff --git a/Engine/Source/Runtime/ECWorld/StaticMeshComponent.cpp b/Engine/Source/Runtime/ECWorld/StaticMeshComponent.cpp index 5350a3e9..a21a2bbd 100644 --- a/Engine/Source/Runtime/ECWorld/StaticMeshComponent.cpp +++ b/Engine/Source/Runtime/ECWorld/StaticMeshComponent.cpp @@ -110,7 +110,7 @@ void StaticMeshComponent::Reset() m_currentVertexCount = UINT32_MAX; m_totalPolygonCount = UINT32_MAX; m_currentPolygonCount = UINT32_MAX; - m_progressiveMeshLODPercent = 1.0f; + m_progressiveMeshReductionPercent = 1.0f; m_progressiveMeshVertexBuffer.clear(); m_progressiveMeshVertexBufferHandle = UINT16_MAX; @@ -362,7 +362,8 @@ void StaticMeshComponent::BuildProgressiveMeshData() void StaticMeshComponent::UpdateProgressiveMeshData() { - uint32_t lodVertexCount = static_cast(m_progressiveMeshLODPercent * m_totalVertexCount); + assert(m_progressiveMeshReductionPercent >= 0.0f && m_progressiveMeshReductionPercent <= 1.0f); + uint32_t lodVertexCount = static_cast(m_progressiveMeshReductionPercent * m_totalVertexCount); if (lodVertexCount == m_currentVertexCount) { return; diff --git a/Engine/Source/Runtime/ECWorld/StaticMeshComponent.h b/Engine/Source/Runtime/ECWorld/StaticMeshComponent.h index 5b04f747..a5ed86d7 100644 --- a/Engine/Source/Runtime/ECWorld/StaticMeshComponent.h +++ b/Engine/Source/Runtime/ECWorld/StaticMeshComponent.h @@ -70,8 +70,8 @@ class StaticMeshComponent final bool IsProgressiveMeshValid() const { return m_progressiveMeshIndexBufferHandle != UINT16_MAX; } uint16_t GetProgressiveMeshIndexBuffer() const { return m_progressiveMeshIndexBufferHandle; } void BuildProgressiveMeshData(); - float GetProgressiveMeshLODPercent() const { return m_progressiveMeshLODPercent; } - float& GetProgressiveMeshLODPercent() { return m_progressiveMeshLODPercent; } + float GetProgressiveMeshReductionPercent() const { return m_progressiveMeshReductionPercent; } + float& GetProgressiveMeshReductionPercent() { return m_progressiveMeshReductionPercent; } void UpdateProgressiveMeshData(); private: @@ -91,7 +91,7 @@ class StaticMeshComponent final uint32_t m_currentVertexCount = UINT32_MAX; uint32_t m_totalPolygonCount = UINT32_MAX; uint32_t m_currentPolygonCount = UINT32_MAX; - float m_progressiveMeshLODPercent = 1.0f; + float m_progressiveMeshReductionPercent = 1.0f; std::vector m_permutation; std::vector m_map; #endif