Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometror committed Oct 24, 2024
1 parent 533c616 commit 9519f26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
8 changes: 5 additions & 3 deletions editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ void VisualShaderEditor::edit_shader(const Ref<Shader> &p_shader) {
graph_plugin->register_shader(visual_shader.ptr());

visual_shader->connect_changed(callable_mp(this, &VisualShaderEditor::_update_preview));
visual_shader->set_graph_offset(graph->get_scroll_offset() / EDSCALE);
// EditorSettings::get_singleton()->set_project_metadata("visual_shader", visual_shader->get_path(), graph->get_scroll_offset() / EDSCALE);
_set_mode(visual_shader->get_mode());

preview_material->set_shader(visual_shader);
Expand Down Expand Up @@ -2491,7 +2491,8 @@ void VisualShaderEditor::_update_graph() {
return;
}

graph->set_scroll_offset(visual_shader->get_graph_offset() * EDSCALE);
// graph->set_scroll_offset(visual_shader->get_graph_offset() * EDSCALE);
graph->set_scroll_offset(EditorSettings::get_singleton()->get_project_metadata("visual_shader", visual_shader->get_path(), Vector2(0, 0)));

VisualShader::Type type = get_current_shader_type();

Expand Down Expand Up @@ -5183,7 +5184,8 @@ void VisualShaderEditor::_scroll_changed(const Vector2 &p_scroll) {
return;
}
updating = true;
visual_shader->set_graph_offset(p_scroll / EDSCALE);
// visual_shader->set_graph_offset(p_scroll / EDSCALE);
EditorSettings::get_singleton()->set_project_metadata("visual_shader", visual_shader->get_path(), p_scroll / EDSCALE);
updating = false;
}

Expand Down
13 changes: 0 additions & 13 deletions scene/resources/visual_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,14 +1468,6 @@ void VisualShader::set_mode(Mode p_mode) {
notify_property_list_changed();
}

void VisualShader::set_graph_offset(const Vector2 &p_offset) {
graph_offset = p_offset;
}

Vector2 VisualShader::get_graph_offset() const {
return graph_offset;
}

Shader::Mode VisualShader::get_mode() const {
return shader_mode;
}
Expand Down Expand Up @@ -3001,9 +2993,6 @@ void VisualShader::_bind_methods() {

ClassDB::bind_method(D_METHOD("get_node_connections", "type"), &VisualShader::_get_node_connections);

ClassDB::bind_method(D_METHOD("set_graph_offset", "offset"), &VisualShader::set_graph_offset);
ClassDB::bind_method(D_METHOD("get_graph_offset"), &VisualShader::get_graph_offset);

ClassDB::bind_method(D_METHOD("attach_node_to_frame", "type", "id", "frame"), &VisualShader::attach_node_to_frame);
ClassDB::bind_method(D_METHOD("detach_node_from_frame", "type", "id"), &VisualShader::detach_node_from_frame);

Expand All @@ -3017,8 +3006,6 @@ void VisualShader::_bind_methods() {

ClassDB::bind_method(D_METHOD("_update_shader"), &VisualShader::_update_shader);

ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "graph_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_graph_offset", "get_graph_offset");

ADD_PROPERTY_DEFAULT("code", ""); // Inherited from Shader, prevents showing default code as override in docs.

BIND_ENUM_CONSTANT(TYPE_VERTEX);
Expand Down
5 changes: 0 additions & 5 deletions scene/resources/visual_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ class VisualShader : public Shader {

TypedArray<Dictionary> _get_node_connections(Type p_type) const;

Vector2 graph_offset;

HashMap<String, int> modes;
HashSet<StringName> flags;

Expand Down Expand Up @@ -246,9 +244,6 @@ class VisualShader : public Shader {

virtual bool is_text_shader() const override;

void set_graph_offset(const Vector2 &p_offset);
Vector2 get_graph_offset() const;

String generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &r_default_tex_params) const;

String validate_port_name(const String &p_port_name, VisualShaderNode *p_node, int p_port_id, bool p_output) const;
Expand Down

0 comments on commit 9519f26

Please sign in to comment.