Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e360ab6

Browse files
otonashixavDxUr
authored andcommittedMar 23, 2024·
Add Camera3d custom projection gizmo.
1 parent 18bb7b1 commit e360ab6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
 

‎editor/plugins/gizmos/camera_3d_gizmo_plugin.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,23 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
255255
} break;
256256

257257
case Camera3D::PROJECTION_CUSTOM: {
258-
// Show Nothing
258+
// An inaccurate, but sufficient representation of the custom projection
259+
Vector3 endpoints[8];
260+
Projection proj = camera->get_custom_projection();
261+
proj.get_endpoints(
262+
Transform3D(Basis(Vector3(size_factor.x, 0, 0), Vector3(0, size_factor.y, 0), Vector3(0, 0, 1)) / proj.get_z_far()),
263+
endpoints);
264+
265+
ADD_QUAD(endpoints[0], endpoints[1], endpoints[5], endpoints[4]);
266+
ADD_QUAD(endpoints[2], endpoints[3], endpoints[7], endpoints[6]);
267+
ADD_QUAD(endpoints[0], endpoints[2], endpoints[6], endpoints[4]);
268+
ADD_QUAD(endpoints[1], endpoints[3], endpoints[7], endpoints[5]);
269+
270+
Vector3 top_left_to_top_right = endpoints[2] - endpoints[0];
271+
Vector3 up = Vector3(0, 0, 0.2).cross(top_left_to_top_right);
272+
ADD_TRIANGLE(endpoints[0] + top_left_to_top_right * 0.4,
273+
endpoints[0] + top_left_to_top_right * 0.6,
274+
endpoints[0] + top_left_to_top_right * 0.5 + up);
259275
} break;
260276
}
261277

‎scene/3d/camera_3d.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ void Camera3D::set_custom(Projection p_proj) {
279279
};
280280

281281
for (int i = 0; i < 8; i++) {
282-
Vector3 point;
283282
Plane a = planes[intersections[i][0]];
284283
Plane b = planes[intersections[i][1]];
285284
Plane c = planes[intersections[i][2]];

0 commit comments

Comments
 (0)
Please sign in to comment.