summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/visual_script.cpp9
-rw-r--r--modules/visual_script/visual_script.h91
-rw-r--r--modules/visual_script/visual_script_editor.cpp11
-rw-r--r--modules/visual_script/visual_script_expression.cpp6
-rw-r--r--modules/visual_script/visual_script_expression.h45
5 files changed, 74 insertions, 88 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index fe92f59179..2517b17168 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -137,7 +137,6 @@ Ref<VisualScript> VisualScriptNode::get_visual_script() const {
}
VisualScriptNode::VisualScriptNode() {
- breakpoint = false;
}
////////////////
@@ -145,8 +144,6 @@ VisualScriptNode::VisualScriptNode() {
/////////////////////
VisualScriptNodeInstance::VisualScriptNodeInstance() {
- sequence_outputs = nullptr;
- input_ports = nullptr;
}
VisualScriptNodeInstance::~VisualScriptNodeInstance() {
@@ -2623,14 +2620,8 @@ void VisualScriptLanguage::get_registered_node_names(List<String> *r_names) {
}
VisualScriptLanguage::VisualScriptLanguage() {
- notification = "_notification";
- _step = "_step";
- _subcall = "_subcall";
singleton = this;
- _debug_parse_err_node = -1;
- _debug_parse_err_file = "";
- _debug_call_stack_pos = 0;
int dmcs = GLOBAL_DEF("debug/settings/visual_script/max_call_stack", 1024);
ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/visual_script/max_call_stack", PropertyInfo(Variant::INT, "debug/settings/visual_script/max_call_stack", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater")); //minimum is 1024
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index bdb3c3a16b..72362e0ef4 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -49,7 +49,7 @@ class VisualScriptNode : public Resource {
Ref<VisualScript> script_used;
Array default_input_values;
- bool breakpoint;
+ bool breakpoint = false;
void _set_default_input_values(Array p_values);
Array _get_default_input_values() const;
@@ -90,13 +90,9 @@ public:
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0;
struct TypeGuess {
- Variant::Type type;
+ Variant::Type type = Variant::NIL;
StringName gdclass;
Ref<Script> script;
-
- TypeGuess() {
- type = Variant::NIL;
- }
};
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
@@ -114,19 +110,19 @@ class VisualScriptNodeInstance {
INPUT_DEFAULT_VALUE_BIT = INPUT_SHIFT, // from unassigned input port, using default value (edited by user)
};
- int id;
- int sequence_index;
- VisualScriptNodeInstance **sequence_outputs;
- int sequence_output_count;
+ int id = 0;
+ int sequence_index = 0;
+ VisualScriptNodeInstance **sequence_outputs = nullptr;
+ int sequence_output_count = 0;
Vector<VisualScriptNodeInstance *> dependencies;
- int *input_ports;
- int input_port_count;
- int *output_ports;
- int output_port_count;
- int working_mem_idx;
- int pass_idx;
+ int *input_ports = nullptr;
+ int input_port_count = 0;
+ int *output_ports = nullptr;
+ int output_port_count = 0;
+ int working_mem_idx = 0;
+ int pass_idx = 0;
- VisualScriptNode *base;
+ VisualScriptNode *base = nullptr;
public:
enum StartMode {
@@ -178,7 +174,7 @@ public:
uint64_t from_output : 16;
uint64_t to_node : 24;
};
- uint64_t id;
+ uint64_t id = 0;
};
bool operator<(const SequenceConnection &p_connection) const {
@@ -194,7 +190,7 @@ public:
uint64_t to_node : 24;
uint64_t to_port : 8;
};
- uint64_t id;
+ uint64_t id = 0;
};
bool operator<(const DataConnection &p_connection) const {
@@ -208,7 +204,7 @@ private:
StringName base_type;
struct Argument {
String name;
- Variant::Type type;
+ Variant::Type type = Variant::Type::NIL;
};
struct NodeData {
@@ -231,7 +227,7 @@ private:
struct Variable {
PropertyInfo info;
Variant default_value;
- bool _export;
+ bool _export = false;
// Add getter & setter options here.
};
@@ -388,26 +384,27 @@ public:
};
class VisualScriptInstance : public ScriptInstance {
- Object *owner;
+ Object *owner = nullptr;
Ref<VisualScript> script;
Map<StringName, Variant> variables; // Using variable path, not script.
Map<int, VisualScriptNodeInstance *> instances;
struct Function {
- int node;
- int max_stack;
- int trash_pos;
- int flow_stack_size;
- int pass_stack_size;
- int node_count;
- int argument_count;
+ int node = 0;
+ int max_stack = 0;
+ int trash_pos = 0;
+ int flow_stack_size = 0;
+ int pass_stack_size = 0;
+ int node_count = 0;
+ int argument_count = 0;
};
Map<StringName, Function> functions;
Vector<Variant> default_values;
- int max_input_args, max_output_args;
+ int max_input_args = 0;
+ int max_output_args = 0;
StringName source;
@@ -479,14 +476,14 @@ class VisualScriptFunctionState : public Reference {
ObjectID instance_id;
ObjectID script_id;
- VisualScriptInstance *instance;
+ VisualScriptInstance *instance = nullptr;
StringName function;
Vector<uint8_t> stack;
- int working_mem_index;
- int variant_stack_size;
- VisualScriptNodeInstance *node;
- int flow_stack_pos;
- int pass;
+ int working_mem_index = 0;
+ int variant_stack_size = 0;
+ VisualScriptNodeInstance *node = nullptr;
+ int flow_stack_pos = 0;
+ int pass = 0;
Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
@@ -507,25 +504,25 @@ class VisualScriptLanguage : public ScriptLanguage {
Map<String, VisualScriptNodeRegisterFunc> register_funcs;
struct CallLevel {
- Variant *stack;
- Variant **work_mem;
- const StringName *function;
- VisualScriptInstance *instance;
- int *current_id;
+ Variant *stack = nullptr;
+ Variant **work_mem = nullptr;
+ const StringName *function = nullptr;
+ VisualScriptInstance *instance = nullptr;
+ int *current_id = nullptr;
};
- int _debug_parse_err_node;
- String _debug_parse_err_file;
+ int _debug_parse_err_node = -1;
+ String _debug_parse_err_file = "";
String _debug_error;
- int _debug_call_stack_pos;
+ int _debug_call_stack_pos = 0;
int _debug_max_call_stack;
CallLevel *_call_stack;
public:
- StringName notification;
+ StringName notification = "_notification";
StringName _get_output_port_unsequenced;
- StringName _step;
- StringName _subcall;
+ StringName _step = "_step";
+ StringName _subcall = "_subcall";
static VisualScriptLanguage *singleton;
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 78e4a7f113..92b83f3db0 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -3689,16 +3689,23 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_
return;
}
+ Vector2 new_size = p_new_size;
+ if (graph->is_using_snap()) {
+ Vector2 snap = Vector2(graph->get_snap(), graph->get_snap());
+ Vector2 min_size = (gn->get_minimum_size() + (snap * 0.5)).snapped(snap);
+ new_size = new_size.snapped(snap).max(min_size);
+ }
+
updating_graph = true;
graph->set_block_minimum_size_adjust(true); //faster resize
undo_redo->create_action(TTR("Resize Comment"), UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(vsc.ptr(), "set_size", p_new_size / EDSCALE);
+ undo_redo->add_do_method(vsc.ptr(), "set_size", new_size / EDSCALE);
undo_redo->add_undo_method(vsc.ptr(), "set_size", vsc->get_size());
undo_redo->commit_action();
- gn->set_custom_minimum_size(p_new_size);
+ gn->set_custom_minimum_size(new_size);
gn->set_size(Size2(1, 1));
graph->set_block_minimum_size_adjust(false);
updating_graph = false;
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 9596fda95c..469367ab59 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -1507,12 +1507,6 @@ VisualScriptNodeInstance *VisualScriptExpression::instance(VisualScriptInstance
}
VisualScriptExpression::VisualScriptExpression() {
- output_type = Variant::NIL;
- expression_dirty = true;
- error_set = true;
- root = nullptr;
- nodes = nullptr;
- sequenced = false;
}
VisualScriptExpression::~VisualScriptExpression() {
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index 7fe665769d..bbf76cef3b 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -39,20 +39,18 @@ class VisualScriptExpression : public VisualScriptNode {
friend class VisualScriptNodeInstanceExpression;
struct Input {
- Variant::Type type;
+ Variant::Type type = Variant::NIL;
String name;
-
- Input() { type = Variant::NIL; }
};
Vector<Input> inputs;
- Variant::Type output_type;
+ Variant::Type output_type = Variant::NIL;
String expression;
- bool sequenced;
- int str_ofs;
- bool expression_dirty;
+ bool sequenced = false;
+ int str_ofs = 0;
+ bool expression_dirty = true;
bool _compile_expression();
@@ -114,7 +112,7 @@ class VisualScriptExpression : public VisualScriptNode {
Error _get_token(Token &r_token);
String error_str;
- bool error_set;
+ bool error_set = true;
struct ENode {
enum Type {
@@ -131,11 +129,10 @@ class VisualScriptExpression : public VisualScriptNode {
TYPE_CALL
};
- ENode *next;
+ ENode *next = nullptr;
- Type type;
+ Type type = Type::TYPE_SELF;
- ENode() { next = nullptr; }
virtual ~ENode() {
if (next) {
memdelete(next);
@@ -144,17 +141,17 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct Expression {
- bool is_op;
+ bool is_op = false;
union {
Variant::Operator op;
- ENode *node;
+ ENode *node = nullptr;
};
};
ENode *_parse_expression();
struct InputNode : public ENode {
- int index;
+ int index = 0;
InputNode() {
type = TYPE_INPUT;
}
@@ -168,9 +165,9 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct OperatorNode : public ENode {
- Variant::Operator op;
+ Variant::Operator op = Variant::Operator::OP_ADD;
- ENode *nodes[2];
+ ENode *nodes[2] = { nullptr, nullptr };
OperatorNode() {
type = TYPE_OPERATOR;
@@ -184,8 +181,8 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct IndexNode : public ENode {
- ENode *base;
- ENode *index;
+ ENode *base = nullptr;
+ ENode *index = nullptr;
IndexNode() {
type = TYPE_INDEX;
@@ -193,7 +190,7 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct NamedIndexNode : public ENode {
- ENode *base;
+ ENode *base = nullptr;
StringName name;
NamedIndexNode() {
@@ -202,7 +199,7 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct ConstructorNode : public ENode {
- Variant::Type data_type;
+ Variant::Type data_type = Variant::Type::NIL;
Vector<ENode *> arguments;
ConstructorNode() {
@@ -211,7 +208,7 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct CallNode : public ENode {
- ENode *base;
+ ENode *base = nullptr;
StringName method;
Vector<ENode *> arguments;
@@ -235,7 +232,7 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct BuiltinFuncNode : public ENode {
- VisualScriptBuiltinFunc::BuiltinFunc func;
+ VisualScriptBuiltinFunc::BuiltinFunc func = VisualScriptBuiltinFunc::BuiltinFunc::BYTES_TO_VAR;
Vector<ENode *> arguments;
BuiltinFuncNode() {
type = TYPE_BUILTIN_FUNC;
@@ -250,8 +247,8 @@ class VisualScriptExpression : public VisualScriptNode {
return node;
}
- ENode *root;
- ENode *nodes;
+ ENode *root = nullptr;
+ ENode *nodes = nullptr;
protected:
bool _set(const StringName &p_name, const Variant &p_value);