Skip to content

Commit 08f9fc8

Browse files
committed
- added parameter to make material invisible
1 parent a5b1a30 commit 08f9fc8

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

SPlisHSPlasH/Utilities/DebugTools.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ DebugTools::DebugTools() :
1414
ParameterObject()
1515
{
1616
m_determineThreadIds = false;
17+
m_determineNumNeighbors = false;
18+
m_determineVelocityChanges = false;
1719

1820
Simulation* sim = Simulation::getCurrent();
1921
const unsigned int nModels = sim->numberOfFluidModels();
@@ -123,6 +125,7 @@ void SPH::DebugTools::determineThreadIds()
123125
void SPH::DebugTools::determineNumNeighbors()
124126
{
125127
Simulation* sim = Simulation::getCurrent();
128+
sim->performNeighborhoodSearch();
126129
const unsigned int nFluids = sim->numberOfFluidModels();
127130

128131
for (unsigned int fluidModelIndex = 0; fluidModelIndex < nFluids; fluidModelIndex++)

SPlisHSPlasH/Utilities/SceneParameterObjects.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ void AnimationFieldParameterObject::initParameters()
253253
int MaterialParameterObject::MATERIAL_ID = -1;
254254
int MaterialParameterObject::MATERIAL_MIN_VAL = -1;
255255
int MaterialParameterObject::MATERIAL_MAX_VAL = -1;
256+
int MaterialParameterObject::MATERIAL_VISIBLE = -1;
256257
int MaterialParameterObject::MATERIAL_COLOR_FIELD = -1;
257258
int MaterialParameterObject::MATERIAL_COLOR_MAP = -1;
258259
int MaterialParameterObject::MATERIAL_MAX_EMITTER_PARTICLES = -1;
@@ -282,6 +283,10 @@ void MaterialParameterObject::initParameters()
282283
setGroup(MATERIAL_COLOR_MAP, "Material");
283284
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");
284285

286+
MATERIAL_VISIBLE = createBoolParameter("visible", "Visible", &visible);
287+
setGroup(MATERIAL_VISIBLE, "Material");
288+
setDescription(MATERIAL_VISIBLE, "Defines if fluid phase is rendered.");
289+
285290
MATERIAL_MAX_EMITTER_PARTICLES = createNumericParameter<unsigned int>("maxEmitterParticles", "Max. emitter particles", &maxEmitterParticles);
286291
setGroup(MATERIAL_MAX_EMITTER_PARTICLES, "Material");
287292
setDescription(MATERIAL_MAX_EMITTER_PARTICLES, "Maximum number of particles the emitter generates. Note that reused particles are not counted here.");

SPlisHSPlasH/Utilities/SceneParameterObjects.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ namespace Utilities
269269
unsigned int colorMapType;
270270
Real minVal;
271271
Real maxVal;
272+
bool visible;
272273
unsigned int maxEmitterParticles;
273274
bool emitterReuseParticles;
274275
Vector3r emitterBoxMin;
@@ -280,6 +281,7 @@ namespace Utilities
280281
id = "Fluid";
281282
minVal = 0.0;
282283
maxVal = 10.0;
284+
visible = true;
283285
colorField = "velocity";
284286
colorMapType = 1;
285287
maxEmitterParticles = 10000;
@@ -288,12 +290,13 @@ namespace Utilities
288290
emitterBoxMax = Vector3r(1.0, 1.0, 1.0);
289291
}
290292

291-
MaterialParameterObject(std::string id_, std::string colorField_, unsigned int colorMapType_, Real minVal_, Real maxVal_,
293+
MaterialParameterObject(std::string id_, std::string colorField_, unsigned int colorMapType_, Real minVal_, Real maxVal_, bool visible_,
292294
unsigned int maxEmitterParticles_, bool emitterReuseParticles_, Vector3r emitterBoxMin_, Vector3r emitterBoxMax_)
293295
{
294296
id = id_;
295297
minVal = minVal_;
296298
maxVal = maxVal_;
299+
visible = visible_;
297300
colorField = colorField_;
298301
colorMapType = colorMapType_;
299302
maxEmitterParticles = maxEmitterParticles_;
@@ -305,6 +308,7 @@ namespace Utilities
305308
static int MATERIAL_ID;
306309
static int MATERIAL_MIN_VAL;
307310
static int MATERIAL_MAX_VAL;
311+
static int MATERIAL_VISIBLE;
308312
static int MATERIAL_COLOR_FIELD;
309313
static int MATERIAL_COLOR_MAP;
310314
static int MATERIAL_MAX_EMITTER_PARTICLES;

Simulator/GUI/imgui/Simulator_GUI_imgui.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,13 @@ void Simulator_GUI_imgui::initSimulationParameterGUI()
488488
param3->readOnly = false;
489489
param3->function = [this]() { getSimulatorBase()->determineMinMaxOfScalarField(); };
490490
imguiParameters::addParam("Fluid Model", model->getId(), param3);
491+
492+
imguiParameters::imguiBoolParameter* param4 = new imguiParameters::imguiBoolParameter();
493+
param4->description = "Define if fluid phase is rendered.";
494+
param4->label = "Visible";
495+
param4->getFct = [this]() -> bool { return getSimulatorBase()->getVisible(m_currentFluidModel); };
496+
param4->setFct = [this](bool v) { getSimulatorBase()->setVisible(m_currentFluidModel, v); };
497+
imguiParameters::addParam("Fluid Model", model->getId(), param4);
491498
}
492499

493500
imguiParameters::createParameterObjectGUI(model);
@@ -616,6 +623,9 @@ void Simulator_GUI_imgui::render()
616623
FluidModel *model = sim->getFluidModel(i);
617624
SimulatorBase *base = getSimulatorBase();
618625

626+
if (!base->getVisible(i))
627+
continue;
628+
619629
const FieldDescription* field = nullptr;
620630
field = &model->getField(base->getColorField(i));
621631

Simulator/SimulatorBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace SPH
7373
std::vector<int> m_colorMapType;
7474
std::vector<Real> m_renderMaxValue;
7575
std::vector<Real> m_renderMinValue;
76+
std::vector<bool> m_visible;
7677
float const* m_colorMapBuffer;
7778
unsigned int m_colorMapLength;
7879
BoundarySimulator *m_boundarySimulator;
@@ -209,6 +210,8 @@ namespace SPH
209210
void setRenderMaxValue(const unsigned int fluidModelIndex, Real val) { m_renderMaxValue[fluidModelIndex] = val; }
210211
Real getRenderMinValue(const unsigned int fluidModelIndex) const { return m_renderMinValue[fluidModelIndex]; }
211212
void setRenderMinValue(const unsigned int fluidModelIndex, Real val) { m_renderMinValue[fluidModelIndex] = val; }
213+
bool getFluidPhaseVisible(const unsigned int fluidModelIndex) const { return m_visible[fluidModelIndex]; }
214+
void setFluidPhaseVisible(const unsigned int fluidModelIndex, bool val) { m_visible[fluidModelIndex] = val; }
212215
std::string getOutputPath() const { return m_outputPath; }
213216

214217
unsigned int getLastObjectId() const { return m_currentObjectId; }

pySPlisHSPlasH/UtilitiesModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,16 @@ void UtilitiesModule(py::module m) {
373373

374374
py::class_<Utilities::MaterialParameterObject, GenParam::ParameterObject>(m_sub_sub, "MaterialData")
375375
.def(py::init<>())
376-
.def(py::init<std::string, std::string, unsigned int, Real, Real, unsigned int, bool, Vector3r, Vector3r>(),
377-
"id"_a, "colorField"_a="velocity", "colorMapType"_a=1, "minVal"_a=0.0, "maxVal"_a=10.0, //TODO: an id has to be provided
376+
.def(py::init<std::string, std::string, unsigned int, Real, Real, bool, unsigned int, bool, Vector3r, Vector3r>(),
377+
"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
378378
"maxEmitterParticles"_a=10000, "emitterReuseParticles"_a=false, "emitterBoxMin"_a=Vector3r(-1.0, -1.0, -1.0),
379379
"emitterBoxMax"_a=Vector3r(1.0, 1.0, 1.0))
380380
.def_readwrite("id", &Utilities::MaterialParameterObject::id)
381381
.def_readwrite("colorField", &Utilities::MaterialParameterObject::colorField)
382382
.def_readwrite("colorMapType", &Utilities::MaterialParameterObject::colorMapType)
383383
.def_readwrite("minVal", &Utilities::MaterialParameterObject::minVal)
384384
.def_readwrite("maxVal", &Utilities::MaterialParameterObject::maxVal)
385+
.def_readwrite("visible", &Utilities::MaterialParameterObject::visible)
385386
.def_readwrite("maxEmitterParticles", &Utilities::MaterialParameterObject::maxEmitterParticles)
386387
.def_readwrite("emitterReuseParticles", &Utilities::MaterialParameterObject::emitterReuseParticles)
387388
.def_readwrite("emitterBoxMin", &Utilities::MaterialParameterObject::emitterBoxMin)

0 commit comments

Comments
 (0)