Skip to content

Commit

Permalink
Merge pull request #53354 from reduz/remove-clipped-camera
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Oct 4, 2021
2 parents bb201c5 + b11bb59 commit 7722048
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 418 deletions.
8 changes: 7 additions & 1 deletion doc/classes/Camera3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<method name="get_camera_transform" qualifiers="const">
<return type="Transform3D" />
<description>
Returns the transform of the camera plus the vertical ([member v_offset]) and horizontal ([member h_offset]) offsets; and any other adjustments made to the position and orientation of the camera by subclassed cameras such as [ClippedCamera3D] and [XRCamera3D].
Returns the transform of the camera plus the vertical ([member v_offset]) and horizontal ([member h_offset]) offsets; and any other adjustments made to the position and orientation of the camera by subclassed cameras such as [XRCamera3D].
</description>
</method>
<method name="get_cull_mask_value" qualifiers="const">
Expand All @@ -42,6 +42,12 @@
Returns the camera's frustum planes in world space units as an array of [Plane]s in the following order: near, far, left, top, right, bottom. Not to be confused with [member frustum_offset].
</description>
</method>
<method name="get_pyramid_shape_rid">
<return type="RID" />
<description>
Returns the RID of a pyramid shape encompassing the camera's view frustum, ignoring the camera's near plane. The tip of the pyramid represents the position of the camera.
</description>
</method>
<method name="is_position_behind" qualifiers="const">
<return type="bool" />
<argument index="0" name="world_point" type="Vector3" />
Expand Down
93 changes: 0 additions & 93 deletions doc/classes/ClippedCamera3D.xml

This file was deleted.

41 changes: 0 additions & 41 deletions editor/plugins/node_3d_editor_gizmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1840,47 +1840,6 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {

p_gizmo->add_lines(lines, material);
p_gizmo->add_handles(handles, get_material("handles"));

ClippedCamera3D *clipcam = Object::cast_to<ClippedCamera3D>(camera);
if (clipcam) {
Node3D *parent = Object::cast_to<Node3D>(camera->get_parent());
if (!parent) {
return;
}
Vector3 cam_normal = -camera->get_global_transform().basis.get_axis(Vector3::AXIS_Z).normalized();
Vector3 cam_x = camera->get_global_transform().basis.get_axis(Vector3::AXIS_X).normalized();
Vector3 cam_y = camera->get_global_transform().basis.get_axis(Vector3::AXIS_Y).normalized();
Vector3 cam_pos = camera->get_global_transform().origin;
Vector3 parent_pos = parent->get_global_transform().origin;

Plane parent_plane(parent_pos, cam_normal);
Vector3 ray_from = parent_plane.project(cam_pos);

lines.clear();
lines.push_back(ray_from + cam_x * 0.5 + cam_y * 0.5);
lines.push_back(ray_from + cam_x * 0.5 + cam_y * -0.5);

lines.push_back(ray_from + cam_x * 0.5 + cam_y * -0.5);
lines.push_back(ray_from + cam_x * -0.5 + cam_y * -0.5);

lines.push_back(ray_from + cam_x * -0.5 + cam_y * -0.5);
lines.push_back(ray_from + cam_x * -0.5 + cam_y * 0.5);

lines.push_back(ray_from + cam_x * -0.5 + cam_y * 0.5);
lines.push_back(ray_from + cam_x * 0.5 + cam_y * 0.5);

if (parent_plane.distance_to(cam_pos) < 0) {
lines.push_back(ray_from);
lines.push_back(cam_pos);
}

Transform3D local = camera->get_global_transform().affine_inverse();
for (int i = 0; i < lines.size(); i++) {
lines.write[i] = local.xform(lines[i]);
}

p_gizmo->add_lines(lines, material);
}
}

//////
Expand Down
Loading

0 comments on commit 7722048

Please sign in to comment.