fix: edit history ignores preview data
This commit is contained in:
parent
656917f6fc
commit
cd730ac8d4
|
|
@ -14,7 +14,9 @@ void PointPrimitiveNode::on_underlying_changed() {
|
||||||
if (!this->pushing_change && this->is_inside_tree()) {
|
if (!this->pushing_change && this->is_inside_tree()) {
|
||||||
this->pushing_change = true;
|
this->pushing_change = true;
|
||||||
Vector2 const center{ this->primitive->get_center() };
|
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;
|
this->pushing_change = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +44,6 @@ void PointPrimitiveNode::preview_transform_changes() {
|
||||||
if (position.y != this->primitive->get_height()) {
|
if (position.y != this->primitive->get_height()) {
|
||||||
this->primitive->set_height(position.y);
|
this->primitive->set_height(position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->pushing_change = false;
|
this->pushing_change = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,16 +53,18 @@ void PointPrimitiveNode::push_transform_changes() {
|
||||||
this->pushing_change = true;
|
this->pushing_change = true;
|
||||||
Vector3 const position{ get_global_position() };
|
Vector3 const position{ get_global_position() };
|
||||||
Vector2 const center{ position.x, position.z };
|
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(
|
EditHistory::get_singleton()->push_action(
|
||||||
callable_mp(*this->primitive, &PointPrimitive::set_center).bind(center),
|
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(
|
EditHistory::get_singleton()->push_action(
|
||||||
callable_mp(*this->primitive, &PointPrimitive::set_height).bind(position.y),
|
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;
|
this->pushing_change = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ public:
|
||||||
Ref<PointPrimitive> get_primitive() const;
|
Ref<PointPrimitive> get_primitive() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Vector3 last_pushed_position{};
|
||||||
bool pushing_change{ false };
|
bool pushing_change{ false };
|
||||||
Ref<PointPrimitive> primitive{};
|
Ref<PointPrimitive> primitive{};
|
||||||
Callable underlying_changed_callable{ callable_mp(this, &self_type::on_underlying_changed) };
|
Callable underlying_changed_callable{ callable_mp(this, &self_type::on_underlying_changed) };
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ script/source = "extends Area3D
|
||||||
|
|
||||||
var dragged : bool = false
|
var dragged : bool = false
|
||||||
var slope_adjusted : float = 0.0
|
var slope_adjusted : float = 0.0
|
||||||
|
var slope_pre_adjusted : float = 0.0
|
||||||
var refresh_time : float
|
var refresh_time : float
|
||||||
@onready
|
@onready
|
||||||
var parent = get_parent() as PointPrimitiveNode
|
var parent = get_parent() as PointPrimitiveNode
|
||||||
|
|
@ -65,8 +66,8 @@ func _input(event: InputEvent) -> void:
|
||||||
dragged = false
|
dragged = false
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
EditHistory.push_action(
|
EditHistory.push_action(
|
||||||
$\"..\".get_primitive().set.bind(\"slope\", slope_adjusted),
|
parent.get_primitive().set.bind(\"slope\", slope_adjusted),
|
||||||
$\"..\".get_primitive().set.bind(\"slope\", $\"..\".get_primitive().slope)
|
parent.get_primitive().set.bind(\"slope\", slope_pre_adjusted)
|
||||||
)
|
)
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
elif event is InputEventMouseMotion:
|
elif event is InputEventMouseMotion:
|
||||||
|
|
@ -78,7 +79,8 @@ func _input_event(_camera: Camera3D, event: InputEvent, _event_position: Vector3
|
||||||
if not dragged and event is InputEventMouseButton and (event as InputEventMouseButton).is_pressed():
|
if not dragged and event is InputEventMouseButton and (event as InputEventMouseButton).is_pressed():
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
dragged = true
|
dragged = true
|
||||||
slope_adjusted = $\"..\".get_primitive().slope
|
slope_adjusted = parent.get_primitive().slope
|
||||||
|
slope_pre_adjusted = slope_adjusted
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue