Skip to content

Commit

Permalink
[shgraph] Fix changing texture param not updating graph if it was null
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Dec 19, 2024
1 parent 33cc5b1 commit 938ad93
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions hide/view/shadereditor/ShaderEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,16 @@ class ShaderEditor extends hide.view.FileView implements GraphInterface.IGraphEd
execMoveParameterTo(parameter, parameterPrev, !up);
}

function updateParam(id : Int) {
function updateParam(id : Int) : Bool {
meshPreviewScene.setCurrent(); // needed for texture changes

var param = shaderGraph.getParameter(id);
var init = compiledShader.inits.find((i) -> i.variable.name == param.name);
if (init != null) {
setParamValue(meshPreviewShader, init.variable, param.defaultValue);
return true;
}
return false;
}

var parametersUpdate : Map<Int, (Dynamic) -> Void> = [];
Expand Down Expand Up @@ -666,16 +668,24 @@ class ShaderEditor extends hide.view.FileView implements GraphInterface.IGraphEd
var v = !isUndo ? curr : prev;
shaderGraph.setParameterDefaultValue(parameter.id, v);
parametersUpdate[parameter.id](v);
updateParam(parameter.id);

if (!updateParam(parameter.id)) {
// If the graph was initialised without the variable,
// we need to recompile it
requestRecompile();
}
}
exec(false);
this.undo.change(Custom(exec));
return;
}
if (!shaderGraph.setParameterDefaultValue(parameter.id, currentValue))
return;
//setBoxesParam(parameter.id);
updateParam(parameter.id);
if (!updateParam(parameter.id)) {
// If the graph was initialised without the variable,
// we need to recompile it
requestRecompile();
}
}
typeName = "Texture";

Expand Down

0 comments on commit 938ad93

Please sign in to comment.