More null checks.

This commit is contained in:
Relintai 2022-06-07 13:32:04 +02:00
parent ecd2be23a6
commit 729950b86a
2 changed files with 19 additions and 16 deletions

View File

@ -61,6 +61,11 @@ void MMMaterial::initialize() {
for (int i = 0; i < nodes.size(); ++i) {
Ref<MMNode> n = nodes[i];
if (!n.is_valid()) {
continue;
}
n->init_properties();
n->connect("changed", this, "on_node_changed");
}
@ -68,6 +73,8 @@ void MMMaterial::initialize() {
}
void MMMaterial::add_node(const Ref<MMNode> &node) {
ERR_FAIL_COND(!node.is_valid());
nodes.push_back(node);
Ref<MMNode> n = node;
n->connect("changed", this, "on_node_changed");
@ -85,13 +92,15 @@ void MMMaterial::remove_node(const Ref<MMNode> &node) {
for (int j = 0; j < nodes.size(); ++j) {
Ref<MMNode> n = nodes[j];
if (n.is_valid()) {
for (int k = 0; k < n->input_properties.size(); ++k) {
Ref<MMNodeUniversalProperty> ip = n->input_properties[k];
if (!n.is_valid()) {
continue;
}
if (ip->get_input_property() == op) {
ip->set_input_property(Ref<MMNodeUniversalProperty>());
}
for (int k = 0; k < n->input_properties.size(); ++k) {
Ref<MMNodeUniversalProperty> ip = n->input_properties[k];
if (ip->get_input_property() == op) {
ip->set_input_property(Ref<MMNodeUniversalProperty>());
}
}
}

View File

@ -27,11 +27,6 @@ void MMNode::set_input_properties(const Vector<Variant> &val) {
input_properties.clear();
for (int i = 0; i < val.size(); i++) {
Ref<MMNode> e = Ref<MMNode>(val[i]);
if (!e.is_valid()) {
continue;
}
input_properties.push_back(e);
}
}
@ -48,11 +43,6 @@ void MMNode::set_output_properties(const Vector<Variant> &val) {
output_properties.clear();
for (int i = 0; i < val.size(); i++) {
Ref<MMNode> e = Ref<MMNode>(val[i]);
if (!e.is_valid()) {
continue;
}
output_properties.push_back(e);
}
}
@ -86,6 +76,10 @@ bool MMNode::render(const Ref<MMMaterial> &material) {
for (int i = 0; i < input_properties.size(); ++i) {
Ref<MMNodeUniversalProperty> p = input_properties[i];
if (!p.is_valid()) {
continue;
}
if (p->get_input_property().is_valid() && p->get_input_property()->get_owner()->get_dirty()) {
return false;
}