Path3D notify transform change to CSGPolygon
This commit is contained in:
parent
c8c483cf57
commit
0e344f0d0b
3 changed files with 18 additions and 6 deletions
|
@ -1826,11 +1826,13 @@ CSGBrush *CSGPolygon3D::_build_brush() {
|
||||||
if (path) {
|
if (path) {
|
||||||
path->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
|
path->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
|
||||||
path->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
|
path->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
|
||||||
|
path->set_update_callback(Callable());
|
||||||
}
|
}
|
||||||
path = current_path;
|
path = current_path;
|
||||||
if (path) {
|
if (path) {
|
||||||
path->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
|
path->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
|
||||||
path->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
|
path->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
|
||||||
|
path->set_update_callback(callable_mp(this, &CSGPolygon3D::_path_changed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,10 @@ Path3D::~Path3D() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Path3D::set_update_callback(Callable p_callback) {
|
||||||
|
update_callback = p_callback;
|
||||||
|
}
|
||||||
|
|
||||||
void Path3D::_notification(int p_what) {
|
void Path3D::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
@ -67,9 +71,13 @@ void Path3D::_notification(int p_what) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||||
if (is_inside_tree() && debug_instance.is_valid()) {
|
if (is_inside_tree()) {
|
||||||
|
if (debug_instance.is_valid()) {
|
||||||
RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
|
RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_callback.call();
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,15 +37,15 @@
|
||||||
class Path3D : public Node3D {
|
class Path3D : public Node3D {
|
||||||
GDCLASS(Path3D, Node3D);
|
GDCLASS(Path3D, Node3D);
|
||||||
|
|
||||||
|
private:
|
||||||
Ref<Curve3D> curve;
|
Ref<Curve3D> curve;
|
||||||
|
|
||||||
void _curve_changed();
|
|
||||||
|
|
||||||
RID debug_instance;
|
RID debug_instance;
|
||||||
Ref<ArrayMesh> debug_mesh;
|
Ref<ArrayMesh> debug_mesh;
|
||||||
|
|
||||||
private:
|
Callable update_callback; // Used only by CSG currently.
|
||||||
|
|
||||||
void _update_debug_mesh();
|
void _update_debug_mesh();
|
||||||
|
void _curve_changed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
@ -53,6 +53,8 @@ protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void set_update_callback(Callable p_callback);
|
||||||
|
|
||||||
void set_curve(const Ref<Curve3D> &p_curve);
|
void set_curve(const Ref<Curve3D> &p_curve);
|
||||||
Ref<Curve3D> get_curve() const;
|
Ref<Curve3D> get_curve() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue