|
@@ -651,13 +651,13 @@ void Node3DEditorViewport::_select_region() {
|
|
|
Vector3 a = _get_screen_to_space(box[i]);
|
|
|
Vector3 b = _get_screen_to_space(box[(i + 1) % 4]);
|
|
|
if (orthogonal) {
|
|
|
- frustum.push_back(Plane(a, (a - b).normalized()));
|
|
|
+ frustum.push_back(Plane((a - b).normalized(), a));
|
|
|
} else {
|
|
|
frustum.push_back(Plane(a, b, cam_pos));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Plane near(cam_pos, -_get_camera_normal());
|
|
|
+ Plane near(-_get_camera_normal(), cam_pos);
|
|
|
near.d -= get_znear();
|
|
|
frustum.push_back(near);
|
|
|
|
|
@@ -972,7 +972,7 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b
|
|
|
const Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gizmo_scale * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST * 0.6667);
|
|
|
|
|
|
Vector3 r;
|
|
|
- Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
|
|
|
+ Plane plane(gt.basis.get_axis(i).normalized(), gt.origin);
|
|
|
|
|
|
if (plane.intersects_ray(ray_pos, ray, &r)) {
|
|
|
const real_t dist = r.distance_to(grabber_pos);
|
|
@@ -1010,7 +1010,7 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b
|
|
|
float col_d = 1e20;
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
- Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
|
|
|
+ Plane plane(gt.basis.get_axis(i).normalized(), gt.origin);
|
|
|
Vector3 r;
|
|
|
if (!plane.intersects_ray(ray_pos, ray, &r)) {
|
|
|
continue;
|
|
@@ -1076,7 +1076,7 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b
|
|
|
const Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gizmo_scale * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST * 0.6667);
|
|
|
|
|
|
Vector3 r;
|
|
|
- Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
|
|
|
+ Plane plane(gt.basis.get_axis(i).normalized(), gt.origin);
|
|
|
|
|
|
if (plane.intersects_ray(ray_pos, ray, &r)) {
|
|
|
const real_t dist = r.distance_to(grabber_pos);
|
|
@@ -1761,33 +1761,33 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|
|
switch (_edit.plane) {
|
|
|
case TRANSFORM_VIEW:
|
|
|
motion_mask = Vector3(0, 0, 0);
|
|
|
- plane = Plane(_edit.center, _get_camera_normal());
|
|
|
+ plane = Plane(_get_camera_normal(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_X_AXIS:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0);
|
|
|
- plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
|
|
|
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_Y_AXIS:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1);
|
|
|
- plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
|
|
|
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_Z_AXIS:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2);
|
|
|
- plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
|
|
|
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_YZ:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1);
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0), _edit.center);
|
|
|
plane_mv = true;
|
|
|
break;
|
|
|
case TRANSFORM_XZ:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0);
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1), _edit.center);
|
|
|
plane_mv = true;
|
|
|
break;
|
|
|
case TRANSFORM_XY:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1);
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2), _edit.center);
|
|
|
plane_mv = true;
|
|
|
break;
|
|
|
}
|
|
@@ -1882,30 +1882,30 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
switch (_edit.plane) {
|
|
|
case TRANSFORM_VIEW:
|
|
|
- plane = Plane(_edit.center, _get_camera_normal());
|
|
|
+ plane = Plane(_get_camera_normal(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_X_AXIS:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0);
|
|
|
- plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
|
|
|
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_Y_AXIS:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1);
|
|
|
- plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
|
|
|
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_Z_AXIS:
|
|
|
motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2);
|
|
|
- plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
|
|
|
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_YZ:
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0), _edit.center);
|
|
|
plane_mv = true;
|
|
|
break;
|
|
|
case TRANSFORM_XZ:
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1), _edit.center);
|
|
|
plane_mv = true;
|
|
|
break;
|
|
|
case TRANSFORM_XY:
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2), _edit.center);
|
|
|
plane_mv = true;
|
|
|
break;
|
|
|
}
|
|
@@ -1978,18 +1978,18 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
switch (_edit.plane) {
|
|
|
case TRANSFORM_VIEW:
|
|
|
- plane = Plane(_edit.center, _get_camera_normal());
|
|
|
+ plane = Plane(_get_camera_normal(), _edit.center);
|
|
|
break;
|
|
|
case TRANSFORM_X_AXIS:
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0), _edit.center);
|
|
|
axis = Vector3(1, 0, 0);
|
|
|
break;
|
|
|
case TRANSFORM_Y_AXIS:
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1), _edit.center);
|
|
|
axis = Vector3(0, 1, 0);
|
|
|
break;
|
|
|
case TRANSFORM_Z_AXIS:
|
|
|
- plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2));
|
|
|
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2), _edit.center);
|
|
|
axis = Vector3(0, 0, 1);
|
|
|
break;
|
|
|
case TRANSFORM_YZ:
|
|
@@ -3588,7 +3588,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
|
|
|
|
|
|
const Vector3 camz = -camera_xform.get_basis().get_axis(2).normalized();
|
|
|
const Vector3 camy = -camera_xform.get_basis().get_axis(1).normalized();
|
|
|
- const Plane p(camera_xform.origin, camz);
|
|
|
+ const Plane p = Plane(camz, camera_xform.origin);
|
|
|
const real_t gizmo_d = MAX(Math::abs(p.distance_to(xform.origin)), CMP_EPSILON);
|
|
|
const real_t d0 = camera->unproject_position(camera_xform.origin + camz * gizmo_d).y;
|
|
|
const real_t d1 = camera->unproject_position(camera_xform.origin + camz * gizmo_d + camy).y;
|
|
@@ -6171,7 +6171,7 @@ void Node3DEditor::_init_grid() {
|
|
|
if (orthogonal) {
|
|
|
camera_distance = camera->get_size() / 2.0;
|
|
|
Vector3 camera_direction = -camera->get_global_transform().get_basis().get_axis(2);
|
|
|
- Plane grid_plane = Plane(Vector3(), normal);
|
|
|
+ Plane grid_plane = Plane(normal);
|
|
|
Vector3 intersection;
|
|
|
if (grid_plane.intersects_ray(camera_position, camera_direction, &intersection)) {
|
|
|
camera_position = intersection;
|