diff --git a/src/SofaSphFluid/ParticleSink.inl b/src/SofaSphFluid/ParticleSink.inl index 6aa27f8..c39ec6e 100644 --- a/src/SofaSphFluid/ParticleSink.inl +++ b/src/SofaSphFluid/ParticleSink.inl @@ -211,7 +211,7 @@ void ParticleSink::draw(const core::visual::VisualParams* vparams) if (!d_showPlane.getValue()) return; - vparams->drawTool()->saveLastState(); + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); type::Vec3d normal; normal = d_planeNormal.getValue(); @@ -243,8 +243,6 @@ void ParticleSink::draw(const core::visual::VisualParams* vparams) vertices.push_back(sofa::type::Vec3(corners[2])); vertices.push_back(sofa::type::Vec3(corners[3])); vparams->drawTool()->drawQuad(vertices[0],vertices[1],vertices[2],vertices[3], cross((vertices[1] - vertices[0]), (vertices[2] - vertices[0])), sofa::type::RGBAColor(0.0f, 0.5f, 0.2f, 1.0f)); - - vparams->drawTool()->restoreLastState(); } } // namespace misc diff --git a/src/SofaSphFluid/ParticleSource.inl b/src/SofaSphFluid/ParticleSource.inl index bbb93aa..651370b 100644 --- a/src/SofaSphFluid/ParticleSource.inl +++ b/src/SofaSphFluid/ParticleSource.inl @@ -333,6 +333,8 @@ void ParticleSource::draw(const core::visual::VisualParams* vparams) if (time < d_start.getValue() || time > d_stop.getValue()) return; + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + Deriv dpos = d_velocity.getValue()*(time - m_lastTime); std::vector< sofa::type::Vec3 > pointsInit; diff --git a/src/SofaSphFluid/ParticlesRepulsionForceField.inl b/src/SofaSphFluid/ParticlesRepulsionForceField.inl index 8f935e9..c1e90cd 100644 --- a/src/SofaSphFluid/ParticlesRepulsionForceField.inl +++ b/src/SofaSphFluid/ParticlesRepulsionForceField.inl @@ -187,7 +187,7 @@ void ParticlesRepulsionForceField::draw(const core::visual::VisualPar if (!vparams->displayFlags().getShowForceFields() && !vparams->displayFlags().getShowInteractionForceFields()) return; - vparams->drawTool()->saveLastState(); + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); vparams->drawTool()->disableLighting(); const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); @@ -217,7 +217,6 @@ void ParticlesRepulsionForceField::draw(const core::visual::VisualPar } } vparams->drawTool()->drawLines(vertices,1,colorVector); - vparams->drawTool()->restoreLastState(); } } // namespace forcefield diff --git a/src/SofaSphFluid/SPHFluidForceField.inl b/src/SofaSphFluid/SPHFluidForceField.inl index 7481cf4..cdc0f7b 100644 --- a/src/SofaSphFluid/SPHFluidForceField.inl +++ b/src/SofaSphFluid/SPHFluidForceField.inl @@ -451,7 +451,7 @@ void SPHFluidForceField::draw(const core::visual::VisualParams* vpara if (!vparams->displayFlags().getShowForceFields()) return; - vparams->drawTool()->saveLastState(); + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); vparams->drawTool()->disableLighting(); vparams->drawTool()->enableBlending(); vparams->drawTool()->disableDepthTest(); @@ -552,8 +552,6 @@ void SPHFluidForceField::draw(const core::visual::VisualParams* vpara vparams->drawTool()->drawPoints(vertices,5,colorVector); vertices.clear(); colorVector.clear(); - - vparams->drawTool()->restoreLastState(); } } // namespace forcefield diff --git a/src/SofaSphFluid/SPHFluidSurfaceMapping.inl b/src/SofaSphFluid/SPHFluidSurfaceMapping.inl index ba54e8b..a01c091 100644 --- a/src/SofaSphFluid/SPHFluidSurfaceMapping.inl +++ b/src/SofaSphFluid/SPHFluidSurfaceMapping.inl @@ -489,6 +489,7 @@ void SPHFluidSurfaceMapping::draw(const core::visual::VisualParams* vpar if (!grid) return; + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); grid->draw(vparams); float scale = (float)d_mStep.getValue();