From 08f9fc8fad5efb5e346b8b6be4bfaa42be3845a2 Mon Sep 17 00:00:00 2001 From: Jan Bender Date: Mon, 26 Aug 2024 10:15:33 +0200 Subject: [PATCH] - added parameter to make material invisible --- SPlisHSPlasH/Utilities/DebugTools.cpp | 3 +++ SPlisHSPlasH/Utilities/SceneParameterObjects.cpp | 5 +++++ SPlisHSPlasH/Utilities/SceneParameterObjects.h | 6 +++++- Simulator/GUI/imgui/Simulator_GUI_imgui.cpp | 10 ++++++++++ Simulator/SimulatorBase.h | 3 +++ pySPlisHSPlasH/UtilitiesModule.cpp | 5 +++-- 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/SPlisHSPlasH/Utilities/DebugTools.cpp b/SPlisHSPlasH/Utilities/DebugTools.cpp index 081f1d5f..128d5113 100644 --- a/SPlisHSPlasH/Utilities/DebugTools.cpp +++ b/SPlisHSPlasH/Utilities/DebugTools.cpp @@ -14,6 +14,8 @@ DebugTools::DebugTools() : ParameterObject() { m_determineThreadIds = false; + m_determineNumNeighbors = false; + m_determineVelocityChanges = false; Simulation* sim = Simulation::getCurrent(); const unsigned int nModels = sim->numberOfFluidModels(); @@ -123,6 +125,7 @@ void SPH::DebugTools::determineThreadIds() void SPH::DebugTools::determineNumNeighbors() { Simulation* sim = Simulation::getCurrent(); + sim->performNeighborhoodSearch(); const unsigned int nFluids = sim->numberOfFluidModels(); for (unsigned int fluidModelIndex = 0; fluidModelIndex < nFluids; fluidModelIndex++) diff --git a/SPlisHSPlasH/Utilities/SceneParameterObjects.cpp b/SPlisHSPlasH/Utilities/SceneParameterObjects.cpp index 87431e97..6be6bbc2 100644 --- a/SPlisHSPlasH/Utilities/SceneParameterObjects.cpp +++ b/SPlisHSPlasH/Utilities/SceneParameterObjects.cpp @@ -253,6 +253,7 @@ void AnimationFieldParameterObject::initParameters() int MaterialParameterObject::MATERIAL_ID = -1; int MaterialParameterObject::MATERIAL_MIN_VAL = -1; int MaterialParameterObject::MATERIAL_MAX_VAL = -1; +int MaterialParameterObject::MATERIAL_VISIBLE = -1; int MaterialParameterObject::MATERIAL_COLOR_FIELD = -1; int MaterialParameterObject::MATERIAL_COLOR_MAP = -1; int MaterialParameterObject::MATERIAL_MAX_EMITTER_PARTICLES = -1; @@ -282,6 +283,10 @@ void MaterialParameterObject::initParameters() setGroup(MATERIAL_COLOR_MAP, "Material"); setDescription(MATERIAL_COLOR_MAP, "Selection of a color map for coloring the scalar/vector field: 0: None, 1 : Jet, 2 : Plasma, 3 : CoolWarm, 4 : BlueWhiteRed, 5 : Seismic"); + MATERIAL_VISIBLE = createBoolParameter("visible", "Visible", &visible); + setGroup(MATERIAL_VISIBLE, "Material"); + setDescription(MATERIAL_VISIBLE, "Defines if fluid phase is rendered."); + MATERIAL_MAX_EMITTER_PARTICLES = createNumericParameter("maxEmitterParticles", "Max. emitter particles", &maxEmitterParticles); setGroup(MATERIAL_MAX_EMITTER_PARTICLES, "Material"); setDescription(MATERIAL_MAX_EMITTER_PARTICLES, "Maximum number of particles the emitter generates. Note that reused particles are not counted here."); diff --git a/SPlisHSPlasH/Utilities/SceneParameterObjects.h b/SPlisHSPlasH/Utilities/SceneParameterObjects.h index 30b0aa5a..1eea317a 100644 --- a/SPlisHSPlasH/Utilities/SceneParameterObjects.h +++ b/SPlisHSPlasH/Utilities/SceneParameterObjects.h @@ -269,6 +269,7 @@ namespace Utilities unsigned int colorMapType; Real minVal; Real maxVal; + bool visible; unsigned int maxEmitterParticles; bool emitterReuseParticles; Vector3r emitterBoxMin; @@ -280,6 +281,7 @@ namespace Utilities id = "Fluid"; minVal = 0.0; maxVal = 10.0; + visible = true; colorField = "velocity"; colorMapType = 1; maxEmitterParticles = 10000; @@ -288,12 +290,13 @@ namespace Utilities emitterBoxMax = Vector3r(1.0, 1.0, 1.0); } - MaterialParameterObject(std::string id_, std::string colorField_, unsigned int colorMapType_, Real minVal_, Real maxVal_, + MaterialParameterObject(std::string id_, std::string colorField_, unsigned int colorMapType_, Real minVal_, Real maxVal_, bool visible_, unsigned int maxEmitterParticles_, bool emitterReuseParticles_, Vector3r emitterBoxMin_, Vector3r emitterBoxMax_) { id = id_; minVal = minVal_; maxVal = maxVal_; + visible = visible_; colorField = colorField_; colorMapType = colorMapType_; maxEmitterParticles = maxEmitterParticles_; @@ -305,6 +308,7 @@ namespace Utilities static int MATERIAL_ID; static int MATERIAL_MIN_VAL; static int MATERIAL_MAX_VAL; + static int MATERIAL_VISIBLE; static int MATERIAL_COLOR_FIELD; static int MATERIAL_COLOR_MAP; static int MATERIAL_MAX_EMITTER_PARTICLES; diff --git a/Simulator/GUI/imgui/Simulator_GUI_imgui.cpp b/Simulator/GUI/imgui/Simulator_GUI_imgui.cpp index 8cb17911..1ee50093 100644 --- a/Simulator/GUI/imgui/Simulator_GUI_imgui.cpp +++ b/Simulator/GUI/imgui/Simulator_GUI_imgui.cpp @@ -488,6 +488,13 @@ void Simulator_GUI_imgui::initSimulationParameterGUI() param3->readOnly = false; param3->function = [this]() { getSimulatorBase()->determineMinMaxOfScalarField(); }; imguiParameters::addParam("Fluid Model", model->getId(), param3); + + imguiParameters::imguiBoolParameter* param4 = new imguiParameters::imguiBoolParameter(); + param4->description = "Define if fluid phase is rendered."; + param4->label = "Visible"; + param4->getFct = [this]() -> bool { return getSimulatorBase()->getVisible(m_currentFluidModel); }; + param4->setFct = [this](bool v) { getSimulatorBase()->setVisible(m_currentFluidModel, v); }; + imguiParameters::addParam("Fluid Model", model->getId(), param4); } imguiParameters::createParameterObjectGUI(model); @@ -616,6 +623,9 @@ void Simulator_GUI_imgui::render() FluidModel *model = sim->getFluidModel(i); SimulatorBase *base = getSimulatorBase(); + if (!base->getVisible(i)) + continue; + const FieldDescription* field = nullptr; field = &model->getField(base->getColorField(i)); diff --git a/Simulator/SimulatorBase.h b/Simulator/SimulatorBase.h index c5803f5b..49a6810e 100644 --- a/Simulator/SimulatorBase.h +++ b/Simulator/SimulatorBase.h @@ -73,6 +73,7 @@ namespace SPH std::vector m_colorMapType; std::vector m_renderMaxValue; std::vector m_renderMinValue; + std::vector m_visible; float const* m_colorMapBuffer; unsigned int m_colorMapLength; BoundarySimulator *m_boundarySimulator; @@ -209,6 +210,8 @@ namespace SPH void setRenderMaxValue(const unsigned int fluidModelIndex, Real val) { m_renderMaxValue[fluidModelIndex] = val; } Real getRenderMinValue(const unsigned int fluidModelIndex) const { return m_renderMinValue[fluidModelIndex]; } void setRenderMinValue(const unsigned int fluidModelIndex, Real val) { m_renderMinValue[fluidModelIndex] = val; } + bool getFluidPhaseVisible(const unsigned int fluidModelIndex) const { return m_visible[fluidModelIndex]; } + void setFluidPhaseVisible(const unsigned int fluidModelIndex, bool val) { m_visible[fluidModelIndex] = val; } std::string getOutputPath() const { return m_outputPath; } unsigned int getLastObjectId() const { return m_currentObjectId; } diff --git a/pySPlisHSPlasH/UtilitiesModule.cpp b/pySPlisHSPlasH/UtilitiesModule.cpp index 7584ed2a..7bdeec52 100644 --- a/pySPlisHSPlasH/UtilitiesModule.cpp +++ b/pySPlisHSPlasH/UtilitiesModule.cpp @@ -373,8 +373,8 @@ void UtilitiesModule(py::module m) { py::class_(m_sub_sub, "MaterialData") .def(py::init<>()) - .def(py::init(), - "id"_a, "colorField"_a="velocity", "colorMapType"_a=1, "minVal"_a=0.0, "maxVal"_a=10.0, //TODO: an id has to be provided + .def(py::init(), + "id"_a, "colorField"_a="velocity", "colorMapType"_a=1, "minVal"_a=0.0, "maxVal"_a=10.0, "visible"_a=true, //TODO: an id has to be provided "maxEmitterParticles"_a=10000, "emitterReuseParticles"_a=false, "emitterBoxMin"_a=Vector3r(-1.0, -1.0, -1.0), "emitterBoxMax"_a=Vector3r(1.0, 1.0, 1.0)) .def_readwrite("id", &Utilities::MaterialParameterObject::id) @@ -382,6 +382,7 @@ void UtilitiesModule(py::module m) { .def_readwrite("colorMapType", &Utilities::MaterialParameterObject::colorMapType) .def_readwrite("minVal", &Utilities::MaterialParameterObject::minVal) .def_readwrite("maxVal", &Utilities::MaterialParameterObject::maxVal) + .def_readwrite("visible", &Utilities::MaterialParameterObject::visible) .def_readwrite("maxEmitterParticles", &Utilities::MaterialParameterObject::maxEmitterParticles) .def_readwrite("emitterReuseParticles", &Utilities::MaterialParameterObject::emitterReuseParticles) .def_readwrite("emitterBoxMin", &Utilities::MaterialParameterObject::emitterBoxMin)