void MeshDecimationApp::guiVertexCountSlider() { if (m_curLoadingMeshIdx == 0) return; ImGui::Text("- Vertex Count -"); auto& collapsedEdges = m_curMesh->collapsedEdges; int maxVertexCount = int(m_curMesh->originalEdgeMesh->getVertices().size()); int minVertexCount = int(maxVertexCount - m_curMesh->collapsedEdges.size()); ImGui::SliderInt("", &m_curVertexCount, minVertexCount, maxVertexCount); ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value."); m_curVertexCount = math::clamp(m_curVertexCount, minVertexCount, maxVertexCount); static int lastVertexCount = -1; int reductionCount = maxVertexCount - m_curVertexCount; // To allow interactive speeds collapse candidates are cached for each mesh during program startup. // Upon slider interaction the original mesh is restored and reduced to the desired vertex count. // This is still an expensive process and won't work interactively for meshes with millions of vertices. if (lastVertexCount != m_curVertexCount) { m_reducibleMesh = *m_curMesh->originalEdgeMesh; for (int i = 0; i < reductionCount; ++i) m_reducibleMesh.collapse(collapsedEdges[i]); m_phongShadedMesh.setSubMesh(m_reducibleMesh.getReducedSubMesh(), 0); m_phongShadedMesh.finalize(); createFlatShadedMesh(); lastVertexCount = m_curVertexCount; } }
void FaceDetectorModule::DrawGUI(){ if(showGUI){ ui::Begin("Face Detector", &showGUI, ImGuiWindowFlags_AlwaysAutoResize); ui::Checkbox("Enabled", &enabled); ui::Separator(); if(!enabled) ui::PushStyleVar(ImGuiStyleVar_Alpha, 0.2); //Push disabled style ui::SliderFloat("Scale", &imageScale, 0.01, 1.00); ShowHelpMarker("Higher values give more accurate results, but run much slower."); if(!enabled) ui::PopStyleVar(); //Pop disabled style ui::End(); } }