mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 03:18:37 +08:00
Merge pull request #30264 from Calinou/add-csg-gizmo-snapping
Implement snapping in the CSG gizmos and 3D polygon editor
This commit is contained in:
commit
8c78a4b78f
@ -346,8 +346,10 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
|
||||
snap_ignore = false;
|
||||
}
|
||||
|
||||
if (!snap_ignore) {
|
||||
cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
|
||||
if (!snap_ignore && SpatialEditor::get_singleton()->is_snap_enabled()) {
|
||||
cpoint = cpoint.snapped(Vector2(
|
||||
SpatialEditor::get_singleton()->get_translate_snap(),
|
||||
SpatialEditor::get_singleton()->get_translate_snap()));
|
||||
}
|
||||
edited_point_pos = cpoint;
|
||||
|
||||
|
@ -120,6 +120,10 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
|
||||
Vector3 ra, rb;
|
||||
Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
|
||||
float d = ra.x;
|
||||
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
|
||||
d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
|
||||
}
|
||||
|
||||
if (d < 0.001)
|
||||
d = 0.001;
|
||||
|
||||
@ -135,6 +139,10 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
|
||||
Vector3 ra, rb;
|
||||
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
|
||||
float d = ra[p_idx];
|
||||
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
|
||||
d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
|
||||
}
|
||||
|
||||
if (d < 0.001)
|
||||
d = 0.001;
|
||||
|
||||
@ -154,6 +162,9 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
|
||||
Vector3 ra, rb;
|
||||
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
|
||||
float d = axis.dot(ra);
|
||||
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
|
||||
d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
|
||||
}
|
||||
|
||||
if (d < 0.001)
|
||||
d = 0.001;
|
||||
@ -173,6 +184,9 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
|
||||
Vector3 ra, rb;
|
||||
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
|
||||
float d = axis.dot(ra);
|
||||
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
|
||||
d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
|
||||
}
|
||||
|
||||
if (d < 0.001)
|
||||
d = 0.001;
|
||||
|
Loading…
Reference in New Issue
Block a user