Skip to content

Commit 9f1ce63

Browse files
committed
Merge pull request godotengine#91109 from kleonc/path3d-tilt-gizmo-ray-against-global-plane
Fix `Path3D` tilt gizmo raycasting against local plane
2 parents de99334 + 0c8275b commit 9f1ce63

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

editor/plugins/path_3d_editor_plugin.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,17 @@ void Path3DGizmo::set_handle(int p_id, bool p_secondary, Camera3D *p_camera, con
169169
const Basis posture = c->get_point_baked_posture(idx);
170170
const Vector3 tangent = -posture.get_column(2);
171171
const Vector3 up = posture.get_column(1);
172-
const Plane p_tilt = Plane(tangent, position);
172+
const Plane tilt_plane_global = gt.xform(Plane(tangent, position));
173173

174174
Vector3 intersection;
175175

176-
if (p_tilt.intersects_ray(ray_from, ray_dir, &intersection)) {
177-
Vector3 direction = intersection - position;
178-
direction.normalize(); // FIXME: redundant?
176+
if (tilt_plane_global.intersects_ray(ray_from, ray_dir, &intersection)) {
177+
Vector3 direction = gi.xform(intersection) - position;
179178
real_t tilt_angle = up.signed_angle_to(direction, tangent);
180179

181180
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
182-
real_t snap = Node3DEditor::get_singleton()->get_rotate_snap();
183-
184-
tilt_angle = Math::rad_to_deg(tilt_angle) + snap * 0.5; // Else it won't reach +180.
185-
tilt_angle -= Math::fmod(tilt_angle, snap);
186-
tilt_angle = Math::deg_to_rad(tilt_angle);
181+
real_t snap_degrees = Node3DEditor::get_singleton()->get_rotate_snap();
182+
tilt_angle = Math::deg_to_rad(Math::snapped(Math::rad_to_deg(tilt_angle), snap_degrees));
187183
}
188184

189185
c->set_point_tilt(idx, tilt_angle);

0 commit comments

Comments
 (0)