Direct rotation control, closes #49

This commit is contained in:
2024-09-23 12:21:34 +03:00
parent 7648beb507
commit 1d620a3326
2 changed files with 76 additions and 43 deletions

View File

@@ -94,10 +94,19 @@ private:
"%building_position_y");
LineEdit *position_z = editor->get_as_node<LineEdit>(
"%building_position_z");
LineEdit *position_rot = editor->get_as_node<LineEdit>(
"%building_rotation_y");
Transform xform = editor->get_selected_building_xform();
position_x->set_text(String::num(xform.origin.x));
position_y->set_text(String::num(xform.origin.y));
position_z->set_text(String::num(xform.origin.z));
Vector3 reference(0, 0, -1);
Vector3 rotated =
xform.basis.xform(reference).normalized();
float angle = reference.signed_angle_to(
rotated, Vector3(0, 1, 0));
position_rot->set_text(
String::num(angle * 180.0f / Math_PI));
}
}
void handle_set_cursor()
@@ -122,7 +131,12 @@ private:
editor->get_as_node<LineEdit>("%building_position_y");
LineEdit *position_z =
editor->get_as_node<LineEdit>("%building_position_z");
LineEdit *position_rot =
editor->get_as_node<LineEdit>("%building_rotation_y");
Transform xform = editor->get_selected_building_xform();
xform.basis = Basis().rotated(
Vector3(0, 1, 0),
position_rot->get_text().to_float() * Math_PI / 180.0f);
xform.origin.x = position_x->get_text().to_float();
xform.origin.y = position_y->get_text().to_float();
xform.origin.z = position_z->get_text().to_float();
@@ -155,8 +169,10 @@ private:
editor->get_as_node<LineEdit>("%building_position_y");
LineEdit *position_z =
editor->get_as_node<LineEdit>("%building_position_z");
LineEdit *position_le[] = { position_x, position_y,
position_z };
LineEdit *position_rot =
editor->get_as_node<LineEdit>("%building_rotation_y");
LineEdit *position_le[] = { position_x, position_y, position_z,
position_rot };
Button *set_building_position = editor->get_as_node<Button>(
"%buildings_set_building_position");
int sz_cursor = (int)(sizeof(cursor_le) / sizeof(cursor_le[0]));