feat(wip): implementing edit history and un-re-do

This commit is contained in:
Sara Gerretsen 2025-11-20 23:33:46 +01:00
parent b875c2089b
commit e2926f7c3f
6 changed files with 90 additions and 3 deletions

View file

@ -1,6 +1,8 @@
#include "point_primitive_node.h"
#include "scene/3d/node_3d.h"
#include "terrain_editor/edit_history.h"
#include "terrain_editor/macros.h"
#include "terrain_editor/terrain_primitive.h"
void PointPrimitiveNode::_bind_methods() {
BIND_GET_SET(primitive);
@ -32,8 +34,17 @@ void PointPrimitiveNode::push_transform_changes() {
if (this->primitive.is_valid()) {
this->pushing_change = true;
Vector3 const position{ get_global_position() };
this->primitive->set_center({ position.x, position.z });
this->primitive->set_height(position.y);
Vector2 const center{ position.x, position.z };
if (center != this->primitive->get_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()));
}
if (position.y != this->primitive->get_height()) {
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()));
}
this->pushing_change = false;
}
}