Skip to content

Change inf, inf_neg, nan serialization to uppercase, and add INF_NEG GDScript constant #3398

@theraot

Description

@theraot

Describe the project you are working on

See #3390

Describe the problem or limitation you are having in your project

Most float literals can be typed verbatim in the code inspector. Except for inf, nan, and inf_neg. Instead we have to use INF, NAN and -INF.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Change the Variant serialization that was consolidated in godotengine/godot#47497 / godotengine/godot#47497 to use uppercase.

However, notice that platforms that were unaffected by godotengine/godot#40589 were already using the inf serialization. See godotengine/godot#40589 (comment)

Thus, this is a breaking change. Any scene saved with `inf` would fail to load. Perhaps this is acceptable since such scene would not be common. At least it should be acceptable for a version that is already braking stuff.

We can allow migration if we still parse the lower case versions along side the uppercase version, but only serialize to the uppercase versions.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Since the inspector uses the float serialization, with the proposed change Infinity would show as INF (instead of inf), and we would be able to type it as we see it, since INF is already also a GDScript constant. The same logic applies to NAN. Negative infinity would be INF_NEG, which would be a new GDScript constant.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It is not possible to change the Variant serialization with a script.

Is there a reason why this should be core and not an add-on in the asset library?

It is not possible to change the Variant serialization with a script.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions