Commit 0300d533 authored by Maire Nicolas's avatar Maire Nicolas

Cleanup dans clippingShader.cpp.

parent 31366e50
...@@ -179,9 +179,11 @@ void ClippingShader::setClipPlaneParamsAll(unsigned int id, Geom::Vec3f normal, ...@@ -179,9 +179,11 @@ void ClippingShader::setClipPlaneParamsAll(unsigned int id, Geom::Vec3f normal,
Geom::Vec3f normalNormalized = normal; Geom::Vec3f normalNormalized = normal;
normalNormalized.normalize(); normalNormalized.normalize();
if ((normalNormalized != m_clipPlanes[planeIndex].normal) // Check if it is worth updating values !
|| (origin != m_clipPlanes[planeIndex].origin)) if ((normalNormalized == m_clipPlanes[planeIndex].normal)
{ && (origin == m_clipPlanes[planeIndex].origin))
return;
// Copy the given clipping plane parameters // Copy the given clipping plane parameters
m_clipPlanes[planeIndex].normal = normalNormalized; m_clipPlanes[planeIndex].normal = normalNormalized;
m_clipPlanes[planeIndex].origin = origin; m_clipPlanes[planeIndex].origin = origin;
...@@ -191,7 +193,6 @@ void ClippingShader::setClipPlaneParamsAll(unsigned int id, Geom::Vec3f normal, ...@@ -191,7 +193,6 @@ void ClippingShader::setClipPlaneParamsAll(unsigned int id, Geom::Vec3f normal,
// Send again the whole planes equations array to shader // Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform(); sendClipPlanesEquationsUniform();
}
} }
void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f normal) void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f normal)
...@@ -209,8 +210,10 @@ void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f norma ...@@ -209,8 +210,10 @@ void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f norma
Geom::Vec3f normalNormalized = normal; Geom::Vec3f normalNormalized = normal;
normalNormalized.normalize(); normalNormalized.normalize();
if (normalNormalized != m_clipPlanes[planeIndex].normal) // Check if it is worth updating values !
{ if (normalNormalized == m_clipPlanes[planeIndex].normal)
return;
// Copy the given clipping plane parameter // Copy the given clipping plane parameter
m_clipPlanes[planeIndex].normal = normalNormalized; m_clipPlanes[planeIndex].normal = normalNormalized;
...@@ -219,7 +222,6 @@ void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f norma ...@@ -219,7 +222,6 @@ void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f norma
// Send again the whole planes equations array to shader // Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform(); sendClipPlanesEquationsUniform();
}
} }
void ClippingShader::setClipPlaneParamsOrigin(unsigned int id, Geom::Vec3f origin) void ClippingShader::setClipPlaneParamsOrigin(unsigned int id, Geom::Vec3f origin)
...@@ -233,8 +235,10 @@ void ClippingShader::setClipPlaneParamsOrigin(unsigned int id, Geom::Vec3f origi ...@@ -233,8 +235,10 @@ void ClippingShader::setClipPlaneParamsOrigin(unsigned int id, Geom::Vec3f origi
// Get the corresponding plane index // Get the corresponding plane index
int planeIndex = m_clipPlanesIds[id].index; int planeIndex = m_clipPlanesIds[id].index;
if (origin != m_clipPlanes[planeIndex].origin) // Check if it is worth updating values !
{ if (origin == m_clipPlanes[planeIndex].origin)
return;
// Copy the given clipping plane parameter // Copy the given clipping plane parameter
m_clipPlanes[planeIndex].origin = origin; m_clipPlanes[planeIndex].origin = origin;
...@@ -243,7 +247,6 @@ void ClippingShader::setClipPlaneParamsOrigin(unsigned int id, Geom::Vec3f origi ...@@ -243,7 +247,6 @@ void ClippingShader::setClipPlaneParamsOrigin(unsigned int id, Geom::Vec3f origi
// Send again the whole planes equations array to shader // Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform(); sendClipPlanesEquationsUniform();
}
} }
Geom::Vec3f ClippingShader::getClipPlaneParamsNormal(unsigned int id) Geom::Vec3f ClippingShader::getClipPlaneParamsNormal(unsigned int id)
...@@ -434,9 +437,11 @@ void ClippingShader::setClipSphereParamsAll(unsigned int id, Geom::Vec3f center, ...@@ -434,9 +437,11 @@ void ClippingShader::setClipSphereParamsAll(unsigned int id, Geom::Vec3f center,
// Get the corresponding sphere index // Get the corresponding sphere index
int sphereIndex = m_clipSpheresIds[id].index; int sphereIndex = m_clipSpheresIds[id].index;
if ((center != m_clipSpheres[sphereIndex].center) // Check if it is worth updating values !
|| (radius != m_clipSpheres[sphereIndex].radius)) if ((center == m_clipSpheres[sphereIndex].center)
{ && (radius == m_clipSpheres[sphereIndex].radius))
return;
// Copy the given clipping sphere parameters // Copy the given clipping sphere parameters
m_clipSpheres[sphereIndex].center = center; m_clipSpheres[sphereIndex].center = center;
m_clipSpheres[sphereIndex].radius = radius; m_clipSpheres[sphereIndex].radius = radius;
...@@ -446,7 +451,6 @@ void ClippingShader::setClipSphereParamsAll(unsigned int id, Geom::Vec3f center, ...@@ -446,7 +451,6 @@ void ClippingShader::setClipSphereParamsAll(unsigned int id, Geom::Vec3f center,
// Send again the whole spheres centers and radiuses array to shader // Send again the whole spheres centers and radiuses array to shader
sendClipSpheresCentersAndRadiusesUniform(); sendClipSpheresCentersAndRadiusesUniform();
}
} }
void ClippingShader::setClipSphereParamsCenter(unsigned int id, Geom::Vec3f center) void ClippingShader::setClipSphereParamsCenter(unsigned int id, Geom::Vec3f center)
...@@ -460,8 +464,10 @@ void ClippingShader::setClipSphereParamsCenter(unsigned int id, Geom::Vec3f cent ...@@ -460,8 +464,10 @@ void ClippingShader::setClipSphereParamsCenter(unsigned int id, Geom::Vec3f cent
// Get the corresponding sphere index // Get the corresponding sphere index
int sphereIndex = m_clipSpheresIds[id].index; int sphereIndex = m_clipSpheresIds[id].index;
if (center != m_clipSpheres[sphereIndex].center) // Check if it is worth updating values !
{ if (center == m_clipSpheres[sphereIndex].center)
return;
// Copy the given clipping sphere parameter // Copy the given clipping sphere parameter
m_clipSpheres[sphereIndex].center = center; m_clipSpheres[sphereIndex].center = center;
...@@ -470,7 +476,6 @@ void ClippingShader::setClipSphereParamsCenter(unsigned int id, Geom::Vec3f cent ...@@ -470,7 +476,6 @@ void ClippingShader::setClipSphereParamsCenter(unsigned int id, Geom::Vec3f cent
// Send again the whole spheres centers and radiuses array to shader // Send again the whole spheres centers and radiuses array to shader
sendClipSpheresCentersAndRadiusesUniform(); sendClipSpheresCentersAndRadiusesUniform();
}
} }
void ClippingShader::setClipSphereParamsRadius(unsigned int id, float radius) void ClippingShader::setClipSphereParamsRadius(unsigned int id, float radius)
...@@ -484,8 +489,10 @@ void ClippingShader::setClipSphereParamsRadius(unsigned int id, float radius) ...@@ -484,8 +489,10 @@ void ClippingShader::setClipSphereParamsRadius(unsigned int id, float radius)
// Get the corresponding sphere index // Get the corresponding sphere index
int sphereIndex = m_clipSpheresIds[id].index; int sphereIndex = m_clipSpheresIds[id].index;
if (radius != m_clipSpheres[sphereIndex].radius) // Check if it is worth updating values !
{ if (radius == m_clipSpheres[sphereIndex].radius)
return;
// Copy the given clipping sphere parameter // Copy the given clipping sphere parameter
m_clipSpheres[sphereIndex].radius = radius; m_clipSpheres[sphereIndex].radius = radius;
...@@ -494,7 +501,6 @@ void ClippingShader::setClipSphereParamsRadius(unsigned int id, float radius) ...@@ -494,7 +501,6 @@ void ClippingShader::setClipSphereParamsRadius(unsigned int id, float radius)
// Send again the whole spheres centers and radiuses array to shader // Send again the whole spheres centers and radiuses array to shader
sendClipSpheresCentersAndRadiusesUniform(); sendClipSpheresCentersAndRadiusesUniform();
}
} }
Geom::Vec3f ClippingShader::getClipSphereParamsCenter(unsigned int id) Geom::Vec3f ClippingShader::getClipSphereParamsCenter(unsigned int id)
...@@ -810,14 +816,15 @@ bool ClippingShader::insertClippingCode() ...@@ -810,14 +816,15 @@ bool ClippingShader::insertClippingCode()
void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor) void ClippingShader::setClipColorAttenuationFactor(float colorAttenuationFactor)
{ {
if (colorAttenuationFactor != m_clipColorAttenuationFactor) // Check if it is worth updating values !
{ if (colorAttenuationFactor == m_clipColorAttenuationFactor)
return;
// Copy the given value // Copy the given value
m_clipColorAttenuationFactor = colorAttenuationFactor; m_clipColorAttenuationFactor = colorAttenuationFactor;
// Send again the uniform to shader // Send again the uniform to shader
sendClipColorAttenuationFactorUniform(); sendClipColorAttenuationFactorUniform();
}
} }
float ClippingShader::getClipColorAttenuationFactor() float ClippingShader::getClipColorAttenuationFactor()
...@@ -827,8 +834,10 @@ float ClippingShader::getClipColorAttenuationFactor() ...@@ -827,8 +834,10 @@ float ClippingShader::getClipColorAttenuationFactor()
void ClippingShader::setClipColorAttenuationMode(colorAttenuationMode colAttMode) void ClippingShader::setClipColorAttenuationMode(colorAttenuationMode colAttMode)
{ {
if (colAttMode != m_colorAttenuationMode) // Check if it is worth updating values !
{ if (colAttMode == m_colorAttenuationMode)
return;
// Check if the clipping code has been inserted into shader // Check if the clipping code has been inserted into shader
if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipColorAttenuationMode")) if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipColorAttenuationMode"))
return; return;
...@@ -868,7 +877,6 @@ void ClippingShader::setClipColorAttenuationMode(colorAttenuationMode colAttMode ...@@ -868,7 +877,6 @@ void ClippingShader::setClipColorAttenuationMode(colorAttenuationMode colAttMode
// Recompile shaders (automatically calls updateClippingUniforms) // Recompile shaders (automatically calls updateClippingUniforms)
recompile(); recompile();
}
} }
ClippingShader::colorAttenuationMode ClippingShader::getClipColorAttenuationMode() ClippingShader::colorAttenuationMode ClippingShader::getClipColorAttenuationMode()
...@@ -878,8 +886,10 @@ ClippingShader::colorAttenuationMode ClippingShader::getClipColorAttenuationMode ...@@ -878,8 +886,10 @@ ClippingShader::colorAttenuationMode ClippingShader::getClipColorAttenuationMode
void ClippingShader::setClipMode(clippingMode clipMode) void ClippingShader::setClipMode(clippingMode clipMode)
{ {
if (clipMode != m_clipMode) // Check if it is worth updating values !
{ if (clipMode == m_clipMode)
return;
// Check if the clipping code has been inserted into shader // Check if the clipping code has been inserted into shader
if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipMode")) if (errorRaiseClippingCodeNotInserted(!m_hasClippingCodeBeenInserted, "ClippingShader::setClipMode"))
return; return;
...@@ -919,7 +929,6 @@ void ClippingShader::setClipMode(clippingMode clipMode) ...@@ -919,7 +929,6 @@ void ClippingShader::setClipMode(clippingMode clipMode)
// Recompile shaders (automatically calls updateClippingUniforms) // Recompile shaders (automatically calls updateClippingUniforms)
recompile(); recompile();
}
} }
ClippingShader::clippingMode ClippingShader::getClipMode() ClippingShader::clippingMode ClippingShader::getClipMode()
......
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