Merge pull request #22944 from fire/visual-script-constructor-21840

Fixed the problem with vector3 constructor
This commit is contained in:
Rémi Verschelde 2018-10-16 11:42:49 +02:00 committed by GitHub
commit d36f33a227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -48,20 +48,22 @@ bool VisualScriptNode::is_breakpoint() const {
void VisualScriptNode::_notification(int p_what) { void VisualScriptNode::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) { if (p_what == NOTIFICATION_POSTINITIALIZE) {
_update_input_ports();
}
}
int dvc = get_input_value_port_count(); void VisualScriptNode::_update_input_ports() {
for (int i = 0; i < dvc; i++) { default_input_values.resize(MAX(default_input_values.size(), get_input_value_port_count())); //let it grow as big as possible, we don't want to lose values on resize
int port_count = get_input_value_port_count();
for (int i = 0; i < port_count; i++) {
Variant::Type expected = get_input_value_port_info(i).type; Variant::Type expected = get_input_value_port_info(i).type;
Variant::CallError ce; Variant::CallError ce;
default_input_values.push_back(Variant::construct(expected, NULL, 0, ce, false)); set_default_input_value(i, Variant::construct(expected, NULL, 0, ce, false));
}
} }
} }
void VisualScriptNode::ports_changed_notify() { void VisualScriptNode::ports_changed_notify() {
_update_input_ports();
default_input_values.resize(MAX(default_input_values.size(), get_input_value_port_count())); //let it grow as big as possible, we don't want to lose values on resize
emit_signal("ports_changed"); emit_signal("ports_changed");
} }

View File

@ -52,6 +52,7 @@ class VisualScriptNode : public Resource {
Array _get_default_input_values() const; Array _get_default_input_values() const;
void validate_input_default_values(); void validate_input_default_values();
void _update_input_ports();
protected: protected:
void _notification(int p_what); void _notification(int p_what);