Commit 9acc86b8 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri Committed by Sean McBride

Fix clear shader replacement issue

The replacement would never be erased because of a faulty if check.
Added test code to the relevant tests for regression testing in the
future.

(cherry picked from commit f4f12b96)
parent 1e45e062
......@@ -88,6 +88,18 @@ int TestUserShader(int argc, char *argv[])
" myNormalMCVSOutput = normalMC;\n", //but we add this
false // only do it once
);
mapper->AddShaderReplacement(
vtkShader::Vertex,
"//VTK::Color::Impl", // dummy replacement for testing clear method
true,
"VTK::Color::Impl\n",
false
);
mapper->ClearShaderReplacement(
vtkShader::Vertex, // clear our dummy replacement
"//VTK::Color::Impl",
true
);
// now modify the fragment shader
mapper->AddShaderReplacement(
......
......@@ -254,7 +254,7 @@ void vtkOpenGLPolyDataMapper::ClearShaderReplacement(
typedef std::map<const vtkShader::ReplacementSpec,
vtkShader::ReplacementValue>::iterator RIter;
RIter found = this->UserShaderReplacements.find(spec);
if (found == this->UserShaderReplacements.end())
if (found != this->UserShaderReplacements.end())
{
this->UserShaderReplacements.erase(found);
this->Modified();
......
......@@ -125,6 +125,16 @@ int TestGPURayCastUserShader(int argc, char* argv[])
"\n (gl_DepthRange.far + gl_DepthRange.near)), 1.0);"
"\n }",
false);
mapper->AddShaderReplacement(
vtkShader::Fragment, // dummy replacement to test clear method
"//VTK::ComputeGradient::Dec",
true,
"VTK::ComputeGradient::Dec",
false);
mapper->ClearShaderReplacement(
vtkShader::Fragment, // clear the dummy replacement
"//VTK::ComputeGradient::Dec",
true);
vtkNew<vtkVolume> volume;
volume->SetMapper(mapper.GetPointer());
......
......@@ -3042,7 +3042,7 @@ void vtkOpenGLGPUVolumeRayCastMapper::ClearShaderReplacement(
typedef std::map<const vtkShader::ReplacementSpec,
vtkShader::ReplacementValue>::iterator RIter;
RIter found = this->UserShaderReplacements.find(spec);
if (found == this->UserShaderReplacements.end())
if (found != this->UserShaderReplacements.end())
{
this->UserShaderReplacements.erase(found);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment