diff options
Diffstat (limited to 'scene/3d/camera_3d.cpp')
-rw-r--r-- | scene/3d/camera_3d.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 871f3119bc..0f7aa28bf3 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -39,16 +39,13 @@ void Camera3D::_update_audio_listener_state() { } void Camera3D::_request_camera_update() { - _update_camera(); } void Camera3D::_update_camera_mode() { - force_change = true; switch (mode) { case PROJECTION_PERSPECTIVE: { - set_perspective(fov, near, far); } break; @@ -78,7 +75,6 @@ void Camera3D::_validate_property(PropertyInfo &p_property) const { } void Camera3D::_update_camera() { - if (!is_inside_tree()) return; @@ -101,11 +97,8 @@ void Camera3D::_update_camera() { } void Camera3D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_WORLD: { - // Needs to track the Viewport because it's needed on NOTIFICATION_EXIT_WORLD // and Spatial will handle it first, including clearing its reference to the Viewport, // therefore making it impossible to subclasses to access it @@ -118,14 +111,12 @@ void Camera3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - _request_camera_update(); if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { velocity_tracker->update_position(get_global_transform().origin); } } break; case NOTIFICATION_EXIT_WORLD: { - if (!get_tree()->is_node_being_edited(this)) { if (is_current()) { clear_current(); @@ -156,7 +147,6 @@ void Camera3D::_notification(int p_what) { } Transform Camera3D::get_camera_transform() const { - Transform tr = get_global_transform().orthonormalized(); tr.origin += tr.basis.get_axis(1) * v_offset; tr.origin += tr.basis.get_axis(0) * h_offset; @@ -164,7 +154,6 @@ Transform Camera3D::get_camera_transform() const { } void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) { - if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE) return; @@ -178,7 +167,6 @@ void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_f force_change = false; } void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) { - if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL) return; @@ -218,12 +206,10 @@ void Camera3D::set_projection(Camera3D::Projection p_mode) { } RID Camera3D::get_camera() const { - return camera; }; void Camera3D::make_current() { - current = true; if (!is_inside_tree()) @@ -235,7 +221,6 @@ void Camera3D::make_current() { } void Camera3D::clear_current(bool p_enable_next) { - current = false; if (!is_inside_tree()) return; @@ -258,27 +243,22 @@ void Camera3D::set_current(bool p_current) { } bool Camera3D::is_current() const { - if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) { - return get_viewport()->get_camera() == this; } else return current; } bool Camera3D::_can_gizmo_scale() const { - return false; } Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const { - Vector3 ray = project_local_ray_normal(p_pos); return get_camera_transform().basis.xform(ray).normalized(); }; Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); @@ -286,7 +266,6 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { Vector3 ray; if (mode == PROJECTION_ORTHOGONAL) { - ray = Vector3(0, 0, -1); } else { CameraMatrix cm; @@ -299,7 +278,6 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { }; Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_camera_rect_size(); @@ -307,10 +285,8 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { ERR_FAIL_COND_V(viewport_size.y == 0, Vector3()); if (mode == PROJECTION_PERSPECTIVE) { - return get_camera_transform().origin; } else { - Vector2 pos = cpos / viewport_size; float vsize, hsize; if (keep_aspect == KEEP_WIDTH) { @@ -331,7 +307,6 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { }; bool Camera3D::is_position_behind(const Vector3 &p_pos) const { - Transform t = get_global_transform(); Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized(); return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near); @@ -361,7 +336,6 @@ Vector<Vector3> Camera3D::get_near_plane_points() const { } Point2 Camera3D::unproject_position(const Vector3 &p_pos) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene."); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -386,7 +360,6 @@ Point2 Camera3D::unproject_position(const Vector3 &p_pos) const { } Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const { - ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); if (p_z_depth == 0 && mode != PROJECTION_ORTHOGONAL) { @@ -414,7 +387,6 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const } void Camera3D::set_environment(const Ref<Environment> &p_environment) { - environment = p_environment; if (environment.is_valid()) RS::get_singleton()->camera_set_environment(camera, environment->get_rid()); @@ -424,12 +396,10 @@ void Camera3D::set_environment(const Ref<Environment> &p_environment) { } Ref<Environment> Camera3D::get_environment() const { - return environment; } void Camera3D::set_effects(const Ref<CameraEffects> &p_effects) { - effects = p_effects; if (effects.is_valid()) RS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid()); @@ -439,7 +409,6 @@ void Camera3D::set_effects(const Ref<CameraEffects> &p_effects) { } Ref<CameraEffects> Camera3D::get_effects() const { - return effects; } @@ -451,12 +420,10 @@ void Camera3D::set_keep_aspect_mode(KeepAspect p_aspect) { } Camera3D::KeepAspect Camera3D::get_keep_aspect_mode() const { - return keep_aspect; } void Camera3D::set_doppler_tracking(DopplerTracking p_tracking) { - if (doppler_tracking == p_tracking) return; @@ -475,7 +442,6 @@ Camera3D::DopplerTracking Camera3D::get_doppler_tracking() const { } void Camera3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("project_ray_normal", "screen_point"), &Camera3D::project_ray_normal); ClassDB::bind_method(D_METHOD("project_local_ray_normal", "screen_point"), &Camera3D::project_local_ray_normal); ClassDB::bind_method(D_METHOD("project_ray_origin", "screen_point"), &Camera3D::project_ray_origin); @@ -552,17 +518,14 @@ void Camera3D::_bind_methods() { } float Camera3D::get_fov() const { - return fov; } float Camera3D::get_size() const { - return size; } float Camera3D::get_znear() const { - return near; } @@ -571,12 +534,10 @@ Vector2 Camera3D::get_frustum_offset() const { } float Camera3D::get_zfar() const { - return far; } Camera3D::Projection Camera3D::get_projection() const { - return mode; } @@ -616,7 +577,6 @@ void Camera3D::set_cull_mask(uint32_t p_layers) { } uint32_t Camera3D::get_cull_mask() const { - return layers; } @@ -635,7 +595,6 @@ bool Camera3D::get_cull_mask_bit(int p_layer) const { } Vector<Plane> Camera3D::get_frustum() const { - ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>()); Size2 viewport_size = get_viewport()->get_visible_rect().size; @@ -649,13 +608,11 @@ Vector<Plane> Camera3D::get_frustum() const { } void Camera3D::set_v_offset(float p_offset) { - v_offset = p_offset; _update_camera(); } float Camera3D::get_v_offset() const { - return v_offset; } @@ -665,12 +622,10 @@ void Camera3D::set_h_offset(float p_offset) { } float Camera3D::get_h_offset() const { - return h_offset; } Vector3 Camera3D::get_doppler_tracked_velocity() const { - if (doppler_tracking != DOPPLER_TRACKING_DISABLED) { return velocity_tracker->get_tracked_linear_velocity(); } else { @@ -678,7 +633,6 @@ Vector3 Camera3D::get_doppler_tracked_velocity() const { } } Camera3D::Camera3D() { - camera = RenderingServer::get_singleton()->camera_create(); size = 1; fov = 0; @@ -703,7 +657,6 @@ Camera3D::Camera3D() { } Camera3D::~Camera3D() { - RenderingServer::get_singleton()->free(camera); } @@ -716,7 +669,6 @@ float ClippedCamera3D::get_margin() const { return margin; } void ClippedCamera3D::set_process_mode(ProcessMode p_mode) { - if (process_mode == p_mode) { return; } @@ -729,7 +681,6 @@ ClippedCamera3D::ProcessMode ClippedCamera3D::get_process_mode() const { } Transform ClippedCamera3D::get_camera_transform() const { - Transform t = Camera3D::get_camera_transform(); t.origin += -t.basis.get_axis(Vector3::AXIS_Z).normalized() * clip_offset; return t; @@ -737,7 +688,6 @@ Transform ClippedCamera3D::get_camera_transform() const { void ClippedCamera3D::_notification(int p_what) { if (p_what == NOTIFICATION_INTERNAL_PROCESS || p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { - Node3D *parent = Object::cast_to<Node3D>(get_parent()); if (!parent) { return; @@ -797,17 +747,14 @@ void ClippedCamera3D::_notification(int p_what) { } void ClippedCamera3D::set_collision_mask(uint32_t p_mask) { - collision_mask = p_mask; } uint32_t ClippedCamera3D::get_collision_mask() const { - return collision_mask; } void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) { - uint32_t mask = get_collision_mask(); if (p_value) mask |= 1 << p_bit; @@ -817,17 +764,14 @@ void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) { } bool ClippedCamera3D::get_collision_mask_bit(int p_bit) const { - return get_collision_mask() & (1 << p_bit); } void ClippedCamera3D::add_exception_rid(const RID &p_rid) { - exclude.insert(p_rid); } void ClippedCamera3D::add_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object); if (!co) @@ -836,12 +780,10 @@ void ClippedCamera3D::add_exception(const Object *p_object) { } void ClippedCamera3D::remove_exception_rid(const RID &p_rid) { - exclude.erase(p_rid); } void ClippedCamera3D::remove_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object); if (!co) @@ -850,37 +792,30 @@ void ClippedCamera3D::remove_exception(const Object *p_object) { } void ClippedCamera3D::clear_exceptions() { - exclude.clear(); } float ClippedCamera3D::get_clip_offset() const { - return clip_offset; } void ClippedCamera3D::set_clip_to_areas(bool p_clip) { - clip_to_areas = p_clip; } bool ClippedCamera3D::is_clip_to_areas_enabled() const { - return clip_to_areas; } void ClippedCamera3D::set_clip_to_bodies(bool p_clip) { - clip_to_bodies = p_clip; } bool ClippedCamera3D::is_clip_to_bodies_enabled() const { - return clip_to_bodies; } void ClippedCamera3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_margin", "margin"), &ClippedCamera3D::set_margin); ClassDB::bind_method(D_METHOD("get_margin"), &ClippedCamera3D::get_margin); |