summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaohua Xiong <xiongyaohua@gmail.com>2023-11-28 10:48:15 +0800
committerYaohua Xiong <xiongyaohua@gmail.com>2024-01-08 18:29:18 +0800
commit0e344f0d0bec80f26295ac7bd1a093b32bd904a2 (patch)
treee93ef5e4a5f8554c46edf94336855086d284cd58
parentc8c483cf57a768110fce57e509f9b855e69d34b7 (diff)
downloadredot-engine-0e344f0d0bec80f26295ac7bd1a093b32bd904a2.tar.gz
Path3D notify transform change to CSGPolygon
-rw-r--r--modules/csg/csg_shape.cpp2
-rw-r--r--scene/3d/path_3d.cpp12
-rw-r--r--scene/3d/path_3d.h10
3 files changed, 18 insertions, 6 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 6082b468f7..970cdcb366 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -1826,11 +1826,13 @@ CSGBrush *CSGPolygon3D::_build_brush() {
if (path) {
path->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
path->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
+ path->set_update_callback(Callable());
}
path = current_path;
if (path) {
path->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
path->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
+ path->set_update_callback(callable_mp(this, &CSGPolygon3D::_path_changed));
}
}
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index e38375d339..c42c43be94 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -50,6 +50,10 @@ Path3D::~Path3D() {
}
}
+void Path3D::set_update_callback(Callable p_callback) {
+ update_callback = p_callback;
+}
+
void Path3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -67,8 +71,12 @@ void Path3D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (is_inside_tree() && debug_instance.is_valid()) {
- RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
+ if (is_inside_tree()) {
+ if (debug_instance.is_valid()) {
+ RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
+ }
+
+ update_callback.call();
}
} break;
}
diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h
index 6116e98054..4a75954beb 100644
--- a/scene/3d/path_3d.h
+++ b/scene/3d/path_3d.h
@@ -37,15 +37,15 @@
class Path3D : public Node3D {
GDCLASS(Path3D, Node3D);
+private:
Ref<Curve3D> curve;
-
- void _curve_changed();
-
RID debug_instance;
Ref<ArrayMesh> debug_mesh;
-private:
+ Callable update_callback; // Used only by CSG currently.
+
void _update_debug_mesh();
+ void _curve_changed();
protected:
void _notification(int p_what);
@@ -53,6 +53,8 @@ protected:
static void _bind_methods();
public:
+ void set_update_callback(Callable p_callback);
+
void set_curve(const Ref<Curve3D> &p_curve);
Ref<Curve3D> get_curve() const;