Merge branch 'master' of https://github.com/okamstudio/godot
This commit is contained in:
commit
7d8f187c33
@ -49,7 +49,7 @@
|
||||
|
||||
enum PropertyHint {
|
||||
PROPERTY_HINT_NONE, ///< no hint provided.
|
||||
PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step"
|
||||
PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
|
||||
PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
|
||||
PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
|
||||
PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease)
|
||||
|
@ -141,9 +141,6 @@ void GraphEdit::_graph_node_moved(Node *p_gn) {
|
||||
|
||||
GraphNode *gn=p_gn->cast_to<GraphNode>();
|
||||
ERR_FAIL_COND(!gn);
|
||||
|
||||
//gn->set_pos(gn->get_offset()+scroll_offset);
|
||||
|
||||
top_layer->update();
|
||||
}
|
||||
|
||||
@ -172,7 +169,6 @@ void GraphEdit::remove_child_notify(Node *p_child) {
|
||||
void GraphEdit::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_READY) {
|
||||
Size2 size = top_layer->get_size();
|
||||
Size2 hmin = h_scroll->get_combined_minimum_size();
|
||||
Size2 vmin = v_scroll->get_combined_minimum_size();
|
||||
|
||||
@ -491,7 +487,8 @@ void GraphEdit::_top_layer_draw() {
|
||||
connections.erase(to_erase.front()->get());
|
||||
to_erase.pop_front();
|
||||
}
|
||||
//draw connections
|
||||
if (box_selecting)
|
||||
top_layer->draw_rect(box_selecting_rect,Color(0.7,0.7,1.0,0.3));
|
||||
}
|
||||
|
||||
void GraphEdit::_input_event(const InputEvent& p_ev) {
|
||||
@ -500,6 +497,187 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
|
||||
h_scroll->set_val( h_scroll->get_val() - p_ev.mouse_motion.relative_x );
|
||||
v_scroll->set_val( v_scroll->get_val() - p_ev.mouse_motion.relative_y );
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
|
||||
|
||||
just_selected=true;
|
||||
drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (gn && gn->is_selected())
|
||||
gn->set_offset(gn->get_drag_from()+drag_accum);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_MOTION && box_selecting) {
|
||||
box_selecting_to = get_local_mouse_pos();
|
||||
|
||||
box_selecting_rect = Rect2(MIN(box_selecting_from.x,box_selecting_to.x),
|
||||
MIN(box_selecting_from.y,box_selecting_to.y),
|
||||
ABS(box_selecting_from.x-box_selecting_to.x),
|
||||
ABS(box_selecting_from.y-box_selecting_to.y));
|
||||
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (!gn)
|
||||
continue;
|
||||
|
||||
bool in_box = gn->get_rect().intersects(box_selecting_rect);
|
||||
|
||||
if (in_box)
|
||||
gn->set_selected(box_selection_mode_aditive);
|
||||
else
|
||||
gn->set_selected(previus_selected.find(gn)!=NULL);
|
||||
}
|
||||
|
||||
top_layer->update();
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_BUTTON) {
|
||||
|
||||
const InputEventMouseButton &b=p_ev.mouse_button;
|
||||
|
||||
if (b.button_index==BUTTON_RIGHT && b.pressed)
|
||||
{
|
||||
if (box_selecting) {
|
||||
box_selecting = false;
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (!gn)
|
||||
continue;
|
||||
|
||||
gn->set_selected(previus_selected.find(gn)!=NULL);
|
||||
}
|
||||
top_layer->update();
|
||||
} else {
|
||||
emit_signal("popup_request", Vector2(b.global_x, b.global_y));
|
||||
}
|
||||
}
|
||||
|
||||
if (b.button_index==BUTTON_LEFT && !b.pressed && dragging) {
|
||||
if (!just_selected && drag_accum==Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
|
||||
//deselect current node
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
|
||||
if (gn && gn->get_rect().has_point(get_local_mouse_pos()))
|
||||
gn->set_selected(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (drag_accum!=Vector2()) {
|
||||
|
||||
emit_signal("_begin_node_move");
|
||||
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (gn && gn->is_selected())
|
||||
gn->set_drag(false);
|
||||
}
|
||||
|
||||
emit_signal("_end_node_move");
|
||||
}
|
||||
|
||||
dragging = false;
|
||||
|
||||
top_layer->update();
|
||||
}
|
||||
|
||||
if (b.button_index==BUTTON_LEFT && b.pressed) {
|
||||
|
||||
GraphNode *gn;
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
|
||||
gn=get_child(i)->cast_to<GraphNode>();
|
||||
|
||||
if (gn && gn->get_rect().has_point(get_local_mouse_pos()))
|
||||
break;
|
||||
}
|
||||
|
||||
if (gn) {
|
||||
|
||||
if (_filter_input(Vector2(b.x,b.y)))
|
||||
return;
|
||||
|
||||
dragging = true;
|
||||
drag_accum = Vector2();
|
||||
just_selected = !gn->is_selected();
|
||||
if(!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
GraphNode *o_gn = get_child(i)->cast_to<GraphNode>();
|
||||
if (o_gn)
|
||||
o_gn->set_selected(o_gn == gn);
|
||||
}
|
||||
}
|
||||
|
||||
gn->set_selected(true);
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
GraphNode *o_gn = get_child(i)->cast_to<GraphNode>();
|
||||
if (!o_gn)
|
||||
continue;
|
||||
if (o_gn->is_selected())
|
||||
o_gn->set_drag(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
box_selecting = true;
|
||||
box_selecting_from = get_local_mouse_pos();
|
||||
if (b.mod.control) {
|
||||
box_selection_mode_aditive = true;
|
||||
previus_selected.clear();
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (!gn || !gn->is_selected())
|
||||
continue;
|
||||
|
||||
previus_selected.push_back(gn);
|
||||
}
|
||||
} else if (b.mod.shift) {
|
||||
box_selection_mode_aditive = false;
|
||||
previus_selected.clear();
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (!gn || !gn->is_selected())
|
||||
continue;
|
||||
|
||||
previus_selected.push_back(gn);
|
||||
}
|
||||
} else {
|
||||
box_selection_mode_aditive = true;
|
||||
previus_selected.clear();
|
||||
for(int i=get_child_count()-1;i>=0;i--) {
|
||||
|
||||
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
|
||||
if (!gn)
|
||||
continue;
|
||||
|
||||
gn->set_selected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (b.button_index==BUTTON_LEFT && !b.pressed && box_selecting) {
|
||||
box_selecting = false;
|
||||
previus_selected.clear();
|
||||
top_layer->update();
|
||||
}
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::KEY && p_ev.key.scancode==KEY_D && p_ev.key.pressed && p_ev.key.mod.command) {
|
||||
emit_signal("duplicate_nodes_request");
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::KEY && p_ev.key.scancode==KEY_DELETE && p_ev.key.pressed) {
|
||||
emit_signal("delete_nodes_request");
|
||||
accept_event();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GraphEdit::clear_connections() {
|
||||
@ -555,12 +733,18 @@ void GraphEdit::_bind_methods() {
|
||||
|
||||
ADD_SIGNAL(MethodInfo("connection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
|
||||
ADD_SIGNAL(MethodInfo("disconnection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2,"p_position")));
|
||||
ADD_SIGNAL(MethodInfo("duplicate_nodes_request"));
|
||||
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
|
||||
ADD_SIGNAL(MethodInfo("_begin_node_move"));
|
||||
ADD_SIGNAL(MethodInfo("_end_node_move"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
GraphEdit::GraphEdit() {
|
||||
set_focus_mode(FOCUS_ALL);
|
||||
|
||||
top_layer=NULL;
|
||||
top_layer=memnew(GraphEditFilter(this));
|
||||
add_child(top_layer);
|
||||
@ -581,6 +765,9 @@ GraphEdit::GraphEdit() {
|
||||
connecting=false;
|
||||
right_disconnects=false;
|
||||
|
||||
box_selecting = false;
|
||||
dragging = false;
|
||||
|
||||
h_scroll->connect("value_changed", this,"_scroll_moved");
|
||||
v_scroll->connect("value_changed", this,"_scroll_moved");
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class GraphEditFilter : public Control {
|
||||
|
||||
OBJ_TYPE(GraphEditFilter,Control);
|
||||
|
||||
friend class GraphEdit;
|
||||
friend class GraphEdit;
|
||||
GraphEdit *ge;
|
||||
virtual bool has_point(const Point2& p_point) const;
|
||||
|
||||
@ -49,7 +49,16 @@ private:
|
||||
String connecting_target_to;
|
||||
int connecting_target_index;
|
||||
|
||||
bool dragging;
|
||||
bool just_selected;
|
||||
Vector2 drag_accum;
|
||||
|
||||
bool box_selecting;
|
||||
bool box_selection_mode_aditive;
|
||||
Point2 box_selecting_from;
|
||||
Point2 box_selecting_to;
|
||||
Rect2 box_selecting_rect;
|
||||
List<GraphNode*> previus_selected;
|
||||
|
||||
bool right_disconnects;
|
||||
bool updating;
|
||||
@ -71,7 +80,7 @@ private:
|
||||
|
||||
Array _get_connection_list() const;
|
||||
|
||||
friend class GraphEditFilter;
|
||||
friend class GraphEditFilter;
|
||||
bool _filter_input(const Point2& p_point);
|
||||
protected:
|
||||
|
||||
|
@ -160,7 +160,7 @@ void GraphNode::_notification(int p_what) {
|
||||
|
||||
if (p_what==NOTIFICATION_DRAW) {
|
||||
|
||||
Ref<StyleBox> sb=get_stylebox("frame");
|
||||
Ref<StyleBox> sb=get_stylebox(selected ? "selectedframe" : "frame");
|
||||
Ref<Texture> port =get_icon("port");
|
||||
Ref<Texture> close =get_icon("close");
|
||||
int close_offset = get_constant("close_offset");
|
||||
@ -360,6 +360,29 @@ Vector2 GraphNode::get_offset() const {
|
||||
return offset;
|
||||
}
|
||||
|
||||
void GraphNode::set_selected(bool p_selected)
|
||||
{
|
||||
selected = p_selected;
|
||||
update();
|
||||
}
|
||||
|
||||
bool GraphNode::is_selected()
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
|
||||
void GraphNode::set_drag(bool p_drag)
|
||||
{
|
||||
if (p_drag)
|
||||
drag_from=get_offset();
|
||||
else
|
||||
emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
|
||||
}
|
||||
|
||||
Vector2 GraphNode::get_drag_from()
|
||||
{
|
||||
return drag_from;
|
||||
}
|
||||
|
||||
|
||||
void GraphNode::set_show_close_button(bool p_enable){
|
||||
@ -379,7 +402,6 @@ void GraphNode::_connpos_update() {
|
||||
int sep=get_constant("separation");
|
||||
|
||||
Ref<StyleBox> sb=get_stylebox("frame");
|
||||
Ref<Texture> port =get_icon("port");
|
||||
conn_input_cache.clear();
|
||||
conn_output_cache.clear();
|
||||
int vofs=0;
|
||||
@ -503,31 +525,17 @@ Color GraphNode::get_connection_output_color(int p_idx) {
|
||||
|
||||
void GraphNode::_input_event(const InputEvent& p_ev) {
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
|
||||
if (p_ev.type==InputEvent::MOUSE_BUTTON) {
|
||||
get_parent_control()->grab_focus();
|
||||
if(p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
|
||||
|
||||
Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);
|
||||
if (close_rect.size!=Size2() && close_rect.has_point(mpos)) {
|
||||
emit_signal("close_request");
|
||||
return;
|
||||
}
|
||||
|
||||
drag_from=get_offset();
|
||||
drag_accum=Vector2();
|
||||
dragging=true;
|
||||
emit_signal("raise_request");
|
||||
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_BUTTON && !p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
|
||||
|
||||
dragging=false;
|
||||
emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
|
||||
}
|
||||
|
||||
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
|
||||
|
||||
drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
|
||||
set_offset(drag_from+drag_accum);
|
||||
}
|
||||
|
||||
}
|
||||
@ -576,8 +584,6 @@ void GraphNode::_bind_methods() {
|
||||
}
|
||||
|
||||
GraphNode::GraphNode() {
|
||||
|
||||
dragging=false;
|
||||
show_close=false;
|
||||
connpos_dirty=true;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class GraphNode : public Container {
|
||||
Color color_right;
|
||||
|
||||
|
||||
Slot() { enable_left=false; type_left=0; color_left=Color(1,1,1,1); enable_right=false; type_right=0; color_right=Color(1,1,1,1); };
|
||||
Slot() { enable_left=false; type_left=0; color_left=Color(1,1,1,1); enable_right=false; type_right=0; color_right=Color(1,1,1,1); }
|
||||
};
|
||||
|
||||
String title;
|
||||
@ -46,8 +46,7 @@ class GraphNode : public Container {
|
||||
void _resort();
|
||||
|
||||
Vector2 drag_from;
|
||||
Vector2 drag_accum;
|
||||
bool dragging;
|
||||
bool selected;
|
||||
protected:
|
||||
|
||||
void _input_event(const InputEvent& p_ev);
|
||||
@ -79,6 +78,12 @@ public:
|
||||
void set_offset(const Vector2& p_offset);
|
||||
Vector2 get_offset() const;
|
||||
|
||||
void set_selected(bool p_selected);
|
||||
bool is_selected();
|
||||
|
||||
void set_drag(bool p_drag);
|
||||
Vector2 get_drag_from();
|
||||
|
||||
void set_show_close_button(bool p_enable);
|
||||
bool is_close_button_visible() const;
|
||||
|
||||
|
@ -556,10 +556,16 @@ void make_default_theme() {
|
||||
|
||||
// GraphNode
|
||||
|
||||
Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5);
|
||||
Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png,6,24,6,5,3,24,16,5);
|
||||
Ref<StyleBoxTexture> graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,3,24,16,5);
|
||||
Ref<StyleBoxTexture> graphsbdefault = make_stylebox(graph_node_default_png,4,4,4,4,6,4,4,4);
|
||||
Ref<StyleBoxTexture> graphsbdeffocus = make_stylebox(graph_node_default_focus_png,4,4,4,4,6,4,4,4);
|
||||
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
|
||||
//graphsb->set_expand_margin_size(MARGIN_RIGHT,10);
|
||||
t->set_stylebox("frame","GraphNode", graphsb );
|
||||
t->set_stylebox("selectedframe","GraphNode", graphsbselected );
|
||||
t->set_stylebox("defaultframe", "GraphNode", graphsbdefault );
|
||||
t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus );
|
||||
t->set_constant("separation","GraphNode", 1 );
|
||||
t->set_icon("port","GraphNode", make_icon( graph_port_png ) );
|
||||
t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) );
|
||||
|
BIN
scene/resources/default_theme/graph_node_default.png
Normal file
BIN
scene/resources/default_theme/graph_node_default.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 289 B |
BIN
scene/resources/default_theme/graph_node_default_focus.png
Normal file
BIN
scene/resources/default_theme/graph_node_default_focus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 408 B |
BIN
scene/resources/default_theme/graph_node_selected.png
Normal file
BIN
scene/resources/default_theme/graph_node_selected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 738 B |
@ -114,6 +114,21 @@ static const unsigned char graph_node_close_png[]={
|
||||
};
|
||||
|
||||
|
||||
static const unsigned char graph_node_default_png[]={
|
||||
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x8,0x1a,0x17,0x2e,0xd,0x4c,0xb7,0x38,0x4,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x0,0x85,0x49,0x44,0x41,0x54,0x38,0xcb,0xed,0x93,0x31,0xa,0x83,0x40,0x14,0x44,0xdf,0xba,0xa5,0x20,0x41,0x30,0x20,0x4,0xab,0x40,0x20,0x7,0xc9,0x69,0xec,0x72,0x4e,0x9b,0xa0,0x1e,0xc1,0x2a,0x42,0x10,0x82,0xbb,0xc5,0x77,0x6d,0x4c,0x11,0x48,0xe3,0xb7,0x49,0xe1,0x6b,0x6,0xa6,0x78,0xd5,0x8c,0x1,0x6e,0x80,0xe1,0x9b,0xb0,0xe4,0xaf,0xde,0x3,0x4f,0xa0,0x3,0x6,0x93,0x67,0xa7,0xc0,0xa,0x44,0x64,0x72,0x7e,0x6c,0x87,0xf7,0xab,0x4,0x1e,0x68,0x38,0x17,0x97,0x90,0xc4,0x87,0xa,0xb8,0xa2,0xe5,0x98,0xe6,0x1,0xb8,0x47,0x5a,0x81,0xb5,0x16,0xa0,0x56,0xb,0x3e,0xec,0x82,0x3f,0x10,0x4c,0x6a,0x81,0x88,0x78,0xc0,0x45,0xda,0x29,0x3b,0x3f,0x36,0x40,0xbf,0xf9,0x4c,0x66,0xeb,0x9d,0x67,0x5c,0x46,0x37,0x51,0xb6,0x55,0x6d,0xc2,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
|
||||
};
|
||||
|
||||
|
||||
static const unsigned char graph_node_default_focus_png[]={
|
||||
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x8,0x1b,0x1,0x9,0x1c,0x5c,0xd5,0x12,0x34,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x0,0xfc,0x49,0x44,0x41,0x54,0x38,0xcb,0xbd,0x93,0x41,0x4a,0x4,0x41,0xc,0x45,0x7f,0xca,0x6a,0x14,0x42,0x2f,0xc4,0x85,0x7,0xf0,0x3c,0xde,0xa2,0xbc,0x41,0xd7,0xa2,0xa1,0x60,0xea,0x60,0xae,0x5c,0xea,0x19,0xdc,0xd7,0x42,0x97,0xe5,0xc,0x12,0xeb,0xbb,0x69,0xa5,0x84,0xe9,0x41,0x1d,0xf1,0x43,0x8,0x84,0xe4,0x2d,0x92,0x1f,0xc1,0x22,0x92,0x2,0xc0,0x2d,0x81,0x2e,0x7f,0xa8,0x75,0xb9,0x89,0x8,0x1,0x40,0x48,0x5e,0x76,0xcd,0xad,0x6b,0x74,0x7b,0xea,0x6,0xe0,0x75,0x9,0x13,0x11,0xca,0x34,0x4d,0xc4,0x37,0x35,0xc,0xc3,0xf3,0x38,0x8e,0xb7,0xf3,0x3c,0xdf,0x0,0xd8,0x1,0x30,0x90,0x4,0x49,0xe4,0x9c,0x11,0x42,0x40,0x29,0x65,0x15,0x50,0x4a,0xb9,0x8,0x21,0x30,0xe7,0x7c,0x47,0x52,0x49,0x9e,0x7c,0x2,0x62,0x8c,0x30,0x33,0xa8,0xea,0x2a,0x40,0x55,0xaf,0xcc,0x4c,0x62,0x8c,0x5b,0x92,0xe7,0x24,0x7,0xd7,0x2d,0x11,0xde,0x7b,0xd4,0x5a,0x57,0x1,0xb5,0xd6,0x47,0xef,0x3d,0x49,0x9e,0x1,0xf0,0x0,0x9c,0xc3,0xef,0xe5,0xf6,0x9d,0xea,0x5f,0x1,0x38,0x16,0xd0,0xfe,0x16,0x20,0x22,0x7,0x3d,0xd0,0x7b,0x41,0x44,0xb6,0x8b,0x2b,0x9b,0xeb,0x6e,0x8c,0x94,0x12,0xcc,0x6c,0x75,0xd8,0xcc,0xc6,0x94,0xd2,0x93,0xaa,0xde,0x2f,0x76,0x6e,0x3f,0xb2,0xb2,0x88,0xec,0x54,0xf5,0x61,0xb3,0xd9,0x5c,0x3,0x78,0x1,0x60,0xc7,0x3c,0x53,0x13,0x91,0x37,0xe9,0x9d,0xd8,0xe9,0xf4,0xc0,0xe2,0xbe,0xbc,0xf3,0x3b,0x49,0xa0,0x89,0xbf,0x71,0xc6,0xcd,0x1c,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
|
||||
};
|
||||
|
||||
|
||||
static const unsigned char graph_node_selected_png[]={
|
||||
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x40,0x8,0x6,0x0,0x0,0x0,0x13,0x7d,0xf7,0x96,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x7,0x12,0x1,0xc,0x6,0x23,0x98,0xc7,0x50,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x2,0x46,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0x97,0xcd,0x6a,0x13,0x51,0x14,0xc7,0x7f,0xe7,0xce,0x34,0x49,0xd,0xa6,0xb1,0x2a,0xe2,0x7,0x74,0xa1,0x6e,0x4,0x85,0xe2,0x3,0xb8,0x72,0x21,0xba,0x16,0x5c,0xb9,0x16,0x4,0x7d,0x84,0x3e,0x82,0x82,0xe0,0xda,0x95,0x2f,0x60,0x71,0xe1,0xca,0x7,0xd0,0x82,0xa5,0x6e,0xd4,0x45,0xc1,0x8f,0x4a,0x6c,0x9a,0x46,0x62,0x66,0xa6,0x73,0xef,0x71,0xe1,0x4c,0x92,0x99,0x4c,0x93,0x36,0xdd,0xc9,0xfc,0x37,0x77,0x3e,0xee,0xfd,0xdd,0x73,0xfe,0xf7,0xc,0xcc,0x11,0x86,0x12,0xc0,0x0,0x5e,0x32,0xa,0x59,0x29,0xe0,0x0,0x9b,0x8c,0xca,0xc8,0x24,0x3,0x1c,0x3,0x16,0x81,0xd3,0x40,0x3,0x98,0xcb,0x1,0xf6,0x80,0x2e,0xd0,0x2,0xda,0xc0,0x1f,0xc0,0xa5,0xbb,0xd6,0x81,0x4b,0xb,0xc7,0x9b,0xf,0x6a,0xd5,0xda,0xad,0x4a,0xa5,0x7a,0x81,0x2,0x45,0x51,0xf8,0x35,0x8,0x83,0xd7,0xbb,0xbf,0x3b,0xcf,0x81,0xcf,0x40,0x4f,0x92,0x9d,0x96,0x16,0x9b,0x27,0x9f,0x5c,0x5c,0xba,0x7c,0xfb,0xfe,0xcb,0x3b,0x34,0x2b,0x27,0x8a,0xd6,0xd3,0x89,0x76,0x78,0x71,0xef,0x15,0x5f,0x36,0x3f,0xad,0xb6,0x3b,0xdb,0x8f,0x81,0x4d,0x1,0x6a,0xc0,0xf2,0xd9,0x33,0xe7,0xdf,0xac,0xbc,0x7d,0x54,0xdf,0x73,0x11,0x81,0xed,0x17,0x2,0x6a,0xde,0x3c,0x73,0xa6,0xc2,0xca,0x8d,0xa7,0xbd,0x1f,0x3f,0xbf,0xdd,0x4,0xd6,0xfc,0xc4,0x87,0xba,0xef,0xf9,0xf5,0x6e,0xb4,0xc3,0x24,0xf5,0xe3,0x1e,0x7d,0x7a,0xf8,0x9e,0x5f,0x4f,0xd2,0x96,0x14,0xe0,0x1,0x58,0xb5,0x39,0xdb,0x1d,0x82,0x19,0x5c,0xe7,0xe4,0xa5,0x0,0x4d,0x8f,0x44,0x71,0xa8,0x2a,0x22,0x92,0x81,0x4c,0x92,0x3f,0x7a,0xe3,0xd4,0xe2,0x54,0x41,0xc1,0x13,0xf,0xc5,0xe1,0x54,0x31,0x22,0x8,0xa6,0x10,0x96,0x1,0x58,0x1d,0x4e,0x88,0x35,0x1e,0x79,0x9e,0xd6,0xd0,0x94,0x8,0x54,0xb3,0x93,0x1c,0x8a,0x41,0x6,0x63,0xfa,0x6c,0x5f,0x40,0xe4,0xa2,0xcc,0x4b,0x23,0x32,0xd8,0x37,0x4e,0x52,0x99,0x1c,0x41,0x2e,0x4c,0x9b,0xdd,0x6c,0xec,0xbe,0x20,0x5,0xe5,0xb0,0xca,0x99,0x68,0x93,0x48,0x14,0x41,0x30,0x22,0x3,0x63,0x5,0x41,0x51,0x3c,0x31,0x93,0x8f,0x31,0xf3,0xed,0x6a,0xf6,0x5b,0xfe,0xe7,0x85,0x9b,0x0,0x98,0x52,0x34,0x7,0x2a,0xa4,0xb4,0x74,0x8b,0x4c,0x2d,0x2a,0xa6,0xb1,0x42,0x32,0x8c,0x1b,0x39,0x3c,0x7b,0x37,0xbd,0x90,0xec,0x51,0x52,0x88,0x5d,0x3c,0x36,0x21,0xd,0x39,0x4d,0x4d,0x72,0xc5,0x94,0x1,0xac,0xde,0x7d,0x3f,0xbb,0x89,0xf1,0x9e,0x65,0xf9,0xea,0xf5,0x3,0x2d,0x5a,0x5b,0x7f,0x57,0x1c,0xc1,0x6e,0xb7,0x73,0xe8,0x8,0xc,0x47,0x54,0x9,0x28,0x1,0x25,0xa0,0x4,0x94,0x80,0x12,0x50,0x2,0xfe,0x4b,0x80,0x14,0xf4,0x88,0x87,0x8e,0xc0,0xcd,0xb0,0xd6,0xa5,0x0,0x7,0x4,0xd6,0xda,0xb0,0xe0,0x27,0x6d,0x7c,0x55,0xc,0xd6,0xda,0x10,0x8,0x0,0x67,0x92,0x56,0x76,0x3b,0x8,0xfb,0x1b,0xad,0xf6,0x16,0x93,0x20,0x2e,0x86,0x56,0x7b,0x8b,0x20,0xec,0x6f,0x0,0xdb,0x80,0x4d,0x3b,0xd7,0x5,0xe0,0x5a,0xa3,0xde,0x7c,0x56,0xab,0xce,0x5f,0xf1,0x3c,0xaf,0xd0,0x5c,0x6b,0xad,0xb,0xc2,0xfe,0xc7,0x6e,0xaf,0xf3,0x10,0xf8,0x0,0xec,0xca,0x48,0xb,0xd7,0x0,0xce,0x1,0xa7,0x80,0xea,0x3e,0xcd,0x77,0x8,0xfc,0x2,0xbe,0x27,0x7d,0xb4,0x95,0x9c,0xa1,0x7e,0xda,0xf,0xee,0x93,0x85,0x26,0x29,0xc7,0x33,0x1a,0x3f,0xae,0xbf,0xf0,0x27,0xf6,0x42,0xf6,0xf5,0xfd,0xae,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
|
||||
};
|
||||
|
||||
|
||||
static const unsigned char graph_port_png[]={
|
||||
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x8,0x6,0x0,0x0,0x0,0x8d,0x32,0xcf,0xbd,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0x0,0x0,0x0,0x0,0x0,0xf9,0x43,0xbb,0x7f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xde,0xc,0x14,0x17,0x20,0x3,0xeb,0x8f,0x3a,0xdb,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x1,0x65,0x49,0x44,0x41,0x54,0x18,0xd3,0x4d,0xd0,0x4f,0x6b,0xda,0x70,0x1c,0x7,0xe0,0xcf,0x37,0x7f,0x7e,0x49,0x66,0xd2,0x64,0x61,0x5,0x61,0x76,0x47,0xf1,0xa4,0x2d,0xdb,0x75,0x5,0x11,0x84,0xb0,0x5e,0xeb,0xd9,0xeb,0xf4,0x6d,0xec,0x2d,0xf8,0x26,0xb6,0x77,0xe0,0x45,0xba,0xa3,0x6c,0xa0,0x3b,0xad,0x39,0xb6,0x36,0x8,0x1b,0x4b,0x32,0xd2,0xc6,0x6c,0x9a,0x4f,0x4f,0x85,0x3e,0x2f,0xe1,0x11,0x0,0x20,0x29,0xd3,0xe9,0xd4,0xda,0x6e,0xb7,0x23,0xdf,0xf7,0xbb,0x0,0x90,0xe7,0xf9,0x8f,0x66,0xb3,0xf9,0x79,0x36,0x9b,0x55,0x22,0x42,0x83,0xa4,0x44,0x51,0xf4,0xea,0xe2,0xe2,0xc3,0xf7,0xf1,0x78,0xdc,0xa,0x82,0x40,0x8,0x20,0xcf,0x32,0x2e,0x97,0xcb,0x4f,0x51,0x14,0xbd,0x25,0xf9,0x5b,0x26,0x93,0x89,0xdd,0xe9,0x74,0xe2,0xf7,0xe7,0xe7,0x27,0x59,0xfa,0x87,0x65,0xb9,0x13,0x0,0xb0,0x1d,0x9b,0xe1,0xcb,0x50,0xbe,0x5e,0x5d,0xdd,0xfe,0xbc,0xbe,0x6e,0x6b,0x49,0x92,0x8c,0x4e,0x7b,0xa7,0xad,0xbf,0x79,0x4e,0xd3,0x54,0x12,0x86,0x21,0xc2,0x30,0x84,0x32,0x95,0xe4,0x79,0xc6,0xde,0xd9,0x59,0x2b,0x49,0xee,0x46,0x86,0xeb,0xba,0x5d,0xfb,0x85,0x23,0x87,0xfd,0x1e,0xb6,0xed,0x40,0xd7,0x35,0x0,0x40,0x7d,0x38,0xa0,0xdc,0xed,0x44,0x37,0x74,0xb8,0xae,0xd7,0x35,0x48,0x62,0xff,0xff,0x1f,0xfc,0x20,0x80,0xae,0xe9,0x78,0x42,0x0,0xca,0xb2,0x90,0x65,0x19,0x58,0xd7,0xd0,0x8a,0xa2,0x58,0xa7,0x69,0x56,0x6b,0xa2,0x51,0x29,0x5,0xcb,0x52,0xb0,0x94,0x5,0x4b,0x29,0x88,0x8,0xd3,0x34,0xad,0x8b,0xfb,0x62,0xad,0xf,0x6,0x83,0xb8,0xaa,0xaa,0xb1,0xe7,0x79,0xbe,0x77,0x74,0x44,0xb7,0xe1,0x89,0x69,0x1a,0x28,0xcb,0x92,0x9b,0xcd,0x46,0x56,0xab,0xd5,0x86,0xe4,0x47,0x21,0x29,0xc3,0xe1,0xf0,0xb8,0xdf,0xef,0x7f,0x6b,0xb7,0xdb,0xaf,0x1b,0x8d,0x86,0x46,0x10,0xf,0xf7,0xf,0x75,0x1c,0xc7,0x77,0x8b,0xc5,0xe2,0xdd,0x7c,0x3e,0xff,0x25,0xcf,0xc3,0x6f,0x6e,0x6f,0x2e,0x1d,0xdb,0xe9,0x9,0x80,0xb2,0x2a,0xd7,0x27,0xad,0x37,0x5f,0x9e,0xc2,0x1f,0x1,0x3a,0xe6,0xa5,0x7b,0xef,0xf2,0xf3,0xcd,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
|
||||
};
|
||||
|
@ -80,13 +80,16 @@ void ShaderGraph::_set_data(const Dictionary &p_data) {
|
||||
ERR_FAIL_COND((conns.size()%3)!=0);
|
||||
|
||||
for(int j=0;j<conns.size();j+=3) {
|
||||
|
||||
SourceSlot ss;
|
||||
int ls=conns[j+0];
|
||||
if (ls == SLOT_DEFAULT_VALUE) {
|
||||
n.defaults[conns[j+1]]=conns[j+2];
|
||||
} else {
|
||||
ss.id=conns[j+1];
|
||||
ss.slot=conns[j+2];
|
||||
n.connections[ls]=ss;
|
||||
}
|
||||
}
|
||||
shader[t].node_map[n.id]=n;
|
||||
|
||||
}
|
||||
@ -114,7 +117,7 @@ Dictionary ShaderGraph::_get_data() const {
|
||||
data[idx+4]=E->get().param2;
|
||||
|
||||
Array conns;
|
||||
conns.resize(E->get().connections.size()*3);
|
||||
conns.resize(E->get().connections.size()*3+E->get().defaults.size()*3);
|
||||
int idx2=0;
|
||||
for(Map<int,SourceSlot>::Element*F=E->get().connections.front();F;F=F->next()) {
|
||||
|
||||
@ -123,6 +126,14 @@ Dictionary ShaderGraph::_get_data() const {
|
||||
conns[idx2+2]=F->get().slot;
|
||||
idx2+=3;
|
||||
}
|
||||
for(Map<int,Variant>::Element*F=E->get().defaults.front();F;F=F->next()) {
|
||||
|
||||
conns[idx2+0]=SLOT_DEFAULT_VALUE;
|
||||
conns[idx2+1]=F->key();
|
||||
conns[idx2+2]=F->get();
|
||||
idx2+=3;
|
||||
}
|
||||
|
||||
data[idx+5]=conns;
|
||||
idx+=6;
|
||||
}
|
||||
@ -142,6 +153,15 @@ ShaderGraph::GraphError ShaderGraph::get_graph_error(ShaderType p_type) const {
|
||||
return shader[p_type].error;
|
||||
}
|
||||
|
||||
int ShaderGraph::node_count(ShaderType p_which, int p_type)
|
||||
{
|
||||
int count=0;
|
||||
for (Map<int,Node>::Element *E=shader[p_which].node_map.front();E;E=E->next())
|
||||
if (E->get().type==p_type)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
void ShaderGraph::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
|
||||
@ -155,6 +175,9 @@ void ShaderGraph::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_node_list","shader_type"),&ShaderGraph::_get_node_list);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value);
|
||||
ObjectTypeDB::bind_method(_MD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value);
|
||||
ObjectTypeDB::bind_method(_MD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_set_value);
|
||||
|
||||
@ -683,6 +706,18 @@ void ShaderGraph::get_node_connections(ShaderType p_type,List<Connection> *p_con
|
||||
}
|
||||
}
|
||||
|
||||
bool ShaderGraph::is_slot_connected(ShaderGraph::ShaderType p_type, int p_dst_id, int slot_id)
|
||||
{
|
||||
for(const Map<int,Node>::Element *E=shader[p_type].node_map.front();E;E=E->next()) {
|
||||
for (const Map<int,SourceSlot>::Element *F=E->get().connections.front();F;F=F->next()) {
|
||||
|
||||
if (p_dst_id == E->key() && slot_id==F->key())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ShaderGraph::clear(ShaderType p_type) {
|
||||
|
||||
@ -824,6 +859,47 @@ float ShaderGraph::texture_node_get_filter_strength(ShaderType p_type,float p_id
|
||||
return arr[1];
|
||||
}
|
||||
|
||||
void ShaderGraph::duplicate_nodes(ShaderType p_which, List<int> &p_nodes)
|
||||
{
|
||||
//Create new node IDs
|
||||
Map<int,int> duplicates = Map<int,int>();
|
||||
int i=1;
|
||||
for(List<int>::Element *E=p_nodes.front();E; E=E->next()) {
|
||||
while (shader[p_which].node_map.has(i))
|
||||
i++;
|
||||
duplicates.insert(E->get(), i);
|
||||
i++;
|
||||
}
|
||||
|
||||
for(List<int>::Element *E = p_nodes.front();E; E=E->next()) {
|
||||
|
||||
const Node &n=shader[p_which].node_map[E->get()];
|
||||
Node nn=n;
|
||||
nn.id=duplicates.find(n.id)->get();
|
||||
nn.pos += Vector2(0,100);
|
||||
for (Map<int,SourceSlot>::Element *C=nn.connections.front();C;C=C->next()) {
|
||||
SourceSlot &c=C->get();
|
||||
if (p_nodes.find(c.id))
|
||||
c.id=duplicates.find(c.id)->get();
|
||||
}
|
||||
shader[p_which].node_map[nn.id]=nn;
|
||||
}
|
||||
_request_update();
|
||||
}
|
||||
|
||||
List<int> ShaderGraph::generate_ids(ShaderType p_type, int count)
|
||||
{
|
||||
List<int> ids = List<int>();
|
||||
int i=1;
|
||||
while (ids.size() < count) {
|
||||
while (shader[p_type].node_map.has(i))
|
||||
i++;
|
||||
ids.push_back(i);
|
||||
i++;
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
void ShaderGraph::scalar_op_node_set_op(ShaderType p_type,float p_id,ScalarOp p_op){
|
||||
|
||||
@ -955,6 +1031,33 @@ ShaderGraph::ScalarFunc ShaderGraph::scalar_func_node_get_function(ShaderType p_
|
||||
return ScalarFunc(func);
|
||||
}
|
||||
|
||||
void ShaderGraph::default_set_value(ShaderGraph::ShaderType p_which, int p_id, int p_param, const Variant &p_value)
|
||||
{
|
||||
ERR_FAIL_INDEX(p_which,3);
|
||||
ERR_FAIL_COND(!shader[p_which].node_map.has(p_id));
|
||||
Node& n = shader[p_which].node_map[p_id];
|
||||
if(p_value.get_type()==Variant::NIL)
|
||||
n.defaults.erase(n.defaults.find(p_param));
|
||||
else
|
||||
n.defaults[p_param]=p_value;
|
||||
|
||||
_request_update();
|
||||
|
||||
}
|
||||
|
||||
Variant ShaderGraph::default_get_value(ShaderGraph::ShaderType p_which, int p_id, int p_param)
|
||||
{
|
||||
ERR_FAIL_INDEX_V(p_which,3,Variant());
|
||||
ERR_FAIL_COND_V(!shader[p_which].node_map.has(p_id),Variant());
|
||||
const Node& n = shader[p_which].node_map[p_id];
|
||||
|
||||
if (!n.defaults.has(p_param))
|
||||
return Variant();
|
||||
return n.defaults[p_param];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShaderGraph::vec_func_node_set_function(ShaderType p_type,int p_id,VecFunc p_func){
|
||||
|
||||
ERR_FAIL_INDEX(p_type,3);
|
||||
@ -1215,6 +1318,12 @@ Variant ShaderGraph::node_get_state(ShaderType p_type,int p_id) const {
|
||||
s["pos"]=n.pos;
|
||||
s["param1"]=n.param1;
|
||||
s["param2"]=n.param2;
|
||||
Array keys;
|
||||
for (Map<int,Variant>::Element *E=n.defaults.front();E;E=E->next()) {
|
||||
keys.append(E->key());
|
||||
s[E->key()]=E->get();
|
||||
}
|
||||
s["default_keys"]=keys;
|
||||
return s;
|
||||
|
||||
}
|
||||
@ -1227,10 +1336,15 @@ void ShaderGraph::node_set_state(ShaderType p_type,int p_id,const Variant& p_sta
|
||||
ERR_FAIL_COND(!d.has("pos"));
|
||||
ERR_FAIL_COND(!d.has("param1"));
|
||||
ERR_FAIL_COND(!d.has("param2"));
|
||||
ERR_FAIL_COND(!d.has("default_keys"));
|
||||
|
||||
n.pos=d["pos"];
|
||||
n.param1=d["param1"];
|
||||
n.param2=d["param2"];
|
||||
|
||||
Array keys = d["default_keys"];
|
||||
for(int i=0;i<keys.size();i++) {
|
||||
n.defaults[keys[i]]=d[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
ShaderGraph::ShaderGraph(Mode p_mode) : Shader(p_mode) {
|
||||
@ -1735,18 +1849,18 @@ void ShaderGraph::_update_shader() {
|
||||
Vector<String> inputs;
|
||||
int max = get_node_input_slot_count(get_mode(),ShaderType(i),n->type);
|
||||
for(int k=0;k<max;k++) {
|
||||
String iname;
|
||||
if (!n->connections.has(k)) {
|
||||
shader[i].error=GRAPH_ERROR_MISSING_CONNECTIONS;
|
||||
failed=true;
|
||||
break;
|
||||
}
|
||||
String iname="nd"+itos(n->connections[k].id)+"sl"+itos(n->connections[k].slot);
|
||||
inputs.push_back(iname);
|
||||
iname="nd"+itos(n->id)+"sl"+itos(k)+"def";
|
||||
} else {
|
||||
iname="nd"+itos(n->connections[k].id)+"sl"+itos(n->connections[k].slot);
|
||||
if (node_get_type(ShaderType(i),n->connections[k].id)==NODE_INPUT) {
|
||||
inputs_used.insert(iname);
|
||||
}
|
||||
|
||||
}
|
||||
inputs.push_back(iname);
|
||||
}
|
||||
|
||||
if (failed)
|
||||
break;
|
||||
@ -1951,6 +2065,31 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
const char *typestr[4]={"float","vec3","mat4","texture"};
|
||||
#define OUTNAME(id,slot) (String(typestr[get_node_output_slot_type(get_mode(),p_type,p_node->type,slot)])+" "+("nd"+itos(id)+"sl"+itos(slot)))
|
||||
#define OUTVAR(id,slot) ("nd"+itos(id)+"sl"+itos(slot))
|
||||
#define DEF_VEC(slot)\
|
||||
if (p_inputs[slot].ends_with("def")){\
|
||||
Vector3 v = p_node->defaults[slot];\
|
||||
code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+v+");\n";\
|
||||
}
|
||||
#define DEF_SCALAR(slot)\
|
||||
if (p_inputs[slot].ends_with("def")){\
|
||||
double v = p_node->defaults[slot];\
|
||||
code+=String(typestr[0])+" "+p_inputs[slot]+"="+rtos(v)+";\n";\
|
||||
}
|
||||
#define DEF_COLOR(slot)\
|
||||
if (p_inputs[slot].ends_with("def")){\
|
||||
Color col = p_node->defaults[slot];\
|
||||
code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+rtos(col.r)+","+rtos(col.g)+","+rtos(col.b)+");\n";\
|
||||
}
|
||||
#define DEF_MATRIX(slot) \
|
||||
if (p_inputs[slot].ends_with("def")){\
|
||||
Transform xf = p_node->defaults[slot]; \
|
||||
code+=String(typestr[3])+" "+p_inputs[slot]+"=mat4(\n";\
|
||||
code+="\tvec4(vec3("+rtos(xf.basis.get_axis(0).x)+","+rtos(xf.basis.get_axis(0).y)+","+rtos(xf.basis.get_axis(0).z)+"),0),\n";\
|
||||
code+="\tvec4(vec3("+rtos(xf.basis.get_axis(1).x)+","+rtos(xf.basis.get_axis(1).y)+","+rtos(xf.basis.get_axis(1).z)+"),0),\n";\
|
||||
code+="\tvec4(vec3("+rtos(xf.basis.get_axis(2).x)+","+rtos(xf.basis.get_axis(2).y)+","+rtos(xf.basis.get_axis(2).z)+"),0),\n";\
|
||||
code+="\tvec4(vec3("+rtos(xf.origin.x)+","+rtos(xf.origin.y)+","+rtos(xf.origin.z)+"),1)\n";\
|
||||
code+=");\n";\
|
||||
}
|
||||
|
||||
switch(p_node->type) {
|
||||
|
||||
@ -1987,9 +2126,12 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
code+=OUTNAME(p_node->id,0)+"=TIME;\n";
|
||||
}break;
|
||||
case NODE_SCREEN_TEX: {
|
||||
DEF_VEC(0);
|
||||
code+=OUTNAME(p_node->id,0)+"=texscreen("+p_inputs[0]+".xy);\n";
|
||||
}break;
|
||||
case NODE_SCALAR_OP: {
|
||||
DEF_SCALAR(0);
|
||||
DEF_SCALAR(1);
|
||||
int op = p_node->param1;
|
||||
String optxt;
|
||||
switch(op) {
|
||||
@ -2009,6 +2151,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_VEC_OP: {
|
||||
DEF_VEC(0);
|
||||
DEF_VEC(1);
|
||||
int op = p_node->param1;
|
||||
String optxt;
|
||||
switch(op) {
|
||||
@ -2026,6 +2170,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_VEC_SCALAR_OP: {
|
||||
DEF_VEC(0);
|
||||
DEF_SCALAR(1);
|
||||
int op = p_node->param1;
|
||||
String optxt;
|
||||
switch(op) {
|
||||
@ -2037,6 +2183,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_RGB_OP: {
|
||||
DEF_COLOR(0);
|
||||
DEF_COLOR(1);
|
||||
|
||||
int op = p_node->param1;
|
||||
static const char*axisn[3]={"x","y","z"};
|
||||
@ -2048,7 +2196,6 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
case RGB_OP_DIFFERENCE: {
|
||||
|
||||
code += OUTNAME(p_node->id,0)+"=abs("+p_inputs[0]+"-"+p_inputs[1]+");\n";
|
||||
|
||||
} break;
|
||||
case RGB_OP_DARKEN: {
|
||||
|
||||
@ -2119,11 +2266,15 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
}
|
||||
}break;
|
||||
case NODE_XFORM_MULT: {
|
||||
DEF_MATRIX(0);
|
||||
DEF_MATRIX(1);
|
||||
|
||||
code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+"*"+p_inputs[1]+";\n";
|
||||
|
||||
}break;
|
||||
case NODE_XFORM_VEC_MULT: {
|
||||
DEF_MATRIX(0);
|
||||
DEF_VEC(1);
|
||||
|
||||
bool no_translation = p_node->param1;
|
||||
if (no_translation) {
|
||||
@ -2134,6 +2285,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_XFORM_VEC_INV_MULT: {
|
||||
DEF_VEC(0);
|
||||
DEF_MATRIX(1);
|
||||
bool no_translation = p_node->param1;
|
||||
if (no_translation) {
|
||||
code += OUTNAME(p_node->id,0)+"=("+p_inputs[1]+"*vec4("+p_inputs[0]+",0)).xyz;\n";
|
||||
@ -2142,6 +2295,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
}
|
||||
}break;
|
||||
case NODE_SCALAR_FUNC: {
|
||||
DEF_SCALAR(0);
|
||||
static const char*scalar_func_id[SCALAR_MAX_FUNC]={
|
||||
"sin($)",
|
||||
"cos($)",
|
||||
@ -2171,6 +2325,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
} break;
|
||||
case NODE_VEC_FUNC: {
|
||||
DEF_VEC(0);
|
||||
static const char*vec_func_id[VEC_MAX_FUNC]={
|
||||
"normalize($)",
|
||||
"max(min($,vec3(1,1,1)),vec3(0,0,0))",
|
||||
@ -2208,44 +2363,63 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
}
|
||||
}break;
|
||||
case NODE_VEC_LEN: {
|
||||
DEF_VEC(0);
|
||||
|
||||
code += OUTNAME(p_node->id,0)+"=length("+p_inputs[0]+");\n";
|
||||
|
||||
}break;
|
||||
case NODE_DOT_PROD: {
|
||||
DEF_VEC(0);
|
||||
DEF_VEC(1);
|
||||
code += OUTNAME(p_node->id,0)+"=dot("+p_inputs[1]+","+p_inputs[0]+");\n";
|
||||
|
||||
}break;
|
||||
case NODE_VEC_TO_SCALAR: {
|
||||
DEF_VEC(0);
|
||||
code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+".x;\n";
|
||||
code += OUTNAME(p_node->id,1)+"="+p_inputs[0]+".y;\n";
|
||||
code += OUTNAME(p_node->id,2)+"="+p_inputs[0]+".z;\n";
|
||||
|
||||
}break;
|
||||
case NODE_SCALAR_TO_VEC: {
|
||||
DEF_SCALAR(0);
|
||||
DEF_SCALAR(1);
|
||||
DEF_SCALAR(2);
|
||||
code += OUTNAME(p_node->id,0)+"=vec3("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+""+");\n";
|
||||
|
||||
}break;
|
||||
case NODE_VEC_TO_XFORM: {
|
||||
DEF_VEC(0);
|
||||
DEF_VEC(1);
|
||||
DEF_VEC(2);
|
||||
DEF_VEC(3);
|
||||
code += OUTNAME(p_node->id,0)+"=xform("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+","+","+p_inputs[3]+");\n";
|
||||
|
||||
}break;
|
||||
case NODE_XFORM_TO_VEC: {
|
||||
DEF_MATRIX(0);
|
||||
code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+".x;\n";
|
||||
code += OUTNAME(p_node->id,1)+"="+p_inputs[0]+".y;\n";
|
||||
code += OUTNAME(p_node->id,2)+"="+p_inputs[0]+".z;\n";
|
||||
code += OUTNAME(p_node->id,3)+"="+p_inputs[0]+".o;\n";
|
||||
}break;
|
||||
case NODE_SCALAR_INTERP: {
|
||||
DEF_SCALAR(0);
|
||||
DEF_SCALAR(1);
|
||||
DEF_SCALAR(2);
|
||||
|
||||
code += OUTNAME(p_node->id,0)+"=mix("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+");\n";
|
||||
|
||||
}break;
|
||||
case NODE_VEC_INTERP: {
|
||||
DEF_VEC(0);
|
||||
DEF_VEC(1);
|
||||
DEF_SCALAR(2);
|
||||
code += OUTNAME(p_node->id,0)+"=mix("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+");\n";
|
||||
|
||||
}break;
|
||||
case NODE_COLOR_RAMP: {
|
||||
DEF_SCALAR(0);
|
||||
|
||||
static const int color_ramp_len=512;
|
||||
DVector<uint8_t> cramp;
|
||||
@ -2302,6 +2476,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_CURVE_MAP: {
|
||||
DEF_SCALAR(0);
|
||||
static const int curve_map_len=256;
|
||||
bool mapped[256];
|
||||
zeromem(mapped,sizeof(mapped));
|
||||
@ -2406,6 +2581,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_TEXTURE_INPUT: {
|
||||
DEF_VEC(0);
|
||||
String name = p_node->param1;
|
||||
String rname="rt_read_tex"+itos(p_node->id);
|
||||
code +="uniform texture "+name+";";
|
||||
@ -2415,7 +2591,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}break;
|
||||
case NODE_CUBEMAP_INPUT: {
|
||||
|
||||
DEF_VEC(0);
|
||||
String name = p_node->param1;
|
||||
code +="uniform cubemap "+name+";";
|
||||
String rname="rt_read_tex"+itos(p_node->id);
|
||||
@ -2424,6 +2600,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
code += OUTNAME(p_node->id,1)+"="+rname+".a;\n";
|
||||
}break;
|
||||
case NODE_DEFAULT_TEXTURE: {
|
||||
DEF_VEC(0);
|
||||
|
||||
if (get_mode()==MODE_CANVAS_ITEM && p_type==SHADER_TYPE_FRAGMENT) {
|
||||
|
||||
@ -2450,4 +2627,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
|
||||
|
||||
}
|
||||
}
|
||||
#undef DEF_SCALAR
|
||||
#undef DEF_COLOR
|
||||
#undef DEF_MATRIX
|
||||
#undef DEF_VEC
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ private:
|
||||
|
||||
String _find_unique_name(const String& p_base);
|
||||
|
||||
enum {SLOT_DEFAULT_VALUE = 0x7FFFFFFF};
|
||||
struct SourceSlot {
|
||||
|
||||
int id;
|
||||
@ -135,6 +136,7 @@ private:
|
||||
NodeType type;
|
||||
Variant param1;
|
||||
Variant param2;
|
||||
Map<int, Variant> defaults;
|
||||
int id;
|
||||
mutable int order; // used for sorting
|
||||
int sort_order;
|
||||
@ -216,6 +218,10 @@ public:
|
||||
void texture_node_set_filter_strength(ShaderType p_which,float p_id,float p_strength);
|
||||
float texture_node_get_filter_strength(ShaderType p_which,float p_id) const;
|
||||
|
||||
void duplicate_nodes(ShaderType p_which, List<int> &p_nodes);
|
||||
|
||||
List<int> generate_ids(ShaderType p_type, int count);
|
||||
|
||||
enum ScalarOp {
|
||||
SCALAR_OP_ADD,
|
||||
SCALAR_OP_SUB,
|
||||
@ -314,6 +320,9 @@ public:
|
||||
VEC_MAX_FUNC
|
||||
};
|
||||
|
||||
void default_set_value(ShaderType p_which,int p_id,int p_param, const Variant& p_value);
|
||||
Variant default_get_value(ShaderType p_which,int p_id,int p_param);
|
||||
|
||||
void vec_func_node_set_function(ShaderType p_which,int p_id,VecFunc p_func);
|
||||
VecFunc vec_func_node_get_function(ShaderType p_which,int p_id) const;
|
||||
|
||||
@ -354,6 +363,8 @@ public:
|
||||
|
||||
void get_node_connections(ShaderType p_which,List<Connection> *p_connections) const;
|
||||
|
||||
bool is_slot_connected(ShaderType p_which,int p_dst_id,int slot_id);
|
||||
|
||||
void clear(ShaderType p_which);
|
||||
|
||||
Variant node_get_state(ShaderType p_type, int p_node) const;
|
||||
@ -361,6 +372,8 @@ public:
|
||||
|
||||
GraphError get_graph_error(ShaderType p_type) const;
|
||||
|
||||
int node_count(ShaderType p_which, int p_type);
|
||||
|
||||
static int get_type_input_count(NodeType p_type);
|
||||
static int get_type_output_count(NodeType p_type);
|
||||
static SlotType get_type_input_type(NodeType p_type,int p_idx);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "shader_graph_editor_plugin.h"
|
||||
|
||||
|
||||
#include "scene/gui/check_box.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/panel.h"
|
||||
#include "spatial_editor_plugin.h"
|
||||
@ -509,7 +510,7 @@ void GraphCurveMapEdit::_plot_curve(const Vector2& p_a,const Vector2& p_b,const
|
||||
lastx = CLAMP (x, 0, xmax);
|
||||
lasty = CLAMP (y, 0, ymax);
|
||||
|
||||
/* if (fix255)
|
||||
/* if (fix255)
|
||||
{
|
||||
cd->curve[cd->outline][lastx] = lasty;
|
||||
}
|
||||
@ -608,7 +609,7 @@ void GraphCurveMapEdit::_notification(int p_what){
|
||||
draw_rect(Rect2( Vector2(points[i].offset,1.0-points[i].height)*get_size()-Vector2(2,2),Vector2(5,5)),col);
|
||||
}
|
||||
|
||||
/* if (grabbed!=-1) {
|
||||
/* if (grabbed!=-1) {
|
||||
|
||||
draw_rect(Rect2(total_w+3,0,h,h),points[grabbed].color);
|
||||
}
|
||||
@ -840,6 +841,7 @@ void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){
|
||||
ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height));
|
||||
ped_popup->set_size(tb->get_size());
|
||||
edited_id=p_id;
|
||||
edited_def=-1;
|
||||
ped_popup->edit(NULL,"",Variant::TRANSFORM,graph->xform_input_node_get_value(type,p_id),PROPERTY_HINT_NONE,"");
|
||||
ped_popup->popup();
|
||||
|
||||
@ -850,6 +852,7 @@ void ShaderGraphView::_xform_const_changed(int p_id, Node *p_button){
|
||||
ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height));
|
||||
ped_popup->set_size(tb->get_size());
|
||||
edited_id=p_id;
|
||||
edited_def=-1;
|
||||
ped_popup->edit(NULL,"",Variant::TRANSFORM,graph->xform_const_node_get_value(type,p_id),PROPERTY_HINT_NONE,"");
|
||||
ped_popup->popup();
|
||||
|
||||
@ -879,6 +882,35 @@ void ShaderGraphView::_cube_input_change(int p_id){
|
||||
|
||||
void ShaderGraphView::_variant_edited() {
|
||||
|
||||
if (edited_def != -1) {
|
||||
|
||||
Variant v = ped_popup->get_variant();
|
||||
Variant v2 = graph->default_get_value(type,edited_id,edited_def);
|
||||
if (v2.get_type() == Variant::NIL)
|
||||
switch (v.get_type()) {
|
||||
case Variant::VECTOR3:
|
||||
v2=Vector3();
|
||||
break;
|
||||
case Variant::REAL:
|
||||
v2=0.0;
|
||||
break;
|
||||
case Variant::TRANSFORM:
|
||||
v2=Transform();
|
||||
break;
|
||||
case Variant::COLOR:
|
||||
v2=Color();
|
||||
break;
|
||||
}
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
ur->create_action("Change default value");
|
||||
ur->add_do_method(graph.ptr(),"default_set_value",type,edited_id,edited_def, v);
|
||||
ur->add_undo_method(graph.ptr(),"default_set_value",type,edited_id,edited_def, v2);
|
||||
ur->add_do_method(this,"_update_graph");
|
||||
ur->add_undo_method(this,"_update_graph");
|
||||
ur->commit_action();
|
||||
return;
|
||||
}
|
||||
|
||||
if (graph->node_get_type(type,edited_id)==ShaderGraph::NODE_XFORM_CONST) {
|
||||
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
@ -1043,6 +1075,7 @@ void ShaderGraphView::_tex_edited(int p_id,Node* p_button) {
|
||||
ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height));
|
||||
ped_popup->set_size(tb->get_size());
|
||||
edited_id=p_id;
|
||||
edited_def=-1;
|
||||
ped_popup->edit(NULL,"",Variant::OBJECT,graph->texture_input_node_get_value(type,p_id),PROPERTY_HINT_RESOURCE_TYPE,"Texture");
|
||||
}
|
||||
|
||||
@ -1052,6 +1085,7 @@ void ShaderGraphView::_cube_edited(int p_id,Node* p_button) {
|
||||
ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height));
|
||||
ped_popup->set_size(tb->get_size());
|
||||
edited_id=p_id;
|
||||
edited_def=-1;
|
||||
ped_popup->edit(NULL,"",Variant::OBJECT,graph->cubemap_input_node_get_value(type,p_id),PROPERTY_HINT_RESOURCE_TYPE,"CubeMap");
|
||||
}
|
||||
|
||||
@ -1156,14 +1190,24 @@ void ShaderGraphView::_node_removed(int p_id) {
|
||||
|
||||
}
|
||||
|
||||
void ShaderGraphView::_begin_node_move()
|
||||
{
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
ur->create_action("Move Shader Graph Node");
|
||||
}
|
||||
|
||||
void ShaderGraphView::_node_moved(const Vector2& p_from, const Vector2& p_to,int p_id) {
|
||||
|
||||
|
||||
ERR_FAIL_COND(!node_map.has(p_id));
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
ur->create_action("Move Shader Graph Node");
|
||||
ur->add_do_method(this,"_move_node",p_id,p_to);
|
||||
ur->add_undo_method(this,"_move_node",p_id,p_from);
|
||||
}
|
||||
|
||||
void ShaderGraphView::_end_node_move()
|
||||
{
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
ur->commit_action();
|
||||
}
|
||||
|
||||
@ -1174,6 +1218,173 @@ void ShaderGraphView::_move_node(int p_id,const Vector2& p_to) {
|
||||
graph->node_set_pos(type,p_id,p_to);
|
||||
}
|
||||
|
||||
void ShaderGraphView::_duplicate_nodes_request()
|
||||
{
|
||||
Array s_id;
|
||||
|
||||
for(Map<int,GraphNode*>::Element *E=node_map.front();E;E=E->next()) {
|
||||
ShaderGraph::NodeType t=graph->node_get_type(type, E->key());
|
||||
if (t==ShaderGraph::NODE_OUTPUT || t==ShaderGraph::NODE_INPUT)
|
||||
continue;
|
||||
GraphNode *gn = E->get();
|
||||
if (gn && gn->is_selected())
|
||||
s_id.push_back(E->key());
|
||||
}
|
||||
|
||||
if (s_id.size()==0)
|
||||
return;
|
||||
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
ur->create_action("Duplicate Graph Node(s)");
|
||||
ur->add_do_method(this,"_duplicate_nodes",s_id);
|
||||
List<int> n_ids = graph->generate_ids(type, s_id.size());
|
||||
for (List<int>::Element *E=n_ids.front();E;E=E->next())
|
||||
ur->add_undo_method(graph.ptr(),"node_remove",type,E->get());
|
||||
ur->add_do_method(this,"_update_graph");
|
||||
ur->add_undo_method(this,"_update_graph");
|
||||
ur->commit_action();
|
||||
|
||||
}
|
||||
|
||||
void ShaderGraphView::_duplicate_nodes(Array &p_nodes)
|
||||
{
|
||||
List<int> n = List<int>();
|
||||
for (int i=0; i<p_nodes.size();i++)
|
||||
n.push_back(p_nodes.get(i));
|
||||
graph->duplicate_nodes(type, n);
|
||||
call_deferred("_update_graph");
|
||||
}
|
||||
|
||||
void ShaderGraphView::_delete_nodes_request()
|
||||
{
|
||||
List<int> s_id=List<int>();
|
||||
|
||||
for(Map<int,GraphNode*>::Element *E=node_map.front();E;E=E->next()) {
|
||||
ShaderGraph::NodeType t=graph->node_get_type(type, E->key());
|
||||
if (t==ShaderGraph::NODE_OUTPUT)
|
||||
continue;
|
||||
GraphNode *gn = E->get();
|
||||
if (gn && gn->is_selected())
|
||||
s_id.push_back(E->key());
|
||||
}
|
||||
|
||||
if (s_id.size()==0)
|
||||
return;
|
||||
|
||||
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
|
||||
ur->create_action("Delete Shader Graph Node(s)");
|
||||
|
||||
for (List<int>::Element *N=s_id.front();N;N=N->next()) {
|
||||
ur->add_do_method(graph.ptr(),"node_remove",type,N->get());
|
||||
ur->add_undo_method(graph.ptr(),"node_add",type,graph->node_get_type(type,N->get()),N->get());
|
||||
ur->add_undo_method(graph.ptr(),"node_set_state",type,N->get(),graph->node_get_state(type,N->get()));
|
||||
List<ShaderGraph::Connection> conns;
|
||||
|
||||
graph->get_node_connections(type,&conns);
|
||||
for(List<ShaderGraph::Connection>::Element *E=conns.front();E;E=E->next()) {
|
||||
|
||||
if (E->get().dst_id==N->get() || E->get().src_id==N->get()) {
|
||||
ur->add_undo_method(graph.ptr(),"connect_node",type,E->get().src_id,E->get().src_slot,E->get().dst_id,E->get().dst_slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
ur->add_do_method(this,"_update_graph");
|
||||
ur->add_undo_method(this,"_update_graph");
|
||||
ur->commit_action();
|
||||
|
||||
}
|
||||
|
||||
void ShaderGraphView::_default_changed(int p_id, Node *p_button, int p_param, int v_type, String p_hint)
|
||||
{
|
||||
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());
|
||||
edited_id=p_id;
|
||||
edited_def=p_param;
|
||||
Variant::Type vt = (Variant::Type)v_type;
|
||||
Variant v = graph->default_get_value(type,p_id,edited_def);
|
||||
int h=PROPERTY_HINT_NONE;
|
||||
if (v.get_type() == Variant::NIL)
|
||||
switch (vt) {
|
||||
case Variant::VECTOR3:
|
||||
v=Vector3();
|
||||
break;
|
||||
case Variant::REAL:
|
||||
h=PROPERTY_HINT_RANGE;
|
||||
v=0.0;
|
||||
break;
|
||||
case Variant::TRANSFORM:
|
||||
v=Transform();
|
||||
break;
|
||||
case Variant::COLOR:
|
||||
h=PROPERTY_HINT_COLOR_NO_ALPHA;
|
||||
v=Color();
|
||||
break;
|
||||
}
|
||||
|
||||
ped_popup->edit(NULL,"",vt,v,h,p_hint);
|
||||
|
||||
ped_popup->popup();
|
||||
}
|
||||
|
||||
ToolButton *ShaderGraphView::make_label(String text, Variant::Type v_type) {
|
||||
ToolButton *l = memnew( ToolButton );
|
||||
l->set_text(text);
|
||||
l->set_text_align(ToolButton::ALIGN_LEFT);
|
||||
l->add_style_override("hover", l->get_stylebox("normal", "ToolButton"));
|
||||
l->add_style_override("pressed", l->get_stylebox("normal", "ToolButton"));
|
||||
l->add_style_override("focus", l->get_stylebox("normal", "ToolButton"));
|
||||
switch (v_type) {
|
||||
case Variant::REAL:
|
||||
l->set_icon(ped_popup->get_icon("Real", "EditorIcons"));
|
||||
break;
|
||||
case Variant::VECTOR3:
|
||||
l->set_icon(ped_popup->get_icon("Vector", "EditorIcons"));
|
||||
break;
|
||||
case Variant::TRANSFORM:
|
||||
l->set_icon(ped_popup->get_icon("Matrix", "EditorIcons"));
|
||||
break;
|
||||
case Variant::COLOR:
|
||||
l->set_icon(ped_popup->get_icon("Color", "EditorIcons"));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
ToolButton *ShaderGraphView::make_editor(String text,GraphNode* gn,int p_id,int param,Variant::Type v_type, String p_hint) {
|
||||
ToolButton *edit = memnew( ToolButton );
|
||||
edit->set_text(text);
|
||||
edit->set_text_align(ToolButton::ALIGN_LEFT);
|
||||
edit->set_flat(false);
|
||||
edit->add_style_override("normal", gn->get_stylebox("defaultframe", "GraphNode"));
|
||||
edit->add_style_override("hover", gn->get_stylebox("defaultframe", "GraphNode"));
|
||||
edit->add_style_override("pressed", gn->get_stylebox("defaultframe", "GraphNode"));
|
||||
edit->add_style_override("focus", gn->get_stylebox("defaultfocus", "GraphNode"));
|
||||
edit->connect("pressed",this,"_default_changed",varray(p_id,edit,param,v_type,p_hint));
|
||||
|
||||
switch (v_type) {
|
||||
case Variant::REAL:
|
||||
edit->set_icon(ped_popup->get_icon("Real", "EditorIcons"));
|
||||
break;
|
||||
case Variant::VECTOR3:
|
||||
edit->set_icon(ped_popup->get_icon("Vector", "EditorIcons"));
|
||||
break;
|
||||
case Variant::TRANSFORM:
|
||||
edit->set_icon(ped_popup->get_icon("Matrix", "EditorIcons"));
|
||||
break;
|
||||
case Variant::COLOR:
|
||||
Image icon_color = Image(15,15,false,Image::FORMAT_RGB);
|
||||
Color c = graph->default_get_value(type,p_id,param);
|
||||
for (int x=1;x<14;x++)
|
||||
for (int y=1;y<14;y++)
|
||||
icon_color.put_pixel(x,y,c);
|
||||
Ref<ImageTexture> t;
|
||||
t.instance();
|
||||
t->create_from_image(icon_color);
|
||||
edit->set_icon(t);
|
||||
break;
|
||||
}
|
||||
return edit;
|
||||
}
|
||||
|
||||
void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
@ -1187,6 +1398,9 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
Color(0,1,1)
|
||||
};
|
||||
|
||||
const String hint_spin = "-65536,65535,0.001";
|
||||
const String hint_slider = "0.0,1.0,0.01,slider";
|
||||
|
||||
|
||||
switch(graph->node_get_type(type,p_id)) {
|
||||
|
||||
@ -1291,7 +1505,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("ScreenTex");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("UV")));
|
||||
if (!graph->is_slot_connected(type,p_id,0)) {
|
||||
Vector3 v = graph->default_get_value(type, p_id, 0);
|
||||
hbc->add_child(make_editor("UV: " + v,gn,p_id,0,Variant::VECTOR3));
|
||||
} else {
|
||||
hbc->add_child(make_label("UV",Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("RGB")));
|
||||
gn->add_child(hbc);
|
||||
@ -1325,11 +1544,21 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a",Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("a: ")+Variant(v),gn,p_id,0,Variant::REAL,hint_spin));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b",Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("b: ")+Variant(v),gn,p_id,1,Variant::REAL,hint_spin));
|
||||
}
|
||||
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR]);
|
||||
gn->set_slot(2,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],false,0,Color());
|
||||
@ -1363,11 +1592,21 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a",Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("a: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b",Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("b: ")+v,gn,p_id,1,Variant::VECTOR3));
|
||||
}
|
||||
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],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());
|
||||
@ -1395,12 +1634,22 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a",Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("a: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b",Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("b: ")+Variant(v),gn,p_id,1,Variant::REAL,hint_spin));
|
||||
}
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC]);
|
||||
gn->set_slot(2,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],false,0,Color());
|
||||
|
||||
@ -1433,11 +1682,19 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a",Variant::COLOR));
|
||||
} else {
|
||||
hbc->add_child(make_editor(String("a: "),gn,p_id,0,Variant::COLOR));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b",Variant::COLOR));
|
||||
} else {
|
||||
gn->add_child(make_editor(String("b: "),gn,p_id,1,Variant::COLOR));
|
||||
}
|
||||
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],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());
|
||||
@ -1447,11 +1704,19 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
gn->set_title("XFMult");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a",Variant::TRANSFORM));
|
||||
} else {
|
||||
hbc->add_child(make_editor(String("a: edit..."),gn,p_id,0,Variant::TRANSFORM));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b",Variant::TRANSFORM));
|
||||
} else {
|
||||
gn->add_child(make_editor(String("b: edit..."),gn,p_id,1,Variant::TRANSFORM));
|
||||
}
|
||||
|
||||
gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_XFORM,typecol[ShaderGraph::SLOT_TYPE_XFORM],true,ShaderGraph::SLOT_TYPE_XFORM,typecol[ShaderGraph::SLOT_TYPE_XFORM]);
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_XFORM,typecol[ShaderGraph::SLOT_TYPE_XFORM],false,0,Color());
|
||||
@ -1462,8 +1727,7 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
gn->set_title("XFVecMult");
|
||||
|
||||
Button *button = memnew( Button("RotOnly"));
|
||||
button->set_toggle_mode(true);
|
||||
CheckBox *button = memnew (CheckBox("RotOnly"));
|
||||
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));
|
||||
|
||||
@ -1471,13 +1735,22 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("xf")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("xf",Variant::TRANSFORM));
|
||||
} else {
|
||||
hbc->add_child(make_editor(String("xf: edit..."),gn,p_id,0,Variant::TRANSFORM));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l = memnew(Label("out"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
hbc->add_child( l);
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("vec")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("a",Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("a: ")+v,gn,p_id,1,Variant::VECTOR3));
|
||||
}
|
||||
|
||||
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());
|
||||
@ -1488,17 +1761,25 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("XFVecInvMult");
|
||||
|
||||
|
||||
Button *button = memnew( Button("RotOnly"));
|
||||
button->set_toggle_mode(true);
|
||||
CheckBox *button = memnew( CheckBox("RotOnly"));
|
||||
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")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
gn->add_child(make_label("a",Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
gn->add_child(make_editor(String("a: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("xf")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
hbc->add_child(make_label("xf", Variant::TRANSFORM));
|
||||
} else {
|
||||
hbc->add_child(make_editor(String("xf: edit..."),gn,p_id,1,Variant::TRANSFORM));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l = memnew(Label("out"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1547,7 +1828,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->add_child(ob);
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_child( memnew(Label("in")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("in", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("in: ")+Variant(v),gn,p_id,0,Variant::REAL,hint_spin));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
@ -1582,7 +1868,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("in")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("in", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("in: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("out")));
|
||||
gn->add_child(hbc);
|
||||
@ -1593,7 +1884,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
case ShaderGraph::NODE_VEC_LEN: {
|
||||
gn->set_title("VecLength");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_child( memnew(Label("in")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("in", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("in: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("len")));
|
||||
gn->add_child(hbc);
|
||||
@ -1606,11 +1902,21 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("DotProduct");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("a: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("dp")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("b: ")+v,gn,p_id,1,Variant::VECTOR3));
|
||||
}
|
||||
|
||||
gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR]);
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],false,0,Color());
|
||||
@ -1621,7 +1927,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("Vec2Scalar");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("vec")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("vec", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("vec: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("x"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1646,12 +1957,27 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
gn->set_title("Scalar2Vec");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_child( memnew(Label("x")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("x", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("x: ")+Variant(v),gn,p_id,0,Variant::REAL));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("vec")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("y")));
|
||||
gn->add_child( memnew(Label("z")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("y", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("y: ")+Variant(v),gn,p_id,1,Variant::REAL));
|
||||
}
|
||||
if (graph->is_slot_connected(type, p_id, 2)) {
|
||||
gn->add_child(make_label("in", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,2);
|
||||
gn->add_child(make_editor(String("in: ")+Variant(v),gn,p_id,2,Variant::REAL));
|
||||
}
|
||||
|
||||
gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC]);
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],false,0,Color());
|
||||
@ -1663,13 +1989,33 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("Vec2XForm");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("x")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("x", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("x: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("xf")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("y")));
|
||||
gn->add_child( memnew(Label("z")));
|
||||
gn->add_child( memnew(Label("ofs")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("y", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("y: ")+v,gn,p_id,1,Variant::VECTOR3));
|
||||
}
|
||||
if (graph->is_slot_connected(type, p_id, 2)) {
|
||||
gn->add_child(make_label("z", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,2);
|
||||
gn->add_child(make_editor(String("z: ")+v,gn,p_id,2,Variant::VECTOR3));
|
||||
}
|
||||
if (graph->is_slot_connected(type, p_id, 3)) {
|
||||
gn->add_child(make_label("ofs", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,3);
|
||||
gn->add_child(make_editor(String("ofs: ")+v,gn,p_id,3,Variant::VECTOR3));
|
||||
}
|
||||
|
||||
gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],true,ShaderGraph::SLOT_TYPE_XFORM,typecol[ShaderGraph::SLOT_TYPE_XFORM]);
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_VEC,typecol[ShaderGraph::SLOT_TYPE_VEC],false,0,Color());
|
||||
@ -1683,7 +2029,11 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("xf")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("fx", Variant::TRANSFORM));
|
||||
} else {
|
||||
hbc->add_child(make_editor(String("fx: edit..."),gn,p_id,0,Variant::TRANSFORM));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("x"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1710,12 +2060,27 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("ScalarInterp");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("a: ")+Variant(v),gn,p_id,0,Variant::REAL,hint_spin));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("interp")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
gn->add_child( memnew(Label("c")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("b: ")+Variant(v),gn,p_id,1,Variant::REAL,hint_spin));
|
||||
}
|
||||
if (graph->is_slot_connected(type, p_id, 2)) {
|
||||
gn->add_child(make_label("c", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,2);
|
||||
gn->add_child(make_editor(String("c: ")+Variant(v),gn,p_id,2,Variant::REAL,hint_slider));
|
||||
}
|
||||
|
||||
gn->set_slot(0,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR]);
|
||||
gn->set_slot(1,true,ShaderGraph::SLOT_TYPE_SCALAR,typecol[ShaderGraph::SLOT_TYPE_SCALAR],false,0,Color());
|
||||
@ -1727,12 +2092,27 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
gn->set_title("VecInterp");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_child( memnew(Label("a")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("a", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("a: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
hbc->add_child( memnew(Label("interp")));
|
||||
gn->add_child(hbc);
|
||||
gn->add_child( memnew(Label("b")));
|
||||
gn->add_child( memnew(Label("c")));
|
||||
if (graph->is_slot_connected(type, p_id, 1)) {
|
||||
gn->add_child(make_label("b", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,1);
|
||||
gn->add_child(make_editor(String("b: ")+v,gn,p_id,1,Variant::VECTOR3));
|
||||
}
|
||||
if (graph->is_slot_connected(type, p_id, 2)) {
|
||||
gn->add_child(make_label("c", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,2);
|
||||
gn->add_child(make_editor(String("c: ")+Variant(v),gn,p_id,2,Variant::REAL,hint_slider));
|
||||
}
|
||||
|
||||
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());
|
||||
@ -1771,7 +2151,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("c")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("c", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("c: ")+Variant(v),gn,p_id,0,Variant::REAL,hint_slider));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("rgb"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1816,7 +2201,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("c")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("c", Variant::REAL));
|
||||
} else {
|
||||
float v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("c: ")+Variant(v),gn,p_id,0,Variant::REAL,hint_slider));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("cmap"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1930,7 +2320,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("UV")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("UV", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("UV: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("RGB"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1961,7 +2356,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("UV")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("UV", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("UV: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("RGB"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -1981,7 +2381,12 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
gn->set_title("CanvasItemTex");
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
hbc->add_constant_override("separation",0);
|
||||
hbc->add_child( memnew(Label("UV")));
|
||||
if (graph->is_slot_connected(type, p_id, 0)) {
|
||||
hbc->add_child(make_label("UV", Variant::VECTOR3));
|
||||
} else {
|
||||
Vector3 v = graph->default_get_value(type,p_id,0);
|
||||
hbc->add_child(make_editor(String("UV: ")+v,gn,p_id,0,Variant::VECTOR3));
|
||||
}
|
||||
hbc->add_spacer();
|
||||
Label *l=memnew(Label("RGB"));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
@ -2000,19 +2405,42 @@ void ShaderGraphView::_create_node(int p_id) {
|
||||
|
||||
case ShaderGraph::NODE_OUTPUT: {
|
||||
gn->set_title("Output");
|
||||
gn->set_show_close_button(false);
|
||||
|
||||
List<ShaderGraph::SlotInfo> si;
|
||||
ShaderGraph::get_input_output_node_slot_info(graph->get_mode(),type,&si);
|
||||
|
||||
Array colors;
|
||||
colors.push_back("Color");
|
||||
colors.push_back("LightColor");
|
||||
colors.push_back("Light");
|
||||
colors.push_back("Diffuse");
|
||||
colors.push_back("Specular");
|
||||
colors.push_back("Emmision");
|
||||
Array reals;
|
||||
reals.push_back("Alpha");
|
||||
reals.push_back("DiffuseAlpha");
|
||||
reals.push_back("NormalMapDepth");
|
||||
reals.push_back("SpecExp");
|
||||
reals.push_back("Glow");
|
||||
reals.push_back("ShadeParam");
|
||||
reals.push_back("SpecularExp");
|
||||
reals.push_back("LightAlpha");
|
||||
reals.push_back("PointSize");
|
||||
reals.push_back("Discard");
|
||||
|
||||
int idx=0;
|
||||
for (List<ShaderGraph::SlotInfo>::Element *E=si.front();E;E=E->next()) {
|
||||
ShaderGraph::SlotInfo& s=E->get();
|
||||
if (s.dir==ShaderGraph::SLOT_OUT) {
|
||||
|
||||
Label *l= memnew( Label );
|
||||
l->set_text(s.name);
|
||||
l->set_align(Label::ALIGN_LEFT);
|
||||
gn->add_child(l);
|
||||
Variant::Type v;
|
||||
if (colors.find(s.name)>=0)
|
||||
v=Variant::COLOR;
|
||||
else if (reals.find(s.name)>=0)
|
||||
v=Variant::REAL;
|
||||
else
|
||||
v=Variant::VECTOR3;
|
||||
gn->add_child(make_label(s.name, v));
|
||||
gn->set_slot(idx,true,s.type,typecol[s.type],false,0,Color());
|
||||
idx++;
|
||||
}
|
||||
@ -2076,8 +2504,6 @@ void ShaderGraphView::_update_graph() {
|
||||
graph_edit->connect_node(node_map[E->get().src_id]->get_name(),E->get().src_slot,node_map[E->get().dst_id]->get_name(),E->get().dst_slot);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShaderGraphView::_sg_updated() {
|
||||
@ -2112,9 +2538,12 @@ void ShaderGraphView::_notification(int p_what) {
|
||||
|
||||
ped_popup->connect("variant_changed",this,"_variant_edited");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderGraphView::add_node(int p_type) {
|
||||
void ShaderGraphView::add_node(int p_type, const Vector2 &location) {
|
||||
|
||||
if ((p_type==ShaderGraph::NODE_INPUT||p_type==ShaderGraph::NODE_INPUT) && graph->node_count(type, p_type)>0)
|
||||
return;
|
||||
|
||||
List<int> existing;
|
||||
graph->get_node_list(type,&existing);
|
||||
@ -2127,7 +2556,7 @@ void ShaderGraphView::add_node(int p_type) {
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 init_ofs(20,20);
|
||||
Vector2 init_ofs = location;
|
||||
while(true) {
|
||||
bool valid=true;
|
||||
for(List<int>::Element *E=existing.front();E;E=E->next()) {
|
||||
@ -2157,12 +2586,18 @@ void ShaderGraphView::add_node(int p_type) {
|
||||
void ShaderGraphView::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method("_update_graph",&ShaderGraphView::_update_graph);
|
||||
ObjectTypeDB::bind_method("_begin_node_move", &ShaderGraphView::_begin_node_move);
|
||||
ObjectTypeDB::bind_method("_node_moved",&ShaderGraphView::_node_moved);
|
||||
ObjectTypeDB::bind_method("_end_node_move", &ShaderGraphView::_end_node_move);
|
||||
ObjectTypeDB::bind_method("_move_node",&ShaderGraphView::_move_node);
|
||||
ObjectTypeDB::bind_method("_node_removed",&ShaderGraphView::_node_removed);
|
||||
ObjectTypeDB::bind_method("_connection_request",&ShaderGraphView::_connection_request);
|
||||
ObjectTypeDB::bind_method("_disconnection_request",&ShaderGraphView::_disconnection_request);
|
||||
ObjectTypeDB::bind_method("_duplicate_nodes_request", &ShaderGraphView::_duplicate_nodes_request);
|
||||
ObjectTypeDB::bind_method("_duplicate_nodes", &ShaderGraphView::_duplicate_nodes);
|
||||
ObjectTypeDB::bind_method("_delete_nodes_request", &ShaderGraphView::_delete_nodes_request);
|
||||
|
||||
ObjectTypeDB::bind_method("_default_changed",&ShaderGraphView::_default_changed);
|
||||
ObjectTypeDB::bind_method("_scalar_const_changed",&ShaderGraphView::_scalar_const_changed);
|
||||
ObjectTypeDB::bind_method("_vec_const_changed",&ShaderGraphView::_vec_const_changed);
|
||||
ObjectTypeDB::bind_method("_rgb_const_changed",&ShaderGraphView::_rgb_const_changed);
|
||||
@ -2200,6 +2635,8 @@ ShaderGraphView::ShaderGraphView(ShaderGraph::ShaderType p_type) {
|
||||
graph_edit->add_child(ped_popup);
|
||||
status = memnew( Label );
|
||||
graph_edit->get_top_layer()->add_child(status);
|
||||
graph_edit->connect("_begin_node_move", this, "_begin_node_move");
|
||||
graph_edit->connect("_end_node_move", this, "_end_node_move");
|
||||
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));
|
||||
@ -2222,9 +2659,18 @@ void ShaderGraphEditor::_add_node(int p_type) {
|
||||
|
||||
ShaderGraph::ShaderType shader_type=ShaderGraph::ShaderType(tabs->get_current_tab());
|
||||
|
||||
graph_edits[shader_type]->add_node(p_type);
|
||||
graph_edits[shader_type]->add_node(p_type, next_location);
|
||||
}
|
||||
|
||||
void ShaderGraphEditor::_popup_requested(const Vector2 &p_position)
|
||||
{
|
||||
next_location = get_local_mouse_pos();
|
||||
popup->set_global_pos(p_position);
|
||||
popup->set_size( Size2( 200, 0) );
|
||||
popup->popup();
|
||||
popup->call_deferred("grab_click_focus");
|
||||
popup->set_invalidate_click_until_motion();
|
||||
}
|
||||
|
||||
void ShaderGraphEditor::_notification(int p_what) {
|
||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||
@ -2243,11 +2689,11 @@ void ShaderGraphEditor::_notification(int p_what) {
|
||||
if (nn.ends_with(":")) {
|
||||
addsep=true;
|
||||
}
|
||||
menu->get_popup()->add_icon_item(get_icon(ic,"EditorIcons"),v,i);
|
||||
popup->add_icon_item(get_icon(ic,"EditorIcons"),v,i);
|
||||
if (addsep)
|
||||
menu->get_popup()->add_separator();
|
||||
popup->add_separator();
|
||||
}
|
||||
menu->get_popup()->connect("item_pressed",this,"_add_node");
|
||||
popup->connect("item_pressed",this,"_add_node");
|
||||
|
||||
|
||||
}
|
||||
@ -2256,7 +2702,7 @@ void ShaderGraphEditor::_notification(int p_what) {
|
||||
void ShaderGraphEditor::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method("_add_node",&ShaderGraphEditor::_add_node);
|
||||
|
||||
ObjectTypeDB::bind_method("_popup_requested",&ShaderGraphEditor::_popup_requested);
|
||||
}
|
||||
|
||||
|
||||
@ -2302,11 +2748,8 @@ const char* ShaderGraphEditor::node_names[ShaderGraph::NODE_TYPE_MAX]={
|
||||
ShaderGraphEditor::ShaderGraphEditor(bool p_2d) {
|
||||
_2d=p_2d;
|
||||
|
||||
HBoxContainer *hbc = memnew( HBoxContainer );
|
||||
menu = memnew( MenuButton );
|
||||
menu->set_text("Add Node..");
|
||||
hbc->add_child(menu);
|
||||
add_child(hbc);
|
||||
popup = memnew( PopupMenu );
|
||||
add_child(popup);
|
||||
|
||||
|
||||
tabs = memnew(TabContainer);
|
||||
@ -2325,8 +2768,10 @@ ShaderGraphEditor::ShaderGraphEditor(bool p_2d) {
|
||||
tabs->add_child(graph_edits[i]->get_graph_edit());
|
||||
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()->connect("duplicate_nodes_request", graph_edits[i], "_duplicate_nodes_request");
|
||||
graph_edits[i]->get_graph_edit()->connect("popup_request",this,"_popup_requested");
|
||||
graph_edits[i]->get_graph_edit()->connect("delete_nodes_request",graph_edits[i],"_delete_nodes_request");
|
||||
graph_edits[i]->get_graph_edit()->set_right_disconnects(true);
|
||||
|
||||
}
|
||||
|
||||
tabs->set_current_tab(1);
|
||||
@ -2374,9 +2819,9 @@ ShaderGraphEditorPlugin::ShaderGraphEditorPlugin(EditorNode *p_node, bool p_2d)
|
||||
SpatialEditor::get_singleton()->get_shader_split()->add_child(shader_editor);
|
||||
|
||||
|
||||
// editor->get_viewport()->add_child(shader_editor);
|
||||
// shader_editor->set_area_as_parent_rect();
|
||||
// shader_editor->hide();
|
||||
// editor->get_viewport()->add_child(shader_editor);
|
||||
// shader_editor->set_area_as_parent_rect();
|
||||
// shader_editor->hide();
|
||||
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ class ShaderGraphView : public Node {
|
||||
GraphEdit *graph_edit;
|
||||
Ref<ShaderGraph> graph;
|
||||
int edited_id;
|
||||
int edited_def;
|
||||
|
||||
ShaderGraph::ShaderType type;
|
||||
|
||||
@ -136,13 +137,23 @@ class ShaderGraphView : public Node {
|
||||
void _create_node(int p_id);
|
||||
|
||||
|
||||
ToolButton *make_label(String text, Variant::Type v_type = Variant::NIL);
|
||||
ToolButton *make_editor(String text, GraphNode* gn, int p_id, int param, Variant::Type type, String p_hint="");
|
||||
|
||||
void _connection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
|
||||
void _disconnection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
|
||||
|
||||
void _node_removed(int p_id);
|
||||
void _begin_node_move();
|
||||
void _node_moved(const Vector2& p_from, const Vector2& p_to,int p_id);
|
||||
void _end_node_move();
|
||||
void _move_node(int p_id,const Vector2& p_to);
|
||||
void _duplicate_nodes_request();
|
||||
void _duplicate_nodes(Array &p_nodes);
|
||||
void _delete_nodes_request();
|
||||
|
||||
|
||||
void _default_changed(int p_id, Node* p_button, int p_param, int v_type, String p_hint);
|
||||
|
||||
void _scalar_const_changed(double p_value,int p_id);
|
||||
void _vec_const_changed(double p_value, int p_id, Array p_arr);
|
||||
@ -175,7 +186,7 @@ protected:
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
void add_node(int p_type);
|
||||
void add_node(int p_type, const Vector2 &location);
|
||||
GraphEdit *get_graph_edit() { return graph_edit; }
|
||||
void set_graph(Ref<ShaderGraph> p_graph);
|
||||
|
||||
@ -186,13 +197,15 @@ class ShaderGraphEditor : public VBoxContainer {
|
||||
|
||||
OBJ_TYPE(ShaderGraphEditor,VBoxContainer);
|
||||
|
||||
MenuButton *menu;
|
||||
PopupMenu *popup;
|
||||
TabContainer *tabs;
|
||||
ShaderGraphView *graph_edits[ShaderGraph::SHADER_TYPE_MAX];
|
||||
static const char* node_names[ShaderGraph::NODE_TYPE_MAX];
|
||||
Vector2 next_location;
|
||||
|
||||
bool _2d;
|
||||
void _add_node(int p_type);
|
||||
void _popup_requested(const Vector2 &p_position);
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
@ -237,6 +237,8 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
|
||||
inheritors_array.clear();
|
||||
text_edit->hide();
|
||||
easing_draw->hide();
|
||||
spinbox->hide();
|
||||
slider->hide();
|
||||
|
||||
for (int i=0;i<MAX_VALUE_EDITORS;i++) {
|
||||
|
||||
@ -262,7 +264,45 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
|
||||
case Variant::INT:
|
||||
case Variant::REAL: {
|
||||
|
||||
if (hint==PROPERTY_HINT_ALL_FLAGS) {
|
||||
if (hint==PROPERTY_HINT_RANGE) {
|
||||
|
||||
int c = hint_text.get_slice_count(",");
|
||||
float min=0,max=100,step=1;
|
||||
if (c>=1) {
|
||||
|
||||
if (!hint_text.get_slice(",",0).empty())
|
||||
min=hint_text.get_slice(",",0).to_double();
|
||||
}
|
||||
if (c>=2) {
|
||||
|
||||
if (!hint_text.get_slice(",",1).empty())
|
||||
max=hint_text.get_slice(",",1).to_double();
|
||||
}
|
||||
|
||||
if (type==Variant::REAL && c>=3) {
|
||||
|
||||
if (!hint_text.get_slice(",",2).empty())
|
||||
step= hint_text.get_slice(",",2).to_double();
|
||||
}
|
||||
|
||||
if (c>=4 && hint_text.get_slice(",",3)=="slider") {
|
||||
slider->set_min(min);
|
||||
slider->set_max(max);
|
||||
slider->set_step((type==Variant::REAL) ? step : 1);
|
||||
slider->set_val(v);
|
||||
slider->show();
|
||||
set_size(Size2(110,30));
|
||||
} else {
|
||||
spinbox->set_min(min);
|
||||
spinbox->set_max(max);
|
||||
spinbox->set_step((type==Variant::REAL) ? step : 1);
|
||||
spinbox->set_val(v);
|
||||
spinbox->show();
|
||||
set_size(Size2(70,35));
|
||||
}
|
||||
|
||||
|
||||
} else if (hint==PROPERTY_HINT_ALL_FLAGS) {
|
||||
|
||||
uint32_t flgs = v;
|
||||
for(int i=0;i<2;i++) {
|
||||
@ -1423,6 +1463,12 @@ void CustomPropertyEditor::_modified(String p_string) {
|
||||
updating=false;
|
||||
}
|
||||
|
||||
void CustomPropertyEditor::_range_modified(double p_value)
|
||||
{
|
||||
v=p_value;
|
||||
emit_signal("variant_changed");
|
||||
}
|
||||
|
||||
void CustomPropertyEditor::_focus_enter() {
|
||||
switch(type) {
|
||||
case Variant::REAL:
|
||||
@ -1532,6 +1578,7 @@ void CustomPropertyEditor::_bind_methods() {
|
||||
ObjectTypeDB::bind_method("_focus_enter", &CustomPropertyEditor::_focus_enter);
|
||||
ObjectTypeDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit);
|
||||
ObjectTypeDB::bind_method("_modified",&CustomPropertyEditor::_modified);
|
||||
ObjectTypeDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified);
|
||||
ObjectTypeDB::bind_method("_scroll_modified",&CustomPropertyEditor::_scroll_modified);
|
||||
ObjectTypeDB::bind_method("_action_pressed",&CustomPropertyEditor::_action_pressed);
|
||||
ObjectTypeDB::bind_method("_file_selected",&CustomPropertyEditor::_file_selected);
|
||||
@ -1655,6 +1702,16 @@ CustomPropertyEditor::CustomPropertyEditor() {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("item_pressed",this,"_menu_option");
|
||||
|
||||
spinbox = memnew ( SpinBox );
|
||||
add_child(spinbox);
|
||||
spinbox->set_area_as_parent_rect(5);
|
||||
spinbox->connect("value_changed",this,"_range_modified");
|
||||
|
||||
slider = memnew ( HSlider );
|
||||
add_child(slider);
|
||||
slider->set_area_as_parent_rect(5);
|
||||
slider->connect("value_changed",this,"_range_modified");
|
||||
}
|
||||
|
||||
bool PropertyEditor::_might_be_in_instance() {
|
||||
|
@ -93,7 +93,8 @@ class CustomPropertyEditor : public Popup {
|
||||
TextEdit *text_edit;
|
||||
bool read_only;
|
||||
Button *checks20[20];
|
||||
|
||||
SpinBox *spinbox;
|
||||
HSlider *slider;
|
||||
|
||||
|
||||
Control *easing_draw;
|
||||
@ -106,6 +107,7 @@ class CustomPropertyEditor : public Popup {
|
||||
void _file_selected(String p_file);
|
||||
void _scroll_modified(double p_value);
|
||||
void _modified(String p_string);
|
||||
void _range_modified(double p_value);
|
||||
void _focus_enter();
|
||||
void _focus_exit();
|
||||
void _action_pressed(int p_which);
|
||||
|
Loading…
Reference in New Issue
Block a user