diff --git a/modules/paint/nodes/paint_node.cpp b/modules/paint/nodes/paint_node.cpp index 7bb5d705a..07ad1e60a 100644 --- a/modules/paint/nodes/paint_node.cpp +++ b/modules/paint/nodes/paint_node.cpp @@ -67,17 +67,26 @@ Ref PaintNode::_get_rendered_image() { return Ref(); } +bool PaintNode::render_should_evaluate_children() { + return call("_render_should_evaluate_children"); +} +bool PaintNode::_render_should_evaluate_children() { + return true; +} + void PaintNode::render_evaluate_paint_node(PaintNode *node, Transform2D transform, Ref image) { ERR_FAIL_COND(!node); ERR_FAIL_COND(!image.is_valid()); Transform2D currtf = transform * node->get_transform(); - for (int i = 0; i < node->get_child_count(); ++i) { - PaintNode *pn = Object::cast_to(node->get_child(i)); + if (node->render_should_evaluate_children()) { + for (int i = 0; i < node->get_child_count(); ++i) { + PaintNode *pn = Object::cast_to(node->get_child(i)); - if (pn && pn->is_visible()) { - render_evaluate_paint_node(pn, currtf, image); + if (pn && pn->is_visible()) { + render_evaluate_paint_node(pn, currtf, image); + } } } @@ -290,6 +299,10 @@ void PaintNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rendered_image"), &PaintNode::get_rendered_image); ClassDB::bind_method(D_METHOD("_get_rendered_image"), &PaintNode::_get_rendered_image); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "r"), "_render_should_evaluate_children")); + ClassDB::bind_method(D_METHOD("render_should_evaluate_children"), &PaintNode::render_should_evaluate_children); + ClassDB::bind_method(D_METHOD("_render_should_evaluate_children"), &PaintNode::_render_should_evaluate_children); + ClassDB::bind_method(D_METHOD("util_get_pixels_in_line", "from", "to"), &PaintNode::util_get_pixels_in_line); ClassDB::bind_method(D_METHOD("util_to_1d_v", "p", "w"), &PaintNode::util_to_1d_v); diff --git a/modules/paint/nodes/paint_node.h b/modules/paint/nodes/paint_node.h index 5efefff51..397711b9a 100644 --- a/modules/paint/nodes/paint_node.h +++ b/modules/paint/nodes/paint_node.h @@ -29,6 +29,9 @@ public: Ref get_rendered_image(); virtual Ref _get_rendered_image(); + bool render_should_evaluate_children(); + virtual bool _render_should_evaluate_children(); + void render_evaluate_paint_node(PaintNode *node, Transform2D transform, Ref image); void render_paint_node(PaintNode *node, Transform2D transform, Ref image); diff --git a/modules/paint/nodes/paint_project.cpp b/modules/paint/nodes/paint_project.cpp index d7c35df97..128fcbec3 100644 --- a/modules/paint/nodes/paint_project.cpp +++ b/modules/paint/nodes/paint_project.cpp @@ -94,6 +94,10 @@ void PaintProject::add_paint_visual_grid() { } } +bool PaintProject::_render_should_evaluate_children() { + return false; +} + PaintProject::PaintProject() { _current_color = Color(1, 1, 1, 1); } diff --git a/modules/paint/nodes/paint_project.h b/modules/paint/nodes/paint_project.h index 1abd867cf..1532f5112 100644 --- a/modules/paint/nodes/paint_project.h +++ b/modules/paint/nodes/paint_project.h @@ -31,6 +31,8 @@ public: void add_paint_canvas_backgorund(); void add_paint_visual_grid(); + bool _render_should_evaluate_children(); + PaintProject(); ~PaintProject();