Skip to content

Make floating-point values in the inspector more permissive #10068

Open
@MrEgggga

Description

@MrEgggga

Describe the project you are working on

A 2D physics-based puzzle platformer

Describe the problem or limitation you are having in your project

I constantly run into issues when changing floating-point values in the inspector:

I mention the actual bugs to point out that these sort of stem from the over-restrictiveness of the Range class and the Godot inspector. However, they should probably be handled separately from this proposal.

Disallowing NaN and Infinity (godotengine/godot#81076) fixed a number of issues where the editor or games crashed when certain fields were set to infinite values, but in my opinion this was a stopgap solution and doesn't really do anything for cases when these fields could be set to NaN via script. In general, I don't see any reason for editing floating points to be this restrictive by default; generally the developer of a game knows what they're trying to do more than the editor does (they might be using NaN in one of their scripts as a special value because Godot currently has no easily-editable way of making optional types in the inspector; they might need a number to be accurate to more than a thousandth; etc.), and making things less restrictive by default in the editor doesn't make things worse for use cases which need the more restrictive behavior; the fields which cause huge problems when set to non-finite values can keep the behavior from godotengine/godot#81076.

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

Add options in the Range class which can remove some of these restrictions, and enable these by default for exported variables (but not for Range nodes in games).

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

  • Add a boolean field allow_infinite with default value false to the Range class that allows for non-finite values.
  • Add a boolean field allow_finer with default value false to the Range class that prevents rounding of values entered by typing into the field (using the slider in SpinBox or the up/down arrows would still round things to the step value).
  • Set both of these to true for float properties with no hint, and false by default with properties with hints, similar to allow_greater and allow_lesser. Add hints or_infinite, or_finer and ideally add these to existing properties as appropriate (but that can be done separately, after the features needed are implemented).

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

If a specific floating point value is needed that cannot be entered in the inspector (e.g. NaN, 0.12345, pi, 0), it is possible to edit the scene in an external editor and write the exact value in there; however, if the field is touched in the inspector (e.g. by selecting it and pressing Enter) it'll often be rounded again. Exact values can also be set in scripts or as the default export value, but these are kind of inflexible and cumbersome.

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

This is about changing some core behavior in the editor and is less of a "new feature" than a "fix."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions