Adjust orthographic camera gizmo with respect to "keep_aspect" setting
This commit is contained in:
parent
d00734053f
commit
b97d995664
@ -112,9 +112,12 @@ void Camera3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id,
|
||||
float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2);
|
||||
camera->set("fov", CLAMP(a * 2.0, 1, 179));
|
||||
} else {
|
||||
Camera3D::KeepAspect aspect = camera->get_keep_aspect_mode();
|
||||
Vector3 far = aspect == Camera3D::KeepAspect::KEEP_WIDTH ? Vector3(4096, 0, -1) : Vector3(0, 4096, -1);
|
||||
|
||||
Vector3 ra, rb;
|
||||
Geometry3D::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb);
|
||||
float d = ra.x * 2;
|
||||
Geometry3D::get_closest_points_between_segments(Vector3(0, 0, -1), far, s[0], s[1], ra, rb);
|
||||
float d = aspect == Camera3D::KeepAspect::KEEP_WIDTH ? ra.x * 2 : ra.y * 2;
|
||||
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
|
||||
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
|
||||
}
|
||||
@ -213,25 +216,33 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
} break;
|
||||
|
||||
case Camera3D::PROJECTION_ORTHOGONAL: {
|
||||
float size = camera->get_size();
|
||||
Camera3D::KeepAspect aspect = camera->get_keep_aspect_mode();
|
||||
|
||||
float hsize = size * 0.5;
|
||||
Vector3 right(hsize * size_factor.x, 0, 0);
|
||||
Vector3 up(0, hsize * size_factor.y, 0);
|
||||
float size = camera->get_size();
|
||||
float keep_size = size * 0.5;
|
||||
|
||||
Vector3 right, up;
|
||||
Vector3 back(0, 0, -1.0);
|
||||
Vector3 front(0, 0, 0);
|
||||
|
||||
if (aspect == Camera3D::KeepAspect::KEEP_WIDTH) {
|
||||
right = Vector3(keep_size, 0, 0);
|
||||
up = Vector3(0, keep_size / viewport_aspect, 0);
|
||||
handles.push_back(right + back);
|
||||
} else {
|
||||
right = Vector3(keep_size * viewport_aspect, 0, 0);
|
||||
up = Vector3(0, keep_size, 0);
|
||||
handles.push_back(up + back);
|
||||
}
|
||||
|
||||
ADD_QUAD(-up - right, -up + right, up + right, up - right);
|
||||
ADD_QUAD(-up - right + back, -up + right + back, up + right + back, up - right + back);
|
||||
ADD_QUAD(up + right, up + right + back, up - right + back, up - right);
|
||||
ADD_QUAD(-up + right, -up + right + back, -up - right + back, -up - right);
|
||||
|
||||
handles.push_back(right + back);
|
||||
|
||||
right.x = MIN(right.x, hsize * 0.25);
|
||||
Vector3 tup(0, up.y + hsize / 2, back.z);
|
||||
right.x = MIN(right.x, keep_size * 0.25);
|
||||
Vector3 tup(0, up.y + keep_size / 2, back.z);
|
||||
ADD_TRIANGLE(tup, right + up + back, -right + up + back);
|
||||
|
||||
} break;
|
||||
|
||||
case Camera3D::PROJECTION_FRUSTUM: {
|
||||
|
Loading…
Reference in New Issue
Block a user