Skip to content

Commit

Permalink
- added parameter to make material invisible
Browse files Browse the repository at this point in the history
  • Loading branch information
janbender committed Aug 26, 2024
1 parent a5b1a30 commit 08f9fc8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions SPlisHSPlasH/Utilities/DebugTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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++)
Expand Down
5 changes: 5 additions & 0 deletions SPlisHSPlasH/Utilities/SceneParameterObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<unsigned int>("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.");
Expand Down
6 changes: 5 additions & 1 deletion SPlisHSPlasH/Utilities/SceneParameterObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ namespace Utilities
unsigned int colorMapType;
Real minVal;
Real maxVal;
bool visible;
unsigned int maxEmitterParticles;
bool emitterReuseParticles;
Vector3r emitterBoxMin;
Expand All @@ -280,6 +281,7 @@ namespace Utilities
id = "Fluid";
minVal = 0.0;
maxVal = 10.0;
visible = true;
colorField = "velocity";
colorMapType = 1;
maxEmitterParticles = 10000;
Expand All @@ -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_;
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Simulator/GUI/imgui/Simulator_GUI_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));

Expand Down
3 changes: 3 additions & 0 deletions Simulator/SimulatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace SPH
std::vector<int> m_colorMapType;
std::vector<Real> m_renderMaxValue;
std::vector<Real> m_renderMinValue;
std::vector<bool> m_visible;
float const* m_colorMapBuffer;
unsigned int m_colorMapLength;
BoundarySimulator *m_boundarySimulator;
Expand Down Expand Up @@ -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; }
Expand Down
5 changes: 3 additions & 2 deletions pySPlisHSPlasH/UtilitiesModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,16 @@ void UtilitiesModule(py::module m) {

py::class_<Utilities::MaterialParameterObject, GenParam::ParameterObject>(m_sub_sub, "MaterialData")
.def(py::init<>())
.def(py::init<std::string, std::string, unsigned int, Real, Real, unsigned int, bool, Vector3r, Vector3r>(),
"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<std::string, std::string, unsigned int, Real, Real, bool, unsigned int, bool, Vector3r, Vector3r>(),
"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)
.def_readwrite("colorField", &Utilities::MaterialParameterObject::colorField)
.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)
Expand Down

0 comments on commit 08f9fc8

Please sign in to comment.