mirror of
https://github.com/godotengine/godot.git
synced 2024-11-11 14:43:44 +00:00
Merge pull request #44434 from madmiraal/rename-camera3d-near-and-far
Rename Camera3D near and far getters and setters
This commit is contained in:
commit
8f4c4bb610
@ -189,7 +189,7 @@
|
||||
<member name="environment" type="Environment" setter="set_environment" getter="get_environment">
|
||||
The [Environment] to use for this camera.
|
||||
</member>
|
||||
<member name="far" type="float" setter="set_zfar" getter="get_zfar" default="4000.0">
|
||||
<member name="far" type="float" setter="set_far" getter="get_far" default="4000.0">
|
||||
The distance to the far culling boundary for this camera relative to its local Z axis.
|
||||
</member>
|
||||
<member name="fov" type="float" setter="set_fov" getter="get_fov" default="75.0">
|
||||
@ -209,7 +209,7 @@
|
||||
<member name="keep_aspect" type="int" setter="set_keep_aspect_mode" getter="get_keep_aspect_mode" enum="Camera3D.KeepAspect" default="1">
|
||||
The axis to lock during [member fov]/[member size] adjustments. Can be either [constant KEEP_WIDTH] or [constant KEEP_HEIGHT].
|
||||
</member>
|
||||
<member name="near" type="float" setter="set_znear" getter="get_znear" default="0.05">
|
||||
<member name="near" type="float" setter="set_near" getter="get_near" default="0.05">
|
||||
The distance to the near culling boundary for this camera relative to its local Z axis.
|
||||
</member>
|
||||
<member name="projection" type="int" setter="set_projection" getter="get_projection" enum="Camera3D.Projection" default="0">
|
||||
|
@ -802,8 +802,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
||||
msg.push_back(true);
|
||||
msg.push_back(cam->get_fov());
|
||||
}
|
||||
msg.push_back(cam->get_znear());
|
||||
msg.push_back(cam->get_zfar());
|
||||
msg.push_back(cam->get_near());
|
||||
msg.push_back(cam->get_far());
|
||||
_put_msg("scene:override_camera_3D:transform", msg);
|
||||
}
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
|
||||
tcp = a;
|
||||
}
|
||||
|
||||
if (camp.distance_to(tcp) < p_camera->get_znear()) {
|
||||
if (camp.distance_to(tcp) < p_camera->get_near()) {
|
||||
continue;
|
||||
}
|
||||
cp = tcp;
|
||||
@ -1357,7 +1357,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
case Camera3D::PROJECTION_FRUSTUM: {
|
||||
float hsize = camera->get_size() / 2.0;
|
||||
|
||||
Vector3 side = Vector3(hsize, 0, -camera->get_znear()).normalized();
|
||||
Vector3 side = Vector3(hsize, 0, -camera->get_near()).normalized();
|
||||
Vector3 nside = side;
|
||||
nside.x = -nside.x;
|
||||
Vector3 up = Vector3(0, side.x, 0);
|
||||
|
@ -2210,8 +2210,8 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) {
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
|
||||
real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_distance = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
|
||||
real_t min_distance = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_distance = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
|
||||
if (unlikely(min_distance > max_distance)) {
|
||||
cursor.distance = (min_distance + max_distance) / 2;
|
||||
} else {
|
||||
@ -2223,8 +2223,8 @@ void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::scale_freelook_speed(real_t scale) {
|
||||
real_t min_speed = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_speed = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
|
||||
real_t min_speed = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_speed = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
|
||||
if (unlikely(min_speed > max_speed)) {
|
||||
freelook_speed = (min_speed + max_speed) / 2;
|
||||
} else {
|
||||
@ -2715,8 +2715,8 @@ void Node3DEditorViewport::_draw() {
|
||||
if (is_freelook_active()) {
|
||||
// Show speed
|
||||
|
||||
real_t min_speed = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_speed = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
|
||||
real_t min_speed = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_speed = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
|
||||
real_t scale_length = (max_speed - min_speed);
|
||||
|
||||
if (!Math::is_zero_approx(scale_length)) {
|
||||
@ -2736,8 +2736,8 @@ void Node3DEditorViewport::_draw() {
|
||||
} else {
|
||||
// Show zoom
|
||||
|
||||
real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_distance = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
|
||||
real_t min_distance = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_distance = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
|
||||
real_t scale_length = (max_distance - min_distance);
|
||||
|
||||
if (!Math::is_zero_approx(scale_length)) {
|
||||
|
@ -476,13 +476,13 @@ void Camera3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_fov"), &Camera3D::get_fov);
|
||||
ClassDB::bind_method(D_METHOD("get_frustum_offset"), &Camera3D::get_frustum_offset);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &Camera3D::get_size);
|
||||
ClassDB::bind_method(D_METHOD("get_zfar"), &Camera3D::get_zfar);
|
||||
ClassDB::bind_method(D_METHOD("get_znear"), &Camera3D::get_znear);
|
||||
ClassDB::bind_method(D_METHOD("get_far"), &Camera3D::get_far);
|
||||
ClassDB::bind_method(D_METHOD("get_near"), &Camera3D::get_near);
|
||||
ClassDB::bind_method(D_METHOD("set_fov"), &Camera3D::set_fov);
|
||||
ClassDB::bind_method(D_METHOD("set_frustum_offset"), &Camera3D::set_frustum_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_size"), &Camera3D::set_size);
|
||||
ClassDB::bind_method(D_METHOD("set_zfar"), &Camera3D::set_zfar);
|
||||
ClassDB::bind_method(D_METHOD("set_znear"), &Camera3D::set_znear);
|
||||
ClassDB::bind_method(D_METHOD("set_far"), &Camera3D::set_far);
|
||||
ClassDB::bind_method(D_METHOD("set_near"), &Camera3D::set_near);
|
||||
ClassDB::bind_method(D_METHOD("get_projection"), &Camera3D::get_projection);
|
||||
ClassDB::bind_method(D_METHOD("set_projection"), &Camera3D::set_projection);
|
||||
ClassDB::bind_method(D_METHOD("set_h_offset", "ofs"), &Camera3D::set_h_offset);
|
||||
@ -519,8 +519,8 @@ void Camera3D::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fov", PROPERTY_HINT_RANGE, "1,179,0.1"), "set_fov", "get_fov");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "size", PROPERTY_HINT_RANGE, "0.1,16384,0.01"), "set_size", "get_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "frustum_offset"), "set_frustum_offset", "get_frustum_offset");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "near", PROPERTY_HINT_EXP_RANGE, "0.001,10,0.001,or_greater"), "set_znear", "get_znear");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "far", PROPERTY_HINT_EXP_RANGE, "0.01,4000,0.01,or_greater"), "set_zfar", "get_zfar");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "near", PROPERTY_HINT_EXP_RANGE, "0.001,10,0.001,or_greater"), "set_near", "get_near");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "far", PROPERTY_HINT_EXP_RANGE, "0.01,4000,0.01,or_greater"), "set_far", "get_far");
|
||||
|
||||
BIND_ENUM_CONSTANT(PROJECTION_PERSPECTIVE);
|
||||
BIND_ENUM_CONSTANT(PROJECTION_ORTHOGONAL);
|
||||
@ -542,7 +542,7 @@ float Camera3D::get_size() const {
|
||||
return size;
|
||||
}
|
||||
|
||||
float Camera3D::get_znear() const {
|
||||
float Camera3D::get_near() const {
|
||||
return near;
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ Vector2 Camera3D::get_frustum_offset() const {
|
||||
return frustum_offset;
|
||||
}
|
||||
|
||||
float Camera3D::get_zfar() const {
|
||||
float Camera3D::get_far() const {
|
||||
return far;
|
||||
}
|
||||
|
||||
@ -572,8 +572,8 @@ void Camera3D::set_size(float p_size) {
|
||||
_change_notify("size");
|
||||
}
|
||||
|
||||
void Camera3D::set_znear(float p_znear) {
|
||||
near = p_znear;
|
||||
void Camera3D::set_near(float p_near) {
|
||||
near = p_near;
|
||||
_update_camera_mode();
|
||||
}
|
||||
|
||||
@ -582,8 +582,8 @@ void Camera3D::set_frustum_offset(Vector2 p_offset) {
|
||||
_update_camera_mode();
|
||||
}
|
||||
|
||||
void Camera3D::set_zfar(float p_zfar) {
|
||||
far = p_zfar;
|
||||
void Camera3D::set_far(float p_far) {
|
||||
far = p_far;
|
||||
_update_camera_mode();
|
||||
}
|
||||
|
||||
|
@ -121,16 +121,16 @@ public:
|
||||
|
||||
float get_fov() const;
|
||||
float get_size() const;
|
||||
float get_zfar() const;
|
||||
float get_znear() const;
|
||||
float get_far() const;
|
||||
float get_near() const;
|
||||
Vector2 get_frustum_offset() const;
|
||||
|
||||
Projection get_projection() const;
|
||||
|
||||
void set_fov(float p_fov);
|
||||
void set_size(float p_size);
|
||||
void set_zfar(float p_zfar);
|
||||
void set_znear(float p_znear);
|
||||
void set_far(float p_far);
|
||||
void set_near(float p_near);
|
||||
void set_frustum_offset(Vector2 p_offset);
|
||||
|
||||
virtual Transform get_camera_transform() const;
|
||||
|
@ -91,9 +91,9 @@ Vector3 XRCamera3D::project_local_ray_normal(const Point2 &p_pos) const {
|
||||
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
|
||||
Vector3 ray;
|
||||
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_near(), get_far());
|
||||
Vector2 screen_he = cm.get_viewport_half_extents();
|
||||
ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_znear()).normalized();
|
||||
ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_near()).normalized();
|
||||
|
||||
return ray;
|
||||
};
|
||||
@ -113,7 +113,7 @@ Point2 XRCamera3D::unproject_position(const Vector3 &p_pos) const {
|
||||
|
||||
Size2 viewport_size = get_viewport()->get_visible_rect().size;
|
||||
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_near(), get_far());
|
||||
|
||||
Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
|
||||
|
||||
@ -142,7 +142,7 @@ Vector3 XRCamera3D::project_position(const Point2 &p_point, float p_z_depth) con
|
||||
|
||||
Size2 viewport_size = get_viewport()->get_visible_rect().size;
|
||||
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_near(), get_far());
|
||||
|
||||
Vector2 vp_he = cm.get_viewport_half_extents();
|
||||
|
||||
@ -170,7 +170,7 @@ Vector<Plane> XRCamera3D::get_frustum() const {
|
||||
ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
|
||||
|
||||
Size2 viewport_size = get_viewport()->get_visible_rect().size;
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_near(), get_far());
|
||||
return cm.get_projection_planes(get_camera_transform());
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user