Merge pull request #65779 from Mickeon/rename-camera-follow
Rename Camera2D's `smoothing` to `position_smoothing`
This commit is contained in:
commit
6fc1715cdf
4 changed files with 50 additions and 38 deletions
|
@ -52,14 +52,14 @@
|
|||
<return type="Vector2" />
|
||||
<description>
|
||||
Returns this camera's target position, in global coordinates.
|
||||
[b]Note:[/b] The returned value is not the same as [member Node2D.global_position], as it is affected by the drag properties. It is also not the same as the current position if [member smoothing_enabled] is [code]true[/code] (see [method get_screen_center_position]).
|
||||
[b]Note:[/b] The returned value is not the same as [member Node2D.global_position], as it is affected by the drag properties. It is also not the same as the current position if [member position_smoothing_enabled] is [code]true[/code] (see [method get_screen_center_position]).
|
||||
</description>
|
||||
</method>
|
||||
<method name="reset_smoothing">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Sets the camera's position immediately to its current smoothing destination.
|
||||
This method has no effect if [member smoothing_enabled] is [code]false[/code].
|
||||
This method has no effect if [member position_smoothing_enabled] is [code]false[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_drag_margin">
|
||||
|
@ -138,7 +138,7 @@
|
|||
</member>
|
||||
<member name="limit_smoothed" type="bool" setter="set_limit_smoothing_enabled" getter="is_limit_smoothing_enabled" default="false">
|
||||
If [code]true[/code], the camera smoothly stops when reaches its limits.
|
||||
This property has no effect if [member smoothing_enabled] is [code]false[/code].
|
||||
This property has no effect if [member position_smoothing_enabled] is [code]false[/code].
|
||||
[b]Note:[/b] To immediately update the camera's position to be within limits without smoothing, even with this setting enabled, invoke [method reset_smoothing].
|
||||
</member>
|
||||
<member name="limit_top" type="int" setter="set_limit" getter="get_limit" default="-10000000">
|
||||
|
@ -147,6 +147,12 @@
|
|||
<member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
|
||||
The camera's relative offset. Useful for looking around or camera shake animations. The offsetted camera can go past the limits defined in [member limit_top], [member limit_bottom], [member limit_left] and [member limit_right].
|
||||
</member>
|
||||
<member name="position_smoothing_enabled" type="bool" setter="set_position_smoothing_enabled" getter="is_position_smoothing_enabled" default="false">
|
||||
If [code]true[/code], the camera's view smoothly moves towards its target position at [member position_smoothing_speed].
|
||||
</member>
|
||||
<member name="position_smoothing_speed" type="float" setter="set_position_smoothing_speed" getter="get_position_smoothing_speed" default="5.0">
|
||||
Speed in pixels per second of the camera's smoothing effect when [member position_smoothing_enabled] is [code]true[/code].
|
||||
</member>
|
||||
<member name="process_callback" type="int" setter="set_process_callback" getter="get_process_callback" enum="Camera2D.Camera2DProcessCallback" default="1">
|
||||
The camera's process callback. See [enum Camera2DProcessCallback].
|
||||
</member>
|
||||
|
@ -157,12 +163,6 @@
|
|||
<member name="rotation_smoothing_speed" type="float" setter="set_rotation_smoothing_speed" getter="get_rotation_smoothing_speed" default="5.0">
|
||||
The angular, asymptotic speed of the camera's rotation smoothing effect when [member rotation_smoothing_enabled] is [code]true[/code].
|
||||
</member>
|
||||
<member name="smoothing_enabled" type="bool" setter="set_enable_follow_smoothing" getter="is_follow_smoothing_enabled" default="false">
|
||||
If [code]true[/code], the camera smoothly moves towards the target at [member smoothing_speed].
|
||||
</member>
|
||||
<member name="smoothing_speed" type="float" setter="set_follow_smoothing" getter="get_follow_smoothing" default="5.0">
|
||||
Speed in pixels per second of the camera's smoothing effect when [member smoothing_enabled] is [code]true[/code].
|
||||
</member>
|
||||
<member name="zoom" type="Vector2" setter="set_zoom" getter="get_zoom" default="Vector2(1, 1)">
|
||||
The camera's zoom. A zoom of [code]Vector(2, 2)[/code] doubles the size seen in the viewport. A zoom of [code]Vector(0.5, 0.5)[/code] halves the size seen in the viewport.
|
||||
</member>
|
||||
|
|
|
@ -311,6 +311,7 @@ static const char *gdscript_function_renames[][2] = {
|
|||
{ "get_error_string", "get_error_message" }, // JSON
|
||||
{ "get_filename", "get_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places
|
||||
{ "get_focus_neighbour", "get_focus_neighbor" }, // Control
|
||||
{ "get_follow_smoothing", "get_position_smoothing_speed" }, // Camera2D
|
||||
{ "get_font_types", "get_font_type_list" }, // Theme
|
||||
{ "get_frame_color", "get_color" }, // ColorRect
|
||||
{ "get_global_rate_scale", "get_playback_speed_scale" }, // AudioServer
|
||||
|
@ -419,6 +420,7 @@ static const char *gdscript_function_renames[][2] = {
|
|||
{ "is_commiting_action", "is_committing_action" }, // UndoRedo
|
||||
{ "is_doubleclick", "is_double_click" }, // InputEventMouseButton
|
||||
{ "is_draw_red", "is_draw_warning" }, // EditorProperty
|
||||
{ "is_follow_smoothing_enabled", "is_position_smoothing_enabled" }, // Camera2D
|
||||
{ "is_h_drag_enabled", "is_drag_horizontal_enabled" }, // Camera2D
|
||||
{ "is_handle_highlighted", "_is_handle_highlighted" }, // EditorNode3DGizmo, EditorNode3DGizmoPlugin
|
||||
{ "is_inverting_faces", "get_flip_faces" }, // CSGPrimitive3D
|
||||
|
@ -500,11 +502,13 @@ static const char *gdscript_function_renames[][2] = {
|
|||
{ "set_depth_bias_enable", "set_depth_bias_enabled" }, // RDPipelineRasterizationState
|
||||
{ "set_doubleclick", "set_double_click" }, // InputEventMouseButton
|
||||
{ "set_draw_red", "set_draw_warning" }, // EditorProperty
|
||||
{ "set_enable_follow_smoothing", "set_position_smoothing_enabled" }, // Camera2D
|
||||
{ "set_enabled_focus_mode", "set_focus_mode" }, // BaseButton
|
||||
{ "set_endian_swap", "set_big_endian" }, // File
|
||||
{ "set_expand_to_text_length", "set_expand_to_text_length_enabled" }, // LineEdit
|
||||
{ "set_filename", "set_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places
|
||||
{ "set_focus_neighbour", "set_focus_neighbor" }, // Control
|
||||
{ "set_follow_smoothing", "set_position_smoothing_speed" }, // Camera2D
|
||||
{ "set_frame_color", "set_color" }, // ColorRect
|
||||
{ "set_global_rate_scale", "set_playback_speed_scale" }, // AudioServer
|
||||
{ "set_gravity_distance_scale", "set_gravity_point_distance_scale" }, // Area2D
|
||||
|
@ -753,6 +757,7 @@ static const char *csharp_function_renames[][2] = {
|
|||
{ "GetEndianSwap", "IsBigEndian" }, // File
|
||||
{ "GetErrorString", "GetErrorMessage" }, // JSON
|
||||
{ "GetFocusNeighbour", "GetFocusNeighbor" }, // Control
|
||||
{ "GetFollowSmoothing", "GetFollowSmoothingSpeed" }, // Camera2D
|
||||
{ "GetFontTypes", "GetFontTypeList" }, // Theme
|
||||
{ "GetFrameColor", "GetColor" }, // ColorRect
|
||||
{ "GetGlobalRateScale", "GetPlaybackSpeedScale" }, // AudioServer
|
||||
|
@ -858,6 +863,7 @@ static const char *csharp_function_renames[][2] = {
|
|||
{ "IsAParentOf", "IsAncestorOf" }, // Node
|
||||
{ "IsCommitingAction", "IsCommittingAction" }, // UndoRedo
|
||||
{ "IsDoubleclick", "IsDoubleClick" }, // InputEventMouseButton
|
||||
{ "IsFollowSmoothingEnabled", "IsPositionSmoothingEnabled" }, // Camera2D
|
||||
{ "IsHDragEnabled", "IsDragHorizontalEnabled" }, // Camera2D
|
||||
{ "IsHandleHighlighted", "_IsHandleHighlighted" }, // EditorNode3DGizmo, EditorNode3DGizmoPlugin
|
||||
{ "IsNetworkMaster", "IsMultiplayerAuthority" }, // Node
|
||||
|
@ -934,10 +940,12 @@ static const char *csharp_function_renames[][2] = {
|
|||
{ "SetD", "SetDistance" }, // WorldMarginShape2D
|
||||
{ "SetDepthBiasEnable", "SetDepthBiasEnabled" }, // RDPipelineRasterizationState
|
||||
{ "SetDoubleclick", "SetDoubleClick" }, // InputEventMouseButton
|
||||
{ "SetEnableFollowSmoothing", "SetFollowSmoothingEnabled" }, // Camera2D
|
||||
{ "SetEnabledFocusMode", "SetFocusMode" }, // BaseButton
|
||||
{ "SetEndianSwap", "SetBigEndian" }, // File
|
||||
{ "SetExpandToTextLength", "SetExpandToTextLengthEnabled" }, // LineEdit
|
||||
{ "SetFocusNeighbour", "SetFocusNeighbor" }, // Control
|
||||
{ "SetFollowSmoothing", "SetFollowSmoothingSpeed" }, // Camera2D
|
||||
{ "SetFrameColor", "SetColor" }, // ColorRect
|
||||
{ "SetGlobalRateScale", "SetPlaybackSpeedScale" }, // AudioServer
|
||||
{ "SetGravityDistanceScale", "SetGravityPointDistanceScale" }, // Area2D
|
||||
|
@ -1139,6 +1147,8 @@ static const char *gdscript_properties_renames[][2] = {
|
|||
{ "selectedframe", "selected_frame" }, // Theme
|
||||
{ "size_override_stretch", "size_2d_override_stretch" }, // SubViewport
|
||||
{ "slips_on_slope", "slide_on_slope" }, // SeparationRayShape2D
|
||||
{ "smoothing_enabled", "follow_smoothing_enabled" }, // Camera2D
|
||||
{ "smoothing_speed", "position_smoothing_speed" }, // Camera2D
|
||||
{ "ss_reflections_depth_tolerance", "ssr_depth_tolerance" }, // Environment
|
||||
{ "ss_reflections_enabled", "ssr_enabled" }, // Environment
|
||||
{ "ss_reflections_fade_in", "ssr_fade_in" }, // Environment
|
||||
|
@ -1233,6 +1243,8 @@ static const char *csharp_properties_renames[][2] = {
|
|||
{ "Selectedframe", "SelectedFrame" }, // Theme
|
||||
{ "SizeOverrideStretch", "Size2dOverrideStretch" }, // SubViewport
|
||||
{ "SlipsOnSlope", "SlideOnSlope" }, // SeparationRayShape2D
|
||||
{ "SmoothingEnabled", "FollowSmoothingEnabled" }, // Camera2D
|
||||
{ "SmoothingSpeed", "FollowSmoothingSpeed" }, // Camera2D
|
||||
{ "SsReflectionsDepthTolerance", "SsrDepthTolerance" }, // Environment
|
||||
{ "SsReflectionsEnabled", "SsrEnabled" }, // Environment
|
||||
{ "SsReflectionsFadeIn", "SsrFadeIn" }, // Environment
|
||||
|
|
|
@ -155,11 +155,11 @@ Transform2D Camera2D::get_camera_transform() {
|
|||
}
|
||||
}
|
||||
|
||||
if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) {
|
||||
real_t c = smoothing * (process_callback == CAMERA2D_PROCESS_PHYSICS ? get_physics_process_delta_time() : get_process_delta_time());
|
||||
if (follow_smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) {
|
||||
real_t c = position_smoothing_speed * (process_callback == CAMERA2D_PROCESS_PHYSICS ? get_physics_process_delta_time() : get_process_delta_time());
|
||||
smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos;
|
||||
ret_camera_pos = smoothed_camera_pos;
|
||||
//camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
|
||||
//camera_pos=camera_pos*(1.0-position_smoothing_speed)+new_camera_pos*position_smoothing_speed;
|
||||
} else {
|
||||
ret_camera_pos = smoothed_camera_pos = camera_pos;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ Transform2D Camera2D::get_camera_transform() {
|
|||
|
||||
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom_scale);
|
||||
|
||||
if (!smoothing_enabled || !limit_smoothing_enabled) {
|
||||
if (!follow_smoothing_enabled || !limit_smoothing_enabled) {
|
||||
if (screen_rect.position.x < limit[SIDE_LEFT]) {
|
||||
screen_rect.position.x = limit[SIDE_LEFT];
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ void Camera2D::set_current(bool p_current) {
|
|||
|
||||
void Camera2D::_update_process_internal_for_smoothing() {
|
||||
bool is_not_in_scene_or_editor = !(is_inside_tree() && Engine::get_singleton()->is_editor_hint());
|
||||
bool is_any_smoothing_valid = smoothing > 0 || rotation_smoothing_speed > 0;
|
||||
bool is_any_smoothing_valid = position_smoothing_speed > 0 || rotation_smoothing_speed > 0;
|
||||
|
||||
bool enabled = is_any_smoothing_valid && is_not_in_scene_or_editor;
|
||||
set_process_internal(enabled);
|
||||
|
@ -525,13 +525,13 @@ void Camera2D::align() {
|
|||
_update_scroll();
|
||||
}
|
||||
|
||||
void Camera2D::set_follow_smoothing(real_t p_speed) {
|
||||
smoothing = p_speed;
|
||||
void Camera2D::set_position_smoothing_speed(real_t p_speed) {
|
||||
position_smoothing_speed = p_speed;
|
||||
_update_process_internal_for_smoothing();
|
||||
}
|
||||
|
||||
real_t Camera2D::get_follow_smoothing() const {
|
||||
return smoothing;
|
||||
real_t Camera2D::get_position_smoothing_speed() const {
|
||||
return position_smoothing_speed;
|
||||
}
|
||||
|
||||
void Camera2D::set_rotation_smoothing_speed(real_t p_speed) {
|
||||
|
@ -607,18 +607,18 @@ real_t Camera2D::get_drag_horizontal_offset() const {
|
|||
void Camera2D::_set_old_smoothing(real_t p_enable) {
|
||||
//compatibility
|
||||
if (p_enable > 0) {
|
||||
smoothing_enabled = true;
|
||||
set_follow_smoothing(p_enable);
|
||||
follow_smoothing_enabled = true;
|
||||
set_position_smoothing_speed(p_enable);
|
||||
}
|
||||
}
|
||||
|
||||
void Camera2D::set_enable_follow_smoothing(bool p_enabled) {
|
||||
smoothing_enabled = p_enabled;
|
||||
void Camera2D::set_position_smoothing_enabled(bool p_enabled) {
|
||||
follow_smoothing_enabled = p_enabled;
|
||||
notify_property_list_changed();
|
||||
}
|
||||
|
||||
bool Camera2D::is_follow_smoothing_enabled() const {
|
||||
return smoothing_enabled;
|
||||
bool Camera2D::is_position_smoothing_enabled() const {
|
||||
return follow_smoothing_enabled;
|
||||
}
|
||||
|
||||
void Camera2D::set_custom_viewport(Node *p_viewport) {
|
||||
|
@ -689,7 +689,7 @@ bool Camera2D::is_margin_drawing_enabled() const {
|
|||
}
|
||||
|
||||
void Camera2D::_validate_property(PropertyInfo &p_property) const {
|
||||
if (!smoothing_enabled && p_property.name == "smoothing_speed") {
|
||||
if (!follow_smoothing_enabled && p_property.name == "smoothing_speed") {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
if (!rotation_smoothing_enabled && p_property.name == "rotation_smoothing_speed") {
|
||||
|
@ -746,11 +746,11 @@ void Camera2D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_custom_viewport", "viewport"), &Camera2D::set_custom_viewport);
|
||||
ClassDB::bind_method(D_METHOD("get_custom_viewport"), &Camera2D::get_custom_viewport);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_follow_smoothing", "follow_smoothing"), &Camera2D::set_follow_smoothing);
|
||||
ClassDB::bind_method(D_METHOD("get_follow_smoothing"), &Camera2D::get_follow_smoothing);
|
||||
ClassDB::bind_method(D_METHOD("set_position_smoothing_speed", "position_smoothing_speed"), &Camera2D::set_position_smoothing_speed);
|
||||
ClassDB::bind_method(D_METHOD("get_position_smoothing_speed"), &Camera2D::get_position_smoothing_speed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_enable_follow_smoothing", "follow_smoothing"), &Camera2D::set_enable_follow_smoothing);
|
||||
ClassDB::bind_method(D_METHOD("is_follow_smoothing_enabled"), &Camera2D::is_follow_smoothing_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_position_smoothing_enabled", "position_smoothing_speed"), &Camera2D::set_position_smoothing_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_position_smoothing_enabled"), &Camera2D::is_position_smoothing_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_rotation_smoothing_enabled", "enabled"), &Camera2D::set_rotation_smoothing_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_rotation_smoothing_enabled"), &Camera2D::is_rotation_smoothing_enabled);
|
||||
|
@ -788,9 +788,9 @@ void Camera2D::_bind_methods() {
|
|||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_bottom", PROPERTY_HINT_NONE, "suffix:px"), "set_limit", "get_limit", SIDE_BOTTOM);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "limit_smoothed"), "set_limit_smoothing_enabled", "is_limit_smoothing_enabled");
|
||||
|
||||
ADD_GROUP("Smoothing", "smoothing_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smoothing_enabled"), "set_enable_follow_smoothing", "is_follow_smoothing_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "smoothing_speed", PROPERTY_HINT_NONE, "suffix:px/s"), "set_follow_smoothing", "get_follow_smoothing");
|
||||
ADD_GROUP("Follow Smoothing", "follow_smoothing_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "position_smoothing_enabled"), "set_position_smoothing_enabled", "is_position_smoothing_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "position_smoothing_speed", PROPERTY_HINT_NONE, "suffix:px/s"), "set_position_smoothing_speed", "get_position_smoothing_speed");
|
||||
|
||||
ADD_GROUP("Rotation Smoothing", "rotation_smoothing_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotation_smoothing_enabled"), "set_rotation_smoothing_enabled", "is_rotation_smoothing_enabled");
|
||||
|
|
|
@ -65,8 +65,8 @@ protected:
|
|||
AnchorMode anchor_mode = ANCHOR_MODE_DRAG_CENTER;
|
||||
bool ignore_rotation = true;
|
||||
bool current = false;
|
||||
real_t smoothing = 5.0;
|
||||
bool smoothing_enabled = false;
|
||||
real_t position_smoothing_speed = 5.0;
|
||||
bool follow_smoothing_enabled = false;
|
||||
|
||||
real_t camera_angle = 0.0;
|
||||
real_t rotation_smoothing_speed = 5.0;
|
||||
|
@ -140,11 +140,11 @@ public:
|
|||
void set_drag_vertical_offset(real_t p_offset);
|
||||
real_t get_drag_vertical_offset() const;
|
||||
|
||||
void set_enable_follow_smoothing(bool p_enabled);
|
||||
bool is_follow_smoothing_enabled() const;
|
||||
void set_position_smoothing_enabled(bool p_enabled);
|
||||
bool is_position_smoothing_enabled() const;
|
||||
|
||||
void set_follow_smoothing(real_t p_speed);
|
||||
real_t get_follow_smoothing() const;
|
||||
void set_position_smoothing_speed(real_t p_speed);
|
||||
real_t get_position_smoothing_speed() const;
|
||||
|
||||
void set_rotation_smoothing_speed(real_t p_speed);
|
||||
real_t get_rotation_smoothing_speed() const;
|
||||
|
|
Loading…
Reference in a new issue