summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-10-20 12:43:02 +0200
committerGitHub <noreply@github.com>2017-10-20 12:43:02 +0200
commiteacdcd7239a52ecb378b752bfd529d4f1f7b3957 (patch)
tree997071c57889d4d4cfeb8f59977215035ba75d96
parent84251d7aec34709d9ab89390e9576a05ab925127 (diff)
parentc566899dcf81d452d975d72ab8e0d07eb0510337 (diff)
Merge pull request #12206 from SaracenOne/drag_and_drop_fix
Fix drag and drop collision with non-centred origin points. [ci skip]
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 703c9e96b6..547679b056 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2765,8 +2765,14 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const
normal = hit_normal;
}
}
- Vector3 center = preview_bounds->get_size() * 0.5;
- return point + (center * normal);
+ Vector3 offset = Vector3();
+ for (int i = 0; i < 3; i++) {
+ if (normal[i] > 0.0)
+ offset[i] = (preview_bounds->get_size()[i] - (preview_bounds->get_size()[i] + preview_bounds->get_position()[i]));
+ else if (normal[i] < 0.0)
+ offset[i] = -(preview_bounds->get_size()[i] + preview_bounds->get_position()[i]);
+ }
+ return point + offset;
}
Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) {