Skip to content

Commit

Permalink
[SofaSphFluid] Fix: internal draw method not restoring default parame…
Browse files Browse the repository at this point in the history
…ters (#4150)
  • Loading branch information
epernod authored Sep 12, 2023
1 parent e853098 commit c39aa2b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/SofaSphFluid/ParticleSink.inl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void ParticleSink<DataTypes>::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();

Expand Down Expand Up @@ -243,8 +243,6 @@ void ParticleSink<DataTypes>::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
Expand Down
2 changes: 2 additions & 0 deletions src/SofaSphFluid/ParticleSource.inl
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ void ParticleSource<DataTypes>::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;
Expand Down
3 changes: 1 addition & 2 deletions src/SofaSphFluid/ParticlesRepulsionForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void ParticlesRepulsionForceField<DataTypes>::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();
Expand Down Expand Up @@ -217,7 +217,6 @@ void ParticlesRepulsionForceField<DataTypes>::draw(const core::visual::VisualPar
}
}
vparams->drawTool()->drawLines(vertices,1,colorVector);
vparams->drawTool()->restoreLastState();
}

} // namespace forcefield
Expand Down
4 changes: 1 addition & 3 deletions src/SofaSphFluid/SPHFluidForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void SPHFluidForceField<DataTypes>::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();
Expand Down Expand Up @@ -552,8 +552,6 @@ void SPHFluidForceField<DataTypes>::draw(const core::visual::VisualParams* vpara
vparams->drawTool()->drawPoints(vertices,5,colorVector);
vertices.clear();
colorVector.clear();

vparams->drawTool()->restoreLastState();
}

} // namespace forcefield
Expand Down
1 change: 1 addition & 0 deletions src/SofaSphFluid/SPHFluidSurfaceMapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ void SPHFluidSurfaceMapping<In,Out>::draw(const core::visual::VisualParams* vpar
if (!grid)
return;

const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle();
grid->draw(vparams);

float scale = (float)d_mStep.getValue();
Expand Down

0 comments on commit c39aa2b

Please sign in to comment.