From 10425b756342776b1a2a98aa6df57110097f41d3 Mon Sep 17 00:00:00 2001 From: codereader Date: Fri, 19 Mar 2021 07:46:28 +0100 Subject: [PATCH] #5532: Remove all the unused code for handling the expressions for the various transformation types separately --- include/ishaderlayer.h | 47 +- install/ui/materialeditor.fbp | 1507 +--------------------- install/ui/materialeditor.xrc | 255 +--- radiant/ui/materials/MaterialEditor.cpp | 25 - radiantcore/shaders/Doom3ShaderLayer.cpp | 104 +- radiantcore/shaders/Doom3ShaderLayer.h | 168 --- 6 files changed, 7 insertions(+), 2099 deletions(-) diff --git a/include/ishaderlayer.h b/include/ishaderlayer.h index 9cc8f99c02..619bdce567 100644 --- a/include/ishaderlayer.h +++ b/include/ishaderlayer.h @@ -80,8 +80,7 @@ class IShaderLayer FLAG_MASK_BLUE = 1 << 8, FLAG_MASK_ALPHA = 1 << 9, FLAG_MASK_DEPTH = 1 << 10, - FLAG_CENTERSCALE = 1 << 11, // whether to translate -0.5, scale and translate +0.5 - FLAG_IGNORE_DEPTH = 1 << 12, // use depthfunc always + FLAG_IGNORE_DEPTH = 1 << 11, // use depthfunc always }; enum TexGenType @@ -291,46 +290,7 @@ class IShaderLayer // Returns the current texture matrix virtual Matrix4 getTextureTransform() = 0; - /** - * Returns the value of the scale expressions of this stage. - */ - virtual Vector2 getScale() const = 0; - - // Returns the expression of the given scale component (0 == x, 1 == y) - virtual const shaders::IShaderExpression::Ptr& getScaleExpression(std::size_t index) const = 0; - - // Workaround: the shader layer is storing the centerscale expression in the same location as scale expressions, - // making them mutually exclusive - which is not the way the idTech4 materials work. - // These stage transforms need to be redesigned to support an arbitrary number of transforms respecting their order. - // Texture Matrix calculation needs to be performed by the stage itself, not in OpenGLShaderPass - // I need to go ahead with the material editor, so I'm not changing it immediately - virtual const shaders::IShaderExpression::Ptr& getCenterScaleExpression(std::size_t index) const = 0; - - /** - * Returns the value of the translate expressions of this stage. - */ - virtual Vector2 getTranslation() const = 0; - - // Returns the expression of the given translation component (0 == x, 1 == y) - virtual const shaders::IShaderExpression::Ptr& getTranslationExpression(std::size_t index) const = 0; - - /** - * Returns the value of the rotate expression of this stage. - */ - virtual float getRotation() const = 0; - - // Returns the expression used to calculate the rotation value - virtual const shaders::IShaderExpression::Ptr& getRotationExpression() const = 0; - - /** - * Returns the value of the 'shear' expressions of this stage. - */ - virtual Vector2 getShear() const = 0; - - // Returns the expression of the given shear component (0 == x, 1 == y) - virtual const shaders::IShaderExpression::Ptr& getShearExpression(std::size_t index) const = 0; - - // Returns true if this layer has an alphatest expression defined + // Returns true if this layer has an alphatest expression defined virtual bool hasAlphaTest() const = 0; /** @@ -442,9 +402,6 @@ class IEditableShaderLayer : virtual ~IEditableShaderLayer() {} - // Set the translation expression [0..1] to the given string - virtual void setTranslationExpressionFromString(std::size_t index, const std::string& expression) = 0; - // Set the alpha test expression from the given string virtual void setAlphaTestExpressionFromString(const std::string& expression) = 0; diff --git a/install/ui/materialeditor.fbp b/install/ui/materialeditor.fbp index 03aac6af00..9816819834 100644 --- a/install/ui/materialeditor.fbp +++ b/install/ui/materialeditor.fbp @@ -9745,7 +9745,7 @@ Blending - 1 + 0 1 1 @@ -14000,7 +14000,7 @@ Transform - 0 + 1 1 1 @@ -14057,1509 +14057,6 @@ bSizer2612 wxVERTICAL none - - 6 - wxALL|wxEXPAND - 1 - - 2 - wxBOTH - 1 - - 12 - - fgSizer112 - wxFLEX_GROWMODE_SPECIFIED - none - 7 - 6 - - 6 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Scroll/Translate: - 0 - - 0 - - - 0 - - 1 - m_staticText117 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 6 - wxEXPAND - 1 - - - bSizer111 - wxHORIZONTAL - none - - 6 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - U: - 0 - - 0 - - - 0 - - 1 - m_staticText118 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageTranslateX - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 6 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - V: - 0 - - 0 - - - 0 - - 1 - m_staticText119 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageTranslateY - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - 0 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Scale: - 0 - - 0 - - - 0 - - 1 - m_staticText11711 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND - 1 - - - bSizer11111 - wxHORIZONTAL - none - - 6 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - U: - 0 - - 0 - - - 0 - - 1 - m_staticText11811 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageScaleX - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 6 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - V: - 0 - - 0 - - - 0 - - 1 - m_staticText11911 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageScaleY - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - 0 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - CenterScale: - 0 - - 0 - - - 0 - - 1 - m_staticText117111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND - 1 - - - bSizer111111 - wxHORIZONTAL - none - - 6 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - U: - 0 - - 0 - - - 0 - - 1 - m_staticText118111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageCenterScaleX - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 6 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - V: - 0 - - 0 - - - 0 - - 1 - m_staticText119111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageCenterScaleY - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - 0 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Shear: - 0 - - 0 - - - 0 - - 1 - m_staticText1171111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND - 1 - - - bSizer1111111 - wxHORIZONTAL - none - - 6 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - U: - 0 - - 0 - - - 0 - - 1 - m_staticText1181111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageShearX - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 6 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - V: - 0 - - 0 - - - 0 - - 1 - m_staticText1191111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageShearY - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - 0 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Rotate: - 0 - - 0 - - - 0 - - 1 - m_staticText11711111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND - 1 - - - bSizer11111111 - wxHORIZONTAL - none - - 6 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Angle: - 0 - - 0 - - - 0 - - 1 - m_staticText11811111 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 0 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - MaterialStageRotate - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - diff --git a/install/ui/materialeditor.xrc b/install/ui/materialeditor.xrc index af6b67aed4..4d90b85867 100644 --- a/install/ui/materialeditor.xrc +++ b/install/ui/materialeditor.xrc @@ -1649,7 +1649,7 @@ - 1 + 0 @@ -2402,262 +2402,11 @@ - 0 + 1 wxVERTICAL - - - wxALL|wxEXPAND - 6 - - 7 - 2 - 6 - 12 - 1 - - - - wxALIGN_CENTER_VERTICAL - 6 - - - -1 - - - - - wxEXPAND - 6 - - wxHORIZONTAL - - - wxALIGN_CENTER_VERTICAL|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - - - wxALIGN_CENTER_VERTICAL - 0 - - - -1 - - - - - wxEXPAND - 5 - - wxHORIZONTAL - - - wxALIGN_CENTER_VERTICAL|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - - - wxALIGN_CENTER_VERTICAL - 0 - - - -1 - - - - - wxEXPAND - 5 - - wxHORIZONTAL - - - wxALIGN_CENTER_VERTICAL|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - - - wxALIGN_CENTER_VERTICAL - 0 - - - -1 - - - - - wxEXPAND - 5 - - wxHORIZONTAL - - - wxALIGN_CENTER_VERTICAL|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - - - wxALIGN_CENTER_VERTICAL - 0 - - - -1 - - - - - wxEXPAND - 5 - - wxHORIZONTAL - - - wxALIGN_CENTER_VERTICAL|wxRIGHT - 6 - - - -1 - - - - - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - - - - - - - diff --git a/radiant/ui/materials/MaterialEditor.cpp b/radiant/ui/materials/MaterialEditor.cpp index b856811a01..3fa759dc7d 100644 --- a/radiant/ui/materials/MaterialEditor.cpp +++ b/radiant/ui/materials/MaterialEditor.cpp @@ -451,31 +451,6 @@ void MaterialEditor::setupMaterialStageProperties() texgenDropdown->AppendString(pair.first); } - createExpressionBinding("MaterialStageTranslateX", - [](const IShaderLayer::Ptr& layer) { return layer->getTranslationExpression(0); }, - [](const IEditableShaderLayer::Ptr& layer, const std::string& value) { layer->setTranslationExpressionFromString(0, value); }); - createExpressionBinding("MaterialStageTranslateY", - [](const IShaderLayer::Ptr& layer) { return layer->getTranslationExpression(1); }, - [](const IEditableShaderLayer::Ptr& layer, const std::string& value) { layer->setTranslationExpressionFromString(1, value); }); - - createExpressionBinding("MaterialStageScaleX", - [](const IShaderLayer::Ptr& layer) { return layer->getScaleExpression(0); }); - createExpressionBinding("MaterialStageScaleY", - [](const IShaderLayer::Ptr& layer) { return layer->getScaleExpression(1); }); - - createExpressionBinding("MaterialStageCenterScaleX", - [](const IShaderLayer::Ptr& layer) { return layer->getCenterScaleExpression(0); }); - createExpressionBinding("MaterialStageCenterScaleY", - [](const IShaderLayer::Ptr& layer) { return layer->getCenterScaleExpression(1); }); - - createExpressionBinding("MaterialStageShearX", - [](const IShaderLayer::Ptr& layer) { return layer->getShearExpression(0); }); - createExpressionBinding("MaterialStageShearY", - [](const IShaderLayer::Ptr& layer) { return layer->getShearExpression(1); }); - - createExpressionBinding("MaterialStageRotate", - [](const IShaderLayer::Ptr& layer) { return layer->getRotationExpression(); }); - createExpressionBinding("MaterialStageCondition", [](const IShaderLayer::Ptr& layer) { return layer->getConditionExpression(); }); diff --git a/radiantcore/shaders/Doom3ShaderLayer.cpp b/radiantcore/shaders/Doom3ShaderLayer.cpp index 7d2642ea8f..f3a5abc748 100644 --- a/radiantcore/shaders/Doom3ShaderLayer.cpp +++ b/radiantcore/shaders/Doom3ShaderLayer.cpp @@ -110,23 +110,6 @@ Doom3ShaderLayer::Doom3ShaderLayer(ShaderTemplate& material, IShaderLayer::Type // Initialise the texture matrix to an identity transform _textureMatrix.setIdentity(); - // Scale is set to 1,1 by default - _scale[0] = _scale[1] = REG_ONE; - _scaleExpression[0] = _scaleExpression[1] = NOT_DEFINED; - - // Translation is set to 0,0 by default - _translation[0] = _translation[1] = REG_ZERO; - _translationExpression[0] = _translationExpression[1] = NOT_DEFINED; - - // Rotation is set to 0 by default - _rotation = REG_ZERO; - _rotationExpression = NOT_DEFINED; - - // No shearing so far - _shear[0] = REG_ZERO; - _shear[1] = REG_ZERO; - _shearExpression[0] = _shearExpression[1] = NOT_DEFINED; - _expressionSlots[Expression::TexGenParam1].registerIndex = REG_ZERO; _expressionSlots[Expression::TexGenParam2].registerIndex = REG_ZERO; _expressionSlots[Expression::TexGenParam3].registerIndex = REG_ZERO; @@ -135,7 +118,6 @@ Doom3ShaderLayer::Doom3ShaderLayer(ShaderTemplate& material, IShaderLayer::Type Doom3ShaderLayer::Doom3ShaderLayer(const Doom3ShaderLayer& other, ShaderTemplate& material) : _material(material), _registers(other._registers), - _expressions(other._expressions), _expressionSlots(other._expressionSlots, _registers), _bindableTex(other._bindableTex), _texture(other._texture), @@ -148,8 +130,6 @@ Doom3ShaderLayer::Doom3ShaderLayer(const Doom3ShaderLayer& other, ShaderTemplate _clampType(other._clampType), _texGenType(other._texGenType), _textureMatrix(_expressionSlots, _registers), // no copying necessary - _rotation(other._rotation), - _rotationExpression(other._rotationExpression), _vertexProgram(other._vertexProgram), _fragmentProgram(other._fragmentProgram), _vertexParms(other._vertexParms), @@ -158,22 +138,7 @@ Doom3ShaderLayer::Doom3ShaderLayer(const Doom3ShaderLayer& other, ShaderTemplate _privatePolygonOffset(other._privatePolygonOffset), _renderMapSize(other._renderMapSize), _parseFlags(other._parseFlags) -{ - _scale[0] = other._scale[0]; - _scale[1] = other._scale[1]; - _scaleExpression[0] = other._scaleExpression[0]; - _scaleExpression[1] = other._scaleExpression[1]; - - _translation[0] = other._translation[0]; - _translation[1] = other._translation[1]; - _translationExpression[0] = other._translationExpression[0]; - _translationExpression[1] = other._translationExpression[1]; - - _shear[0] = other._shear[0]; - _shear[1] = other._shear[1]; - _shearExpression[0] = other._shearExpression[0]; - _shearExpression[1] = other._shearExpression[1]; -} +{} TexturePtr Doom3ShaderLayer::getTexture() const { @@ -514,71 +479,4 @@ void Doom3ShaderLayer::addVertexParm(const VertexParm& parm) assert(_vertexParms.size() % 4 == 0); } -void Doom3ShaderLayer::assignExpression(const IShaderExpression::Ptr& expression, - std::size_t& expressionIndex, std::size_t& registerIndex, std::size_t defaultRegisterIndex) -{ - if (!expression) - { - // Assigning an empty expression will reset the slot to NOT_DEFINED - if (expressionIndex != NOT_DEFINED) - { - // Release the previous expression - assert(_expressions[expressionIndex]); - - _expressions[expressionIndex]->unlinkFromRegisters(); - _expressions[expressionIndex].reset(); - } - - expressionIndex = NOT_DEFINED; - registerIndex = defaultRegisterIndex; - return; - } - - // Non-empty expression, overwrite if we have an existing expression in the slot - if (expressionIndex != NOT_DEFINED) - { - // Try to re-use the previous register position - auto previousExpression = _expressions[expressionIndex]; - _expressions[expressionIndex] = expression; - - if (previousExpression->isLinked()) - { - registerIndex = previousExpression->unlinkFromRegisters(); - expression->linkToSpecificRegister(_registers, registerIndex); - } - else - { - registerIndex = expression->linkToRegister(_registers); - } - } - else - { - expressionIndex = _expressions.size(); - _expressions.emplace_back(expression); - - registerIndex = expression->linkToRegister(_registers); - } -} - -void Doom3ShaderLayer::assignExpressionFromString(const std::string& expressionString, - std::size_t& expressionIndex, std::size_t& registerIndex, std::size_t defaultRegisterIndex) -{ - // An empty string will clear the expression - if (expressionString.empty()) - { - assignExpression(IShaderExpression::Ptr(), expressionIndex, registerIndex, defaultRegisterIndex); - return; - } - - // Attempt to parse the string - auto expression = ShaderExpression::createFromString(expressionString); - - if (!expression) - { - return; // parsing failures will not overwrite the expression slot - } - - assignExpression(expression, expressionIndex, registerIndex, defaultRegisterIndex); -} - } diff --git a/radiantcore/shaders/Doom3ShaderLayer.h b/radiantcore/shaders/Doom3ShaderLayer.h index 6bcde070ca..071e633531 100644 --- a/radiantcore/shaders/Doom3ShaderLayer.h +++ b/radiantcore/shaders/Doom3ShaderLayer.h @@ -32,10 +32,6 @@ class Doom3ShaderLayer : Registers _registers; // The expressions used in this stage - typedef std::vector Expressions; - // deprecated - Expressions _expressions; - ExpressionSlots _expressionSlots; static const IShaderExpression::Ptr NULL_EXPRESSION; @@ -77,22 +73,6 @@ class Doom3ShaderLayer : // Handles the expressions used to calculcate the final texture matrix TextureMatrix _textureMatrix; - // The register indices of this stage's scale expressions - std::size_t _scale[2]; - std::size_t _scaleExpression[2]; - - // The register indices of this stage's translate expressions - std::size_t _translation[2]; - std::size_t _translationExpression[2]; - - // The rotation register index - std::size_t _rotation; - std::size_t _rotationExpression; - - // The register indices of this stage's shear expressions - std::size_t _shear[2]; - std::size_t _shearExpression[2]; - // The shader programs used in this stage std::string _vertexProgram; std::string _fragmentProgram; @@ -163,14 +143,6 @@ class Doom3ShaderLayer : void evaluateExpressions(std::size_t time) { - for (const auto& expression : _expressions) - { - if (expression) - { - expression->evaluate(time); - } - } - for (const auto& slot : _expressionSlots) { if (slot.expression) @@ -190,14 +162,6 @@ class Doom3ShaderLayer : void evaluateExpressions(std::size_t time, const IRenderEntity& entity) { - for (const auto& expression : _expressions) - { - if (expression) - { - expression->evaluate(time, entity); - } - } - for (const auto& slot : _expressionSlots) { if (slot.expression) @@ -372,131 +336,6 @@ class Doom3ShaderLayer : const std::vector& getTransformations() override; Matrix4 getTextureTransform() override; - Vector2 getScale() const override - { - return Vector2(_registers[_scale[0]], _registers[_scale[1]]); - } - - const shaders::IShaderExpression::Ptr& getScaleExpression(std::size_t index) const override - { - assert(index < 2); - - if (getStageFlags() & FLAG_CENTERSCALE) - { - return NULL_EXPRESSION; - } - - auto expressionIndex = _scaleExpression[index]; - return expressionIndex != NOT_DEFINED ? _expressions[expressionIndex] : NULL_EXPRESSION; - } - - const shaders::IShaderExpression::Ptr& getCenterScaleExpression(std::size_t index) const override - { - assert(index < 2); - - if ((getStageFlags() & FLAG_CENTERSCALE) == 0) - { - return NULL_EXPRESSION; - } - - auto expressionIndex = _scaleExpression[index]; - return expressionIndex != NOT_DEFINED ? _expressions[expressionIndex] : NULL_EXPRESSION; - } - - /** - * Set the scale expressions of this stage, overwriting any previous scales. - */ - void setScale(const IShaderExpression::Ptr& xExpr, const IShaderExpression::Ptr& yExpr) - { - _scaleExpression[0] = _expressions.size(); - _expressions.emplace_back(xExpr); - _scaleExpression[1] = _expressions.size(); - _expressions.emplace_back(yExpr); - - _scale[0] = xExpr->linkToRegister(_registers); - _scale[1] = yExpr->linkToRegister(_registers); - } - - Vector2 getTranslation() const override - { - return Vector2(_registers[_translation[0]], _registers[_translation[1]]); - } - - const shaders::IShaderExpression::Ptr& getTranslationExpression(std::size_t index) const override - { - assert(index < 2); - auto expressionIndex = _translationExpression[index]; - return expressionIndex != NOT_DEFINED ? _expressions[expressionIndex] : NULL_EXPRESSION; - } - - void setTranslationExpressionFromString(std::size_t index, const std::string& expressionString) override - { - assert(index < 2); - - assignExpressionFromString(expressionString, _translationExpression[index], _translation[index], REG_ZERO); - } - - /** - * Set the "translate" expressions of this stage, overwriting any previous expressions. - */ - void setTranslation(const IShaderExpression::Ptr& xExpr, const IShaderExpression::Ptr& yExpr) - { - _translationExpression[0] = _expressions.size(); - _expressions.emplace_back(xExpr); - _translationExpression[1] = _expressions.size(); - _expressions.emplace_back(yExpr); - - _translation[0] = xExpr->linkToRegister(_registers); - _translation[1] = yExpr->linkToRegister(_registers); - } - - float getRotation() const override - { - return _registers[_rotation]; - } - - const shaders::IShaderExpression::Ptr& getRotationExpression() const override - { - return _rotationExpression != NOT_DEFINED ? _expressions[_rotationExpression] : NULL_EXPRESSION; - } - - /** - * Set the "rotate" expression of this stage, overwriting any previous one. - */ - void setRotation(const IShaderExpression::Ptr& expr) - { - _rotationExpression = _expressions.size(); - _expressions.emplace_back(expr); - - _rotation = expr->linkToRegister(_registers); - } - - Vector2 getShear() const override - { - return Vector2(_registers[_shear[0]], _registers[_shear[1]]); - } - - const shaders::IShaderExpression::Ptr& getShearExpression(std::size_t index) const override - { - assert(index < 2); - auto expressionIndex = _shearExpression[index]; - return expressionIndex != NOT_DEFINED ? _expressions[expressionIndex] : NULL_EXPRESSION; - } - - /** - * Set the shear expressions of this stage, overwriting any previous ones. - */ - void setShear(const IShaderExpression::Ptr& xExpr, const IShaderExpression::Ptr& yExpr) - { - _shearExpression[0] = _expressions.size(); - _expressions.emplace_back(xExpr); - _shearExpression[1] = _expressions.size(); - _expressions.emplace_back(yExpr); - - _shear[0] = xExpr->linkToRegister(_registers); - _shear[1] = yExpr->linkToRegister(_registers); - } - /** * \brief * Set cube map mode. @@ -592,13 +431,6 @@ class Doom3ShaderLayer : int getParseFlags() const override; void setParseFlag(ParseFlags flag); - -private: - void assignExpression(const IShaderExpression::Ptr& expression, - std::size_t& expressionIndex, std::size_t& registerIndex, std::size_t defaultRegisterIndex); - - void assignExpressionFromString(const std::string& expressionString, - std::size_t& expressionIndex, std::size_t& registerIndex, std::size_t defaultRegisterIndex); }; }