Add a way to force history for undoredo

This commit is contained in:
kobewi 2023-07-22 20:16:54 +02:00
parent 95110ddcb4
commit 57e046541d
5 changed files with 33 additions and 2 deletions

View file

@ -3649,12 +3649,15 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, cons
if (output_port_type == VisualShaderNode::PORT_TYPE_SAMPLER) {
if (is_texture2d) {
undo_redo->force_fixed_history(); // vsnode is freshly created and has no path, so history can't be correctly determined.
undo_redo->add_do_method(vsnode.ptr(), "set_source", VisualShaderNodeTexture::SOURCE_PORT);
}
if (is_texture3d || is_texture2d_array) {
undo_redo->force_fixed_history();
undo_redo->add_do_method(vsnode.ptr(), "set_source", VisualShaderNodeSample3D::SOURCE_PORT);
}
if (is_cubemap) {
undo_redo->force_fixed_history();
undo_redo->add_do_method(vsnode.ptr(), "set_source", VisualShaderNodeCubemap::SOURCE_PORT);
}
}
@ -3754,16 +3757,19 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, cons
//post-initialization
if (is_texture2d || is_texture3d || is_curve || is_curve_xyz) {
undo_redo->force_fixed_history();
undo_redo->add_do_method(vsnode.ptr(), "set_texture", ResourceLoader::load(p_resource_path));
return;
}
if (is_cubemap) {
undo_redo->force_fixed_history();
undo_redo->add_do_method(vsnode.ptr(), "set_cube_map", ResourceLoader::load(p_resource_path));
return;
}
if (is_texture2d_array) {
undo_redo->force_fixed_history();
undo_redo->add_do_method(vsnode.ptr(), "set_texture_array", ResourceLoader::load(p_resource_path));
}
}