Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw committed Sep 21, 2023
1 parent d0c9352 commit 564fe32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Engine/Source/Editor/UILayers/Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ void UpdateComponentWidget<engine::StaticMeshComponent>(engine::SceneWorld* pSce
return;
}

ImGuiUtils::ImGuiStringProperty("Vertex Count", std::to_string(pStaticMeshComponent->GetVertexCount()));
ImGuiUtils::ImGuiStringProperty("Triangle Count", std::to_string(static_cast<uint32_t>(pStaticMeshComponent->GetIndexCount() / 3)));

if (!pStaticMeshComponent->IsProgressiveMeshValid())
{
if (ImGui::Button(reinterpret_cast<const char*>("Build ProgressiveMesh")))
Expand All @@ -101,7 +104,7 @@ void UpdateComponentWidget<engine::StaticMeshComponent>(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);
}
}

Expand Down
5 changes: 3 additions & 2 deletions Engine/Source/Runtime/ECWorld/StaticMeshComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -362,7 +362,8 @@ void StaticMeshComponent::BuildProgressiveMeshData()

void StaticMeshComponent::UpdateProgressiveMeshData()
{
uint32_t lodVertexCount = static_cast<uint32_t>(m_progressiveMeshLODPercent * m_totalVertexCount);
assert(m_progressiveMeshReductionPercent >= 0.0f && m_progressiveMeshReductionPercent <= 1.0f);
uint32_t lodVertexCount = static_cast<uint32_t>(m_progressiveMeshReductionPercent * m_totalVertexCount);
if (lodVertexCount == m_currentVertexCount)
{
return;
Expand Down
6 changes: 3 additions & 3 deletions Engine/Source/Runtime/ECWorld/StaticMeshComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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<uint32_t> m_permutation;
std::vector<uint32_t> m_map;
#endif
Expand Down

0 comments on commit 564fe32

Please sign in to comment.