Polyline tool - avoids rounding angle when distance is too big.

This commit is contained in:
Bruno Perdigão
2025-10-13 17:43:28 -03:00
parent 300855276f
commit 8647f9c357
+5 -4
View File
@@ -172,23 +172,24 @@ class Polyline(bonsai.core.tool.Polyline):
angle = tool.Cad.angle_3_vectors(
second_to_last_point, last_point, mouse_vector, new_angle=None, degrees=True
)
angle_round_threshold = 1000 # Avoids rounding when distance is too big
# Round angle to the nearest 0.05
angle = round(angle / 0.05) * 0.05
angle = round(angle / 0.05) * 0.05 if distance < angle_round_threshold else angle
orientation_angle = tool.Cad.angle_3_vectors(
world_second_to_last_point, last_point, mouse_vector, new_angle=None, degrees=True
)
# Round angle to the nearest 0.05
orientation_angle = round(orientation_angle / 0.05) * 0.05
orientation_angle = round(orientation_angle / 0.05) * 0.05 if distance < angle_round_threshold else angle
if distance == 0:
angle = 0
orientation_angle = 0
if input_ui:
if should_round:
angle = 5 * round(angle / 5)
angle = 5 * round(angle / 5) if distance < angle_round_threshold else angle
factor = tool.Snap.get_increment_snap_value(context)
distance = factor * round(distance / factor)
input_ui.set_value("X", mouse_vector.x)