fix: edit history ignores preview data
This commit is contained in:
parent
656917f6fc
commit
cd730ac8d4
3 changed files with 15 additions and 9 deletions
|
|
@ -14,7 +14,9 @@ void PointPrimitiveNode::on_underlying_changed() {
|
|||
if (!this->pushing_change && this->is_inside_tree()) {
|
||||
this->pushing_change = true;
|
||||
Vector2 const center{ this->primitive->get_center() };
|
||||
set_global_position({ center.x, this->primitive->get_height(), center.y });
|
||||
Vector3 global_position{ center.x, this->primitive->get_height(), center.y };
|
||||
set_global_position(global_position);
|
||||
this->last_pushed_position = global_position;
|
||||
this->pushing_change = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +44,6 @@ void PointPrimitiveNode::preview_transform_changes() {
|
|||
if (position.y != this->primitive->get_height()) {
|
||||
this->primitive->set_height(position.y);
|
||||
}
|
||||
|
||||
this->pushing_change = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -52,16 +53,18 @@ void PointPrimitiveNode::push_transform_changes() {
|
|||
this->pushing_change = true;
|
||||
Vector3 const position{ get_global_position() };
|
||||
Vector2 const center{ position.x, position.z };
|
||||
if (center != this->primitive->get_center()) {
|
||||
Vector2 last_pushed_center{ this->last_pushed_position.x, last_pushed_position.z };
|
||||
if (center != last_pushed_center) {
|
||||
EditHistory::get_singleton()->push_action(
|
||||
callable_mp(*this->primitive, &PointPrimitive::set_center).bind(center),
|
||||
callable_mp(*this->primitive, &PointPrimitive::set_center).bind(this->primitive->get_center()));
|
||||
callable_mp(*this->primitive, &PointPrimitive::set_center).bind(last_pushed_center));
|
||||
}
|
||||
if (position.y != this->primitive->get_height()) {
|
||||
if (position.y != this->last_pushed_position.y) {
|
||||
EditHistory::get_singleton()->push_action(
|
||||
callable_mp(*this->primitive, &PointPrimitive::set_height).bind(position.y),
|
||||
callable_mp(*this->primitive, &PointPrimitive::set_height).bind(this->primitive->get_height()));
|
||||
callable_mp(*this->primitive, &PointPrimitive::set_height).bind(this->last_pushed_position.y));
|
||||
}
|
||||
this->last_pushed_position = position;
|
||||
this->pushing_change = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public:
|
|||
Ref<PointPrimitive> get_primitive() const;
|
||||
|
||||
private:
|
||||
Vector3 last_pushed_position{};
|
||||
bool pushing_change{ false };
|
||||
Ref<PointPrimitive> primitive{};
|
||||
Callable underlying_changed_callable{ callable_mp(this, &self_type::on_underlying_changed) };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue