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

[Editor] Add support for displaying unsigned integers in the inspector #89529

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Mar 15, 2024

Added these hints to shader uniforms, which is what inspired this improvement

Also made improvements to handling of vector inspector

Still in progress with some details to work out, but basically ready, works well with the specific use case, limited at the moment but useful for the specific use of handling shaders, where editing unsigned values is very difficult from the editor

Considering it a feature, but it technically covers a broken or missing editor feature, I think it speaks for itself in this format, but can open a proposal if desired, but I don't think there's anything more to discuss except implementation details

It's of very limited use for int but for PackedInt32Array and Vector2/3/4i it's very potent

See for background:


@@ -2764,7 +2764,7 @@
<constant name="PROPERTY_HINT_RANGE" value="1" enum="PropertyHint">
Hints that an [int] or [float] property should be within a range specified via the hint string [code]"min,max"[/code] or [code]"min,max,step"[/code]. The hint string can optionally include [code]"or_greater"[/code] and/or [code]"or_less"[/code] to allow manual input going respectively above the max or below the min values.
[b]Example:[/b] [code]"-360,360,1,or_greater,or_less"[/code].
Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians_as_degrees"[/code] for editing radian angles in degrees (the range values are also in degrees), [code]"degrees"[/code] to hint at an angle and [code]"hide_slider"[/code] to hide the slider.
Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians_as_degrees"[/code] for editing radian angles in degrees (the range values are also in degrees), [code]"degrees"[/code] to hint at an angle and [code]"hide_slider"[/code] to hide the slider, and [code]"display_unsigned"[/code] to allow signed integers to be displayed as unsigned (this is especially useful with [PackedInt32Array]).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians_as_degrees"[/code] for editing radian angles in degrees (the range values are also in degrees), [code]"degrees"[/code] to hint at an angle and [code]"hide_slider"[/code] to hide the slider, and [code]"display_unsigned"[/code] to allow signed integers to be displayed as unsigned (this is especially useful with [PackedInt32Array]).
Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians_as_degrees"[/code] for editing radian angles in degrees (the range values are also in degrees), [code]"degrees"[/code] to hint at an angle, [code]"hide_slider"[/code] to hide the slider, and [code]"display_unsigned"[/code] to allow signed integers to be displayed as unsigned (this is especially useful with [PackedInt32Array]).

"and" appears twice.

@@ -49,7 +49,7 @@ class TypedArray;

enum PropertyHint {
PROPERTY_HINT_NONE, ///< no hint provided.
PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_less][,hide_slider][,radians_as_degrees][,degrees][,exp][,suffix:<keyword>] range.
PROPERTY_HINT_RANGE, ///< hint_text = "min,max[,step][,or_greater][,or_less][,hide_slider][,radians_as_degrees][,degrees][,exp][,display_unsigned][,suffix:<keyword>] range.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should go beyond just display_unsigned (which is only about display) to something more like treat_as_unsigned or similar name (which is more about how to interpret the data)?

There's a couple of places in Godot's API where we treat the value of an integer as unsigned, but we don't have a way to formally mark it as such. This has come up in the context of GDExtension a number of times. We've decided to assume that bitfields are unsigned, which covers many of these cases. But having a property hint like this would help with any remaining ones.

cc @Bromeon

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, would be interested in looking at it, could name it that way here and leave things open for future expansion

Added these hints to shader uniforms, which is what inspired this
improvement

Also made improvements to handling of vector inspector
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.

Editor interpreting unsigned uvec shader uniform parameters as signed
3 participants