Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace radians range hint with radians_as_degrees #82195

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

AThousandShips
Copy link
Member

Deprecates the old syntax

Added compatibility details to the areas I can find that checks for the old tag, haven't attempted any auto-conversion internally or in relation to 3.x, and couldn't find any references to it in mono

If there are any areas that depend on the original syntax I think they can be solved at a later time as it is not pressing

Also renamed the member variable in the editor property classes to make it clear what they do and align with the annotation

As per #73170 (comment) and RocketChat

@AThousandShips
Copy link
Member Author

If this gets merged I'll look into uses of the now deprecated hint elsewhere in documentation etc.

@AThousandShips
Copy link
Member Author

(Missed a documentation entry in @GlobalScope which I'll add after CI has run)

@AThousandShips AThousandShips changed the title Replace range hint radians with radians_as_degrees Replace radians range hint with radians_as_degrees Sep 23, 2023
@AThousandShips AThousandShips requested a review from a team as a code owner September 23, 2023 16:03
Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the current name. Marking a property as "radians" means "this property uses radians as its unit", which is an independent thing from how the editor decides to convert the unit. For example, if we ever add an editor setting to display radians as radians, the property hint "radians_as_degrees" makes no sense.

@AThousandShips
Copy link
Member Author

AThousandShips commented Sep 23, 2023

But the range is confusing with the naming, and no such system is in place, and are there even any plans to do so? And how would that be useful in the interface?

The current phrasing, without deep knowledge of the engine, is confusing

@YuriSizov
Copy link
Contributor

Marking a property as "radians" means "this property uses radians as its unit"

That doesn't work when the other part of the export hint, the range itself, doesn't use radians as its unit. And we can't change that without breaking compatibility. So we need a new name regardless, even if we want to introduce the behavior that you describe in #73170 (comment).

I agree that "radians_as_degrees" caters to one specific behavior, but that's our current and only behavior. And it also aligns the name with how the rest of the hint is set. If we ever add a way to display this value in some other format, it's going to be even a bigger mess, because the actual property would be in radians, the hinted range would be in degrees, and the displayed value would be in ???.

We shouldn't restrict our solutions based on some potential use case in the future, especially given that that use case is unlikely to fit the current implementation.

@AThousandShips
Copy link
Member Author

Also, while I don't think there's any really good reason to allow editing radians in the inspector, renaming it now would free up radians for this use in the future, without making a breaking change to change its behavior

@quinnyo
Copy link
Contributor

quinnyo commented Sep 24, 2023

Renaming it should at least indicate that it doesn't do a radians-equivalent of the "degrees" hint.

Might I suggest using 'to' instead of 'as' so as to match the conversion functions (rad_to_deg(float)): "radians_to_degrees" or even "rad_to_deg".

Also, it's not that important but you can already export radians -- it's just exporting a float normally?

@AThousandShips
Copy link
Member Author

Might I suggest using 'to' instead of 'as'

Already discussed and rejected as it implies the value is modified as opposed to just represented differently

doc/classes/@GlobalScope.xml Outdated Show resolved Hide resolved
Comment on lines +2702 to +2706
#ifdef DISABLE_DEPRECATED
bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians_as_degrees") != -1;
#else
bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1;
#endif // DISABLE_DEPRECATED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to test both in the case where DISABLE_DEPRECATED is not defined. Supporting deprecated syntax doesn't mean not supporting the new syntax, it means supporting both (new first, and fallback to deprecated).

Copy link
Member Author

@AThousandShips AThousandShips Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well prop_info.hint_string.find("radians") != -1 is true if prop_info.hint_string.find("radians_as_degrees") != -1

I originally added both but then realized that one is superfluous

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Granted it will allow anything including radians but I'm not sure how to test cleanly here for whole words, and the full phrase would also accept things like aaaaradians_as_degreesaaaa

@akien-mga akien-mga removed this from the 4.x milestone Sep 25, 2023
@akien-mga akien-mga added this to the 4.2 milestone Sep 25, 2023
@akien-mga akien-mga merged commit e4cfd4e into godotengine:master Sep 25, 2023
15 checks passed
@AThousandShips AThousandShips deleted the radian_fix branch September 25, 2023 15:21
@akien-mga
Copy link
Member

Thanks!

@AThousandShips
Copy link
Member Author

Thank you!

fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jun 27, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jun 28, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jun 28, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jul 9, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jul 9, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jul 9, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jul 9, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
fpdotmonkey added a commit to fpdotmonkey/gdext that referenced this pull request Jul 9, 2024
`radians_as_degrees` was added in Godot [4.2][1] to replace `radians`
with identical functionality and a better name.  `suffix` was added in
[4.0][2] and was seemingly missed when `#[export(range)]` was first
implemented.

This is the first instance where Godot has deprecated an API and gdext
has needed to implement it.  Hopefully this will serve as a useful
template for future work.

This also fixes a previously unknown bug where a `KEY=VALUE` expression
in the third slot of `range = (...)` would yield strange error messages.

[1]: godotengine/godot#82195
[2]: godotengine/godot#50009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@export_range "radians" does not work as documentation suggests
5 participants