You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Merge pull request #36887 from MCrafterzz/relativeSnap
Made snap relative work on rotation as well
This commit is contained in:
@@ -462,7 +462,15 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
|
|||||||
}
|
}
|
||||||
|
|
||||||
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
|
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
|
||||||
return (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) ? Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset : p_target;
|
if (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) {
|
||||||
|
if (snap_relative) {
|
||||||
|
return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step);
|
||||||
|
} else {
|
||||||
|
return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return p_target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||||
|
|||||||
Reference in New Issue
Block a user