summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authorMaximillian <maximillian.pol@gmail.com>2015-01-08 09:30:13 -0700
committerMaximillian <maximillian.pol@gmail.com>2015-01-08 09:30:13 -0700
commit41b3a1fea3e1c948520514d34dafe5a48728f1f8 (patch)
treef6d08c5ee598edf1da2497ea9e4f6c99bb37e468 /tools/editor
parent5c5519e2c896200652102d34cafde1315b3b9146 (diff)
parent78f4b937034c8bc24c2a871b1fc08ecbe39d0e5e (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp80
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.h3
2 files changed, 66 insertions, 17 deletions
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index 54e8268574..0a206c4a45 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -200,7 +200,7 @@ void ShaderGraphView::_vec_input_changed(double p_value, int p_id,Array p_arr){
}
void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){
- print_line("XFIC");
+
ToolButton *tb = p_button->cast_to<ToolButton>();
ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height));
ped_popup->set_size(tb->get_size());
@@ -445,7 +445,7 @@ void ShaderGraphView::_node_removed(int p_id) {
void ShaderGraphView::_node_moved(const Vector2& p_from, const Vector2& p_to,int p_id) {
- print_line("moved from "+p_from+" to "+p_to);
+
ERR_FAIL_COND(!node_map.has(p_id));
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Move Shader Graph Node");
@@ -745,14 +745,9 @@ void ShaderGraphView::_create_node(int p_id) {
} break; // mat4 x mat4
- case ShaderGraph::NODE_XFORM_VEC_MULT:
- case ShaderGraph::NODE_XFORM_VEC_INV_MULT: {
-
- if (graph->node_get_type(type,p_id)==ShaderGraph::NODE_XFORM_VEC_INV_MULT)
- gn->set_title("XFVecMult");
- else
- gn->set_title("XFVecInvMult");
+ case ShaderGraph::NODE_XFORM_VEC_MULT: {
+ gn->set_title("XFVecMult");
Button *button = memnew( Button("RotOnly"));
button->set_toggle_mode(true);
@@ -774,6 +769,32 @@ void ShaderGraphView::_create_node(int p_id) {
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_XFORM,typecol[ShaderGraph::SLOT_TYPE_XFORM],true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC]);
gn->set_slot(2,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],false,0,Color());
+ } break;
+ case ShaderGraph::NODE_XFORM_VEC_INV_MULT: {
+
+ gn->set_title("XFVecInvMult");
+
+
+ Button *button = memnew( Button("RotOnly"));
+ button->set_toggle_mode(true);
+ button->set_pressed(graph->xform_vec_mult_node_get_no_translation(type,p_id));
+ button->connect("toggled",this,"_xform_inv_rev_changed",varray(p_id));
+
+ gn->add_child(button);
+
+ gn->add_child( memnew(Label("vec")));
+ HBoxContainer *hbc = memnew( HBoxContainer );
+ hbc->add_constant_override("separation",0);
+ hbc->add_child( memnew(Label("xf")));
+ hbc->add_spacer();
+ Label *l = memnew(Label("out"));
+ l->set_align(Label::ALIGN_RIGHT);
+ hbc->add_child( l);
+ gn->add_child(hbc);
+
+ gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],false,0,Color());
+ gn->set_slot(2,true,ShaderGraph::SLOT_TYPE_XFORM,typecol[ShaderGraph::SLOT_TYPE_XFORM],true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC]);
+
} break; // mat4 x vec3 inverse mult (with no-translation option)
case ShaderGraph::NODE_SCALAR_FUNC: {
@@ -1002,7 +1023,7 @@ void ShaderGraphView::_create_node(int p_id) {
gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC]);
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],false,0,Color());
- gn->set_slot(2,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],false,0,Color());
+ gn->set_slot(2,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],false,0,Color());
} break; // vec3 interpolation (with optional curve)
case ShaderGraph::NODE_SCALAR_INPUT: {
@@ -1192,7 +1213,7 @@ void ShaderGraphView::_create_node(int p_id) {
graph_edit->add_child(gn);
node_map[p_id]=gn;
gn->set_offset(graph->node_get_pos(type,p_id));
- print_line("NODE "+itos(p_id)+" OFS "+gn->get_offset());
+
}
@@ -1215,7 +1236,7 @@ void ShaderGraphView::_update_graph() {
List<int> nl;
graph->get_node_list(type,&nl);
- print_line("graph nodes: "+itos(nl.size()));
+
for(List<int>::Element *E=nl.front();E;E=E->next()) {
_create_node(E->get());
@@ -1234,11 +1255,29 @@ void ShaderGraphView::_update_graph() {
}
+void ShaderGraphView::_sg_updated() {
+
+ if (!graph.is_valid())
+ return;
+ switch(graph->get_graph_error(type)) {
+ case ShaderGraph::GRAPH_OK: status->set_text(""); break;
+ case ShaderGraph::GRAPH_ERROR_CYCLIC: status->set_text("Error: Cyclic Connection Link"); break;
+ case ShaderGraph::GRAPH_ERROR_MISSING_CONNECTIONS: status->set_text("Error: Missing Input Connections"); break;
+ }
+}
+
void ShaderGraphView::set_graph(Ref<ShaderGraph> p_graph){
- print_line("GRAPH EDIT: "+itos(p_graph.is_valid()));
+
+ if (graph.is_valid()) {
+ graph->disconnect("updated",this,"_sg_updated");
+ }
graph=p_graph;
+ if (graph.is_valid()) {
+ graph->connect("updated",this,"_sg_updated");
+ }
_update_graph();
+ _sg_updated();
}
@@ -1322,6 +1361,7 @@ void ShaderGraphView::_bind_methods() {
ObjectTypeDB::bind_method("_cube_edited",&ShaderGraphView::_cube_edited);
ObjectTypeDB::bind_method("_comment_edited",&ShaderGraphView::_comment_edited);
+ ObjectTypeDB::bind_method("_sg_updated",&ShaderGraphView::_sg_updated);
}
ShaderGraphView::ShaderGraphView(ShaderGraph::ShaderType p_type) {
@@ -1331,8 +1371,15 @@ ShaderGraphView::ShaderGraphView(ShaderGraph::ShaderType p_type) {
block_update=false;
ped_popup = memnew( CustomPropertyEditor );
graph_edit->add_child(ped_popup);
-
-
+ status = memnew( Label );
+ graph_edit->get_top_layer()->add_child(status);
+ status->set_pos(Vector2(5,5));
+ status->add_color_override("font_color_shadow",Color(0,0,0));
+ status->add_color_override("font_color",Color(1,0.4,0.3));
+ status->add_constant_override("shadow_as_outline",1);
+ status->add_constant_override("shadow_offset_x",2);
+ status->add_constant_override("shadow_offset_y",2);
+ status->set_text("");
}
@@ -1423,7 +1470,7 @@ ShaderGraphEditor::ShaderGraphEditor() {
HBoxContainer *hbc = memnew( HBoxContainer );
menu = memnew( MenuButton );
- menu->set_text("Add..");
+ menu->set_text("Add Node..");
hbc->add_child(menu);
add_child(hbc);
@@ -1445,6 +1492,7 @@ ShaderGraphEditor::ShaderGraphEditor() {
graph_edits[i]->get_graph_edit()->connect("connection_request",graph_edits[i],"_connection_request");
graph_edits[i]->get_graph_edit()->connect("disconnection_request",graph_edits[i],"_disconnection_request");
graph_edits[i]->get_graph_edit()->set_right_disconnects(true);
+
}
tabs->set_current_tab(1);
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.h b/tools/editor/plugins/shader_graph_editor_plugin.h
index 8be3b3293e..bd983c59be 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.h
+++ b/tools/editor/plugins/shader_graph_editor_plugin.h
@@ -54,6 +54,7 @@ class ShaderGraphView : public Node {
CustomPropertyEditor *ped_popup;
bool block_update;
+ Label *status;
GraphEdit *graph_edit;
Ref<ShaderGraph> graph;
int edited_id;
@@ -95,7 +96,7 @@ class ShaderGraphView : public Node {
void _variant_edited();
void _comment_edited(int p_id,Node* p_button);
-
+ void _sg_updated();
Map<int,GraphNode*> node_map;
protected:
void _notification(int p_what);