summaryrefslogtreecommitdiff
path: root/editor/plugins/spatial_editor_plugin.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-07-04 15:06:46 +0200
committerGitHub <noreply@github.com>2018-07-04 15:06:46 +0200
commitdb546732cf5f7b367b88c9008c74f18602167230 (patch)
treecc7324704195d5e40877d21fdf392f0ce0615379 /editor/plugins/spatial_editor_plugin.cpp
parentdb977319329fbd02591bde242093e5821626f3ba (diff)
parente245efaead2a23f717079350637a13d4e74ca8a4 (diff)
Merge pull request #19824 from JFonS/fix_orthogonal_select
Fix selection in 3D orthogonal view
Diffstat (limited to 'editor/plugins/spatial_editor_plugin.cpp')
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 30fff474d7..37b8562e96 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -471,7 +471,11 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_incl
Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
CameraMatrix cm;
- cm.set_perspective(get_fov(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar());
+ if (orthogonal) {
+ cm.set_orthogonal(camera->get_size(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar());
+ } else {
+ cm.set_perspective(get_fov(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar());
+ }
float screen_w, screen_h;
cm.get_viewport_size(screen_w, screen_h);
@@ -518,18 +522,24 @@ void SpatialEditorViewport::_select_region() {
Vector3 a = _get_screen_to_space(box[i]);
Vector3 b = _get_screen_to_space(box[(i + 1) % 4]);
- frustum.push_back(Plane(a, b, cam_pos));
+ if (orthogonal) {
+ frustum.push_back(Plane(a, (a - b).normalized()));
+ } else {
+ frustum.push_back(Plane(a, b, cam_pos));
+ }
}
- Plane near(cam_pos, -_get_camera_normal());
- near.d -= get_znear();
+ if (!orthogonal) {
+ Plane near(cam_pos, -_get_camera_normal());
+ near.d -= get_znear();
- frustum.push_back(near);
+ frustum.push_back(near);
- Plane far = -near;
- far.d += get_zfar();
+ Plane far = -near;
+ far.d += get_zfar();
- frustum.push_back(far);
+ frustum.push_back(far);
+ }
Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario());
Vector<Spatial *> selected;