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