feat: implemented live refresh

This commit is contained in:
Sara Gerretsen 2025-12-08 22:21:28 +01:00
parent bab106eeea
commit 7ed438bcb2
3 changed files with 53 additions and 4 deletions

View file

@ -7,6 +7,7 @@
void PointPrimitiveNode::_bind_methods() {
BIND_GET_SET(primitive);
ClassDB::bind_method(D_METHOD("push_transform_changes"), &self_type::push_transform_changes);
ClassDB::bind_method(D_METHOD("preview_transform_changes"), &self_type::preview_transform_changes);
}
void PointPrimitiveNode::on_underlying_changed() {
@ -30,6 +31,22 @@ void PointPrimitiveNode::_notification(int what) {
}
}
void PointPrimitiveNode::preview_transform_changes() {
if (this->primitive.is_valid()) {
this->pushing_change = true;
Vector3 const position{ get_global_position() };
Vector2 const center{ position.x, position.z };
if (center != this->primitive->get_center()) {
this->primitive->set_center(center);
}
if (position.y != this->primitive->get_height()) {
this->primitive->set_height(position.y);
}
this->pushing_change = false;
}
}
void PointPrimitiveNode::push_transform_changes() {
if (this->primitive.is_valid()) {
this->pushing_change = true;

View file

@ -12,6 +12,7 @@ protected:
void _notification(int what);
public:
void preview_transform_changes();
void push_transform_changes();
void set_primitive(Ref<PointPrimitive> primitive);
Ref<PointPrimitive> get_primitive() const;