diff options
| author | Rémi Verschelde | 2017-10-22 12:06:00 +0200 |
|---|---|---|
| committer | GitHub | 2017-10-22 12:06:00 +0200 |
| commit | 99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f (patch) | |
| tree | f7810fc7be2c4eee2b0ec3bf4795f1930fd6f7ce /editor/plugins/spatial_editor_plugin.cpp | |
| parent | bc667aeada757463fbb562eb262d404968f0ca37 (diff) | |
| parent | 2e22c07f4261625834bd0d16aa5e09005666ab14 (diff) | |
| download | godot-99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f.tar.gz godot-99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f.tar.zst godot-99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f.zip | |
Diffstat (limited to 'editor/plugins/spatial_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 547679b05..f96cbabde 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2894,7 +2894,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P if (parent_spatial) global_transform = parent_spatial->get_global_transform(); - global_transform.origin = _get_instance_position(p_point); + global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point)); editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform); @@ -4834,6 +4834,15 @@ void SpatialEditor::snap_cursor_to_plane(const Plane &p_plane) { //cursor.pos=p_plane.project(cursor.pos); } +Vector3 SpatialEditor::snap_point(Vector3 p_target, Vector3 p_start) const { + if (is_snap_enabled()) { + p_target.x = Math::snap_scalar(0.0, get_translate_snap(), p_target.x); + p_target.y = Math::snap_scalar(0.0, get_translate_snap(), p_target.y); + p_target.z = Math::snap_scalar(0.0, get_translate_snap(), p_target.z); + } + return p_target; +} + void SpatialEditorPlugin::_bind_methods() { ClassDB::bind_method("snap_cursor_to_plane", &SpatialEditorPlugin::snap_cursor_to_plane); |
