Commit cb3bcd83 authored by Maire Nicolas's avatar Maire Nicolas

Essai de rajout de clipping avec des sections de plans. Quelques bugs à régler...

Essai de rajout de clipping avec des sections de plans. Quelques bugs à régler encore, voir tout refaire à part des plans traditionels.
Un peu de cleanup dans clippingShader.
Cleanup complet dans shaderMutator.
parent 163a2e9e
...@@ -40,14 +40,12 @@ void StageShader::slot_drawVertices(bool b) ...@@ -40,14 +40,12 @@ void StageShader::slot_drawVertices(bool b)
updateGL(); updateGL();
} }
void StageShader::slot_drawLines(bool b) void StageShader::slot_drawLines(bool b)
{ {
m_drawLines = b; m_drawLines = b;
updateGL(); updateGL();
} }
void StageShader::slot_drawFaces(bool b) void StageShader::slot_drawFaces(bool b)
{ {
m_drawFaces = b; m_drawFaces = b;
...@@ -77,9 +75,9 @@ void StageShader::slot_explodTopoPhi3(double c) ...@@ -77,9 +75,9 @@ void StageShader::slot_explodTopoPhi3(double c)
void StageShader::slot_pushButton_addPlane() void StageShader::slot_pushButton_addPlane()
{ {
m_shader->setClippingPlanesCount(dock.comboBox_PlaneIndex->count() + 1); m_shader->setClipPlanesCount(dock.comboBox_PlaneIndex->count() + 1);
m_shader->setClippingPlaneOrigin(m_bb.center(), dock.comboBox_PlaneIndex->count() + 1 - 1); m_shader->setClipPlaneOrigin(m_bb.center(), dock.comboBox_PlaneIndex->count() + 1 - 1);
std::string indexStr; std::string indexStr;
std::stringstream ss; std::stringstream ss;
...@@ -98,7 +96,7 @@ void StageShader::slot_pushButton_addPlane() ...@@ -98,7 +96,7 @@ void StageShader::slot_pushButton_addPlane()
void StageShader::slot_pushButton_deletePlane() void StageShader::slot_pushButton_deletePlane()
{ {
m_shader->setClippingPlanesCount(dock.comboBox_PlaneIndex->count() - 1); m_shader->setClipPlanesCount(dock.comboBox_PlaneIndex->count() - 1);
dock.comboBox_PlaneIndex->removeItem(dock.comboBox_PlaneIndex->count() - 1); dock.comboBox_PlaneIndex->removeItem(dock.comboBox_PlaneIndex->count() - 1);
...@@ -112,17 +110,17 @@ void StageShader::slot_comboBox_PlaneIndexChanged(int newIndex) ...@@ -112,17 +110,17 @@ void StageShader::slot_comboBox_PlaneIndexChanged(int newIndex)
{ {
if (newIndex >= 0) if (newIndex >= 0)
{ {
Geom::Vec3f currPlaneVec1 = m_shader->getClippingPlaneFirstVec(newIndex); Geom::Vec3f currPlaneVec1 = m_shader->getClipPlaneFirstVec(newIndex);
dock.doubleSpinBox_PlaneVec1x->setValue(currPlaneVec1[0]); dock.doubleSpinBox_PlaneVec1x->setValue(currPlaneVec1[0]);
dock.doubleSpinBox_PlaneVec1y->setValue(currPlaneVec1[1]); dock.doubleSpinBox_PlaneVec1y->setValue(currPlaneVec1[1]);
dock.doubleSpinBox_PlaneVec1z->setValue(currPlaneVec1[2]); dock.doubleSpinBox_PlaneVec1z->setValue(currPlaneVec1[2]);
Geom::Vec3f currPlaneVec2 = m_shader->getClippingPlaneSecondVec(newIndex); Geom::Vec3f currPlaneVec2 = m_shader->getClipPlaneSecondVec(newIndex);
dock.doubleSpinBox_PlaneVec2x->setValue(currPlaneVec2[0]); dock.doubleSpinBox_PlaneVec2x->setValue(currPlaneVec2[0]);
dock.doubleSpinBox_PlaneVec2y->setValue(currPlaneVec2[1]); dock.doubleSpinBox_PlaneVec2y->setValue(currPlaneVec2[1]);
dock.doubleSpinBox_PlaneVec2z->setValue(currPlaneVec2[2]); dock.doubleSpinBox_PlaneVec2z->setValue(currPlaneVec2[2]);
Geom::Vec3f currPlaneOrigin = m_shader->getClippingPlaneOrigin(newIndex); Geom::Vec3f currPlaneOrigin = m_shader->getClipPlaneOrigin(newIndex);
dock.doubleSpinBox_PlaneOriginx->setValue(currPlaneOrigin[0]); dock.doubleSpinBox_PlaneOriginx->setValue(currPlaneOrigin[0]);
dock.doubleSpinBox_PlaneOriginy->setValue(currPlaneOrigin[1]); dock.doubleSpinBox_PlaneOriginy->setValue(currPlaneOrigin[1]);
dock.doubleSpinBox_PlaneOriginz->setValue(currPlaneOrigin[2]); dock.doubleSpinBox_PlaneOriginz->setValue(currPlaneOrigin[2]);
...@@ -136,7 +134,7 @@ void StageShader::slot_doubleSpinBox_PlaneVec1(double c) ...@@ -136,7 +134,7 @@ void StageShader::slot_doubleSpinBox_PlaneVec1(double c)
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1x->value(); float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1x->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1y->value(); float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1y->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1z->value(); float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1z->value();
m_shader->setClippingPlaneFirstVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex()); m_shader->setClipPlaneFirstVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
updateGL(); updateGL();
} }
} }
...@@ -148,7 +146,7 @@ void StageShader::slot_doubleSpinBox_PlaneVec2(double c) ...@@ -148,7 +146,7 @@ void StageShader::slot_doubleSpinBox_PlaneVec2(double c)
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2x->value(); float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2x->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2y->value(); float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2y->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2z->value(); float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2z->value();
m_shader->setClippingPlaneSecondVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex()); m_shader->setClipPlaneSecondVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
updateGL(); updateGL();
} }
} }
...@@ -160,14 +158,14 @@ void StageShader::slot_doubleSpinBox_PlaneOrigin(double c) ...@@ -160,14 +158,14 @@ void StageShader::slot_doubleSpinBox_PlaneOrigin(double c)
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginx->value(); float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginx->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginy->value(); float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginy->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginz->value(); float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginz->value();
m_shader->setClippingPlaneOrigin(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex()); m_shader->setClipPlaneOrigin(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
updateGL(); updateGL();
} }
} }
void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c) void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{ {
m_shader->setClippingColorAttenuationFactor((float)c); m_shader->setClipColorAttenuationFactor((float)c);
updateGL(); updateGL();
} }
...@@ -287,7 +285,7 @@ void StageShader::initGUI() ...@@ -287,7 +285,7 @@ void StageShader::initGUI()
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc())); dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc())); dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClippingColorAttenuationFactor()); dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClipColorAttenuationFactor());
dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getPlaneDisplaySize()); dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getPlaneDisplaySize());
dock.spinBox_GridResolutionX->setValue(m_shader->getPlaneDisplayXRes()); dock.spinBox_GridResolutionX->setValue(m_shader->getPlaneDisplayXRes());
dock.spinBox_GridResolutionY->setValue(m_shader->getPlaneDisplayYRes()); dock.spinBox_GridResolutionY->setValue(m_shader->getPlaneDisplayYRes());
...@@ -436,7 +434,7 @@ void StageShader::cb_redraw() ...@@ -436,7 +434,7 @@ void StageShader::cb_redraw()
if (m_drawTopo) if (m_drawTopo)
m_render_topo->drawTopo(); m_render_topo->drawTopo();
m_shader->displayClippingPlanes(); m_shader->displayClipPlanes();
} }
......
...@@ -268,7 +268,11 @@ ...@@ -268,7 +268,11 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_GridDisplaySize"/> <widget class="QDoubleSpinBox" name="doubleSpinBox_GridDisplaySize">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_GridSize"> <widget class="QLabel" name="label_GridSize">
......
...@@ -61,84 +61,84 @@ public: ...@@ -61,84 +61,84 @@ public:
~ClippingShader(); ~ClippingShader();
/** /**
* set all parameters for one clipping plane * set all parameters for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param vec1 first basis vector * @param vec1 first basis vector
* @param vec2 second basis vector * @param vec2 second basis vector
* @param origin point of the plane that will be used as origin to display it * @param origin point of the plane that will be used as origin to display it
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
void setClippingPlane(Geom::Vec3f vec1, Geom::Vec3f vec2, Geom::Vec3f origin, int planeIndex = 0); void setClipPlane(Geom::Vec3f vec1, Geom::Vec3f vec2, Geom::Vec3f origin, int planeIndex = 0);
/** /**
* set first vector parameter for one clipping plane * set first vector for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param vec1 first basis vector * @param vec1 first basis vector
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
void setClippingPlaneFirstVec(Geom::Vec3f vec1, int planeIndex = 0); void setClipPlaneFirstVec(Geom::Vec3f vec1, int planeIndex = 0);
/** /**
* set second vector parameter for one clipping plane * set second vector for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param vec2 second basis vector * @param vec2 second basis vector
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
void setClippingPlaneSecondVec(Geom::Vec3f vec2, int planeIndex = 0); void setClipPlaneSecondVec(Geom::Vec3f vec2, int planeIndex = 0);
/** /**
* set origin parameter for one clipping plane * set origin for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param origin point of the plane that will be used as origin to display it * @param origin point of the plane that will be used as origin to display it
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
void setClippingPlaneOrigin(Geom::Vec3f origin, int planeIndex = 0); void setClipPlaneOrigin(Geom::Vec3f origin, int planeIndex = 0);
/** /**
* get first parameter for one clipping plane * get first vector for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
Geom::Vec3f getClippingPlaneFirstVec(int planeIndex = 0); Geom::Vec3f getClipPlaneFirstVec(int planeIndex = 0);
/** /**
* get second vector parameter for one clipping plane * get second vector for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
Geom::Vec3f getClippingPlaneSecondVec(int planeIndex = 0); Geom::Vec3f getClipPlaneSecondVec(int planeIndex = 0);
/** /**
* get origin parameter for one clipping plane * get origin for one clip plane
* @warning planeIndex starts at 0 * @warning planeIndex starts at 0
* @param planeIndex index of the plane to modify * @param planeIndex index of the plane to modify
*/ */
Geom::Vec3f getClippingPlaneOrigin(int planeIndex = 0); Geom::Vec3f getClipPlaneOrigin(int planeIndex = 0);
/** /**
* set the color attenuation factor for clipping * set the color attenuation factor for clipping
* @param colorAttenuationFactor color attenuation factor * @param colorAttenuationFactor color attenuation factor
*/ */
void setClippingColorAttenuationFactor(float colorAttenuationFactor); void setClipColorAttenuationFactor(float colorAttenuationFactor);
/** /**
* get the color attenuation factor for clipping * get the color attenuation factor for clipping
*/ */
float getClippingColorAttenuationFactor() { return m_colorAttenuationFactor; } float getClipColorAttenuationFactor() { return m_colorAttenuationFactor; }
/** /**
* set the clipping planes count used for plane clipping * set the clip planes count
* - insert plane clipping instructions into vertex and fragment shader source code * - inserts plane clipping instructions into vertex and fragment shader source code
* but does not modify the geometry shader source code * but does not modify the geometry shader source code
* @param planesCount the clipping planes count to use * @param planesCount the clip planes count to use
* @warning this function is designed for shaders which *do not* use a geometry shader * @warning this function is designed for shaders which *do not* use a geometry shader
*/ */
void setClippingPlanesCount(int planesCount); void setClipPlanesCount(int planesCount);
/** /**
* get the clipping planes count used for plane clipping * get the clip planes count
*/ */
int getClippingPlanesCount() { return (int)m_clipPlanes.size(); } int getClipPlanesCount() { return (int)m_clipPlanes.size(); }
/** /**
* update uniforms (get their locations and send their values again) for clipping * update uniforms (get their locations and send their values again) for clipping
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
/** /**
* display all clipping planes * display all clipping planes
*/ */
void displayClippingPlanes(); void displayClipPlanes();
/** /**
* set the planes display color * set the planes display color
...@@ -198,7 +198,7 @@ public: ...@@ -198,7 +198,7 @@ public:
* set the planes display size * set the planes display size
* @param size the new size * @param size the new size
*/ */
void setPlaneDisplaySize(float size) { m_clipPlanesDisplaySize = size; updateAllClippingPlanesVBOs(); } void setPlaneDisplaySize(float size) { m_clipPlanesDisplaySize = size;sendClippingPlanesUniform();updateAllClippingPlanesVBOs(); }
/** /**
* get the planes display size * get the planes display size
...@@ -209,7 +209,7 @@ public: ...@@ -209,7 +209,7 @@ public:
private: private:
/** /**
* clipping planes structure * clip planes structure
*/ */
struct clipPlane struct clipPlane
{ {
...@@ -217,15 +217,21 @@ private: ...@@ -217,15 +217,21 @@ private:
}; };
/** /**
* sends the clipping planes uniform to shader * sends the clip planes arrays to shader
*/ */
void sendClippingPlanesUniform(); void sendClippingPlanesUniform();
/** /**
* sends the color attenuation factor uniform to shader * sends the color attenuation factor to shader
*/ */
void sendColorAttenuationFactorUniform(); void sendColorAttenuationFactorUniform();
/**
* update clip planes parameters arrays
* @param planeIndex index of the plane
*/
void updateClippingPlanesArrays(int planeIndex);
/** /**
* update VBO for one plane * update VBO for one plane
* @param planeIndex index of the plane * @param planeIndex index of the plane
...@@ -281,6 +287,26 @@ private: ...@@ -281,6 +287,26 @@ private:
*/ */
GLint m_unif_clipPlanesEquations; GLint m_unif_clipPlanesEquations;
/**
* clip planes first vectors uniform id
*/
GLint m_unif_clipPlanesFirstVectors;
/**
* clip planes second vectors uniform id
*/
GLint m_unif_clipPlanesSecondVectors;
/**
* clip planes origins uniform id
*/
GLint m_unif_clipPlanesOrigins;
/**
* clip planes size uniform id
*/
GLint m_unif_clipPlanesDisplaySize;
/** /**
* color attenuation factor * color attenuation factor
*/ */
...@@ -321,6 +347,11 @@ private: ...@@ -321,6 +347,11 @@ private:
*/ */
float m_clipPlanesDisplaySize; float m_clipPlanesDisplaySize;
/**
* use advanced plane clipping ?
*/
bool m_useAdvancedPlaneClipping;
}; };
......
...@@ -48,52 +48,52 @@ public: ...@@ -48,52 +48,52 @@ public:
/** /**
* constructor * constructor
* @param vertShaderSrc the vertex shader source to store * @param vertShaderSrc vertex shader source to store
* @param fragShaderSrc the fragment shader source to store * @param fragShaderSrc fragment shader source to store
* @param geomShaderSrc the geometry shader source to store * @param geomShaderSrc geometry shader source to store (optional)
*/ */
ShaderMutator(const std::string& shaderName, const std::string& vertShaderSrc, const std::string& fragShaderSrc, const std::string& geomShaderSrc = ""); ShaderMutator(const std::string& shaderName, const std::string& vertShaderSrc, const std::string& fragShaderSrc, const std::string& geomShaderSrc = "");
/** /**
* check if a variable is declared in the shader source * checks if a variable is declared in the shader source
* @param srcType the shader source to use (vertex, fragment or geometry) * @param srcType shader source to use
* @param variableName the variable to search for * @param variableName variable to search for
*/ */
bool containsVariableDeclaration(shaderSrcType srcType, const std::string& variableName); bool containsVariableDeclaration(shaderSrcType srcType, const std::string& variableName);
/** /**
* set or change shading language version in the shader source * sets or changes shading language version in the shader source
* - only if the current version is lower * - only if the current version is lower
* @param srcType the shader source to use (vertex, fragment or geometry) * @param srcType shader source to use
* @param version the version to set (110, 120, 150...) * @param version version to set (110, 120, 150...)
*/ */
void setMinShadingLanguageVersion(shaderSrcType srcType, int version); void setMinShadingLanguageVersion(shaderSrcType srcType, int version);
/** /**
* change int constant value in the shader source * changes int constant value in the shader source
* @param srcType the shader source to use (vertex, fragment or geometry) * @param srcType shader source to use
* @param newVal the new value * @param newVal new constant value
*/ */
void changeIntConstantValue(shaderSrcType srcType, const std::string& constantName, int newVal); void changeIntConstantValue(shaderSrcType srcType, const std::string& constantName, int newVal);
/** /**
* insert code before main function into shader source * inserts code before main function in the shader source
* @param srcType the shader source to use (vertex, fragment or geometry) * @param srcType shader source to use
* @param insertedCode source code to insert into shader * @param insertedCode source code to insert into shader
*/ */
void insertCodeBeforeMainFunction(shaderSrcType srcType, const std::string& insertedCode); void insertCodeBeforeMainFunction(shaderSrcType srcType, const std::string& insertedCode);
/** /**
* insert code at the beginning of main function into shader source * inserts code at the beginning of main function in the shader source
* @param srcType the shader source to use (vertex, fragment or geometry) * @param srcType shader source to use
* @param insertedCode source code to insert into shader * @param insertedCode source code to insert into shader
*/ */
void insertCodeAtMainFunctionBeginning(shaderSrcType srcType, const std::string& insertedCode); void insertCodeAtMainFunctionBeginning(shaderSrcType srcType, const std::string& insertedCode);
/** /**
* insert code at the end of main function into shader source * inserts code at the end of main function in the shader source
* @warning takes the number of opening and closing braces of main function into account * @warning takes the number of opening and closing braces of main function into account
* @param srcType the shader source to use (vertex, fragment or geometry) * @param srcType shader source to use
* @param insertedCode source code to insert into shader * @param insertedCode source code to insert into shader
*/ */
void insertCodeAtMainFunctionEnd(shaderSrcType srcType, const std::string& insertedCode); void insertCodeAtMainFunctionEnd(shaderSrcType srcType, const std::string& insertedCode);
...@@ -136,56 +136,58 @@ private: ...@@ -136,56 +136,58 @@ private:
std::string m_gShaderMutation; std::string m_gShaderMutation;
/** /**
* check if the given position in the source is commented * checks if the given position is commented
* @param pos the position * @param pos position in the source (like in a string)
* @param src the source to analyze * @param src source to analyze
*/ */
bool srcIsCommented(size_t pos, const std::string& src); bool srcIsCommented(size_t pos, const std::string& src);
/** /**
* check if the given position in the source is commented with a one-line comment * checks if the given position is commented with a one-line comment
* @param pos the position * @param pos position in the source (like in a string)
* @param src the source to analyze * @param src source to analyze
*/ */
bool srcIsOneLineCommented(size_t pos, const std::string& src); bool srcIsOneLineCommented(size_t pos, const std::string& src);
/** /**
* check if a variable is declared in a source code * checks if a variable is declared
* @param variable the variable to search for * @param variableName variable to search for
* @param src source to analyze
*/ */
bool srcContainsVariableDeclaration(const std::string& variableName, std::string& src); bool srcContainsVariableDeclaration(const std::string& variableName, std::string& src);
/** /**
* set or change shading language version if the current version is lower * sets or changes shading language version if the current version is lower
* @param version the version to set (110, 120, 150...) * @param version version to set (110, 120, 150...)
* @param modifiedSrc shader source code to modify * @param modifiedSrc shader source code to modify
*/ */
bool srcSetMinShadingLanguageVersion(int version, std::string& modifiedSrc); bool srcSetMinShadingLanguageVersion(int version, std::string& modifiedSrc);
/** /**
* change int constant value * changes int constant value
* @param newVal the new value * @param newVal new constant value
* @param constantName constant name as it is declared
* @param modifiedSrc shader source code to modify * @param modifiedSrc shader source code to modify
*/ */
bool srcChangeIntConstantValue(int newVal, const std::string& constantName, std::string& modifiedSrc); bool srcChangeIntConstantValue(int newVal, const std::string& constantName, std::string& modifiedSrc);
/** /**
* insert code before main function into source code * inserts code before main function
* @param insertedCode source code to insert into shader * @param insertedCode source code to insert
* @param modifiedSrc shader source code to modify * @param modifiedSrc shader source code to modify
*/ */
bool srcInsertCodeBeforeMainFunction(const std::string& insertedCode, std::string& modifiedSrc); bool srcInsertCodeBeforeMainFunction(const std::string& insertedCode, std::string& modifiedSrc);
/** /**
* insert code at the beginning of main function into source code * inserts code at the beginning of main function
* @param insertedCode source code to insert into shader * @param insertedCode source code to insert
* @param modifiedSrc shader source code to modify * @param modifiedSrc shader source code to modify
*/ */
bool srcInsertCodeAtMainFunctionBeginning(const std::string& insertedCode, std::string& modifiedSrc); bool srcInsertCodeAtMainFunctionBeginning(const std::string& insertedCode, std::string& modifiedSrc);
/** /**
* insert code at the end of main function into source code * inserts code at the end of main function
* @param insertedCode source code to insert into shader * @param insertedCode source code to insert
* @param modifiedSrc shader source code to modify * @param modifiedSrc shader source code to modify
*/ */
bool srcInsertCodeAtMainFunctionEnd(const std::string& insertedCode, std::string& modifiedSrc); bool srcInsertCodeAtMainFunctionEnd(const std::string& insertedCode, std::string& modifiedSrc);
......
This diff is collapsed.
...@@ -309,7 +309,7 @@ bool ShaderMutator::srcIsCommented(size_t pos, const std::string& src) ...@@ -309,7 +309,7 @@ bool ShaderMutator::srcIsCommented(size_t pos, const std::string& src)
{ {
CGoGNerr CGoGNerr
<< "ERROR - " << "ERROR - "
<< "ShaderMutator::isCommented : " << "ShaderMutator::srcIsCommented : "
<< "Given position is out of range" << "Given position is out of range"
<< CGoGNendl; << CGoGNendl;
return false; return false;
...@@ -359,7 +359,7 @@ bool ShaderMutator::srcIsOneLineCommented(size_t pos, const std::string& src) ...@@ -359,7 +359,7 @@ bool ShaderMutator::srcIsOneLineCommented(size_t pos, const std::string& src)
{ {
CGoGNerr CGoGNerr
<< "ERROR - " << "ERROR - "
<< "ShaderMutator::isOneLineCommented : " << "ShaderMutator::srcIsOneLineCommented : "
<< "Given position is out of range" << "Given position is out of range"
<< CGoGNendl; << CGoGNendl;
return false; return false;
...@@ -372,6 +372,7 @@ bool ShaderMutator::srcIsOneLineCommented(size_t pos, const std::string& src) ...@@ -372,6 +372,7 @@ bool ShaderMutator::srcIsOneLineCommented(size_t pos, const std::string& src)
// As soon as a '\n' is found, any other "//" will not affect this line anymore // As soon as a '\n' is found, any other "//" will not affect this line anymore
if (src[i] == '\n') if (src[i] == '\n')
return false; return false;
// Else if a '/' is found, look if it is followed by another
else if (src[i] == '/') else if (src[i] == '/')
if (src[i-1] == '/') if (src[i-1] == '/')
return true; return true;
...@@ -442,7 +443,7 @@ bool ShaderMutator::srcSetMinShadingLanguageVersion(int version, std::string& mo ...@@ -442,7 +443,7 @@ bool ShaderMutator::srcSetMinShadingLanguageVersion(int version, std::string& mo
size_t oldVersionLength = oldVersion.length(); size_t oldVersionLength = oldVersion.length();
size_t oldVersionPosition = std::distance(modifiedSrc.begin(), matches[1].first); size_t oldVersionPosition = std::distance(modifiedSrc.begin(), matches[1].first);
// Replace the version value only if it is lower than 'version' // Replace the old version value only if it is lower than 'version'
if (oldVersionValue < version) if (oldVersionValue < version)
{ {
modifiedSrc.replace(oldVersionPosition, oldVersionLength, versionStr); modifiedSrc.replace(oldVersionPosition, oldVersionLength, versionStr);
...@@ -496,7 +497,7 @@ bool ShaderMutator::srcChangeIntConstantValue(int newVal, const std::string& con ...@@ -496,7 +497,7 @@ bool ShaderMutator::srcChangeIntConstantValue(int newVal, const std::string& con
size_t oldValLength = oldValStr.length(); size_t oldValLength = oldValStr.length();
size_t oldValPosition = std::distance(modifiedSrc.begin(), matches[1].first); size_t oldValPosition = std::distance(modifiedSrc.begin(), matches[1].first);
// Replace the constant value // Replace the old constant value
modifiedSrc.replace(oldValPosition, oldValLength, newValStr); modifiedSrc.replace(oldValPosition, oldValLength, newValStr);
return true; return true;
} }
......
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