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

Add Vector2i.MAX as equivalent to Vector2.INF #7348

Closed
KoBeWi opened this issue Jul 21, 2023 · 5 comments · Fixed by godotengine/godot#81741
Closed

Add Vector2i.MAX as equivalent to Vector2.INF #7348

KoBeWi opened this issue Jul 21, 2023 · 5 comments · Fixed by godotengine/godot#81741
Milestone

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Jul 21, 2023

Describe the project you are working on

A sophisticated GDScript plugin.

Describe the problem or limitation you are having in your project

I'm using Vector2i and Vector3i in my project and I need a "null value" for them. With float vectors you can use Vector.INF, but integer vectors don't have equivalent. I must rely on custom constants:

const VECTOR2INF = Vector2i(999999, 99999999)
const VECTOR3INF = Vector3i(999999, 99999999, 99999999)

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

Add Vector2i.MAX constant, which is Vector2i(INT_MAX, INT_MAX) - basically integer equivalent of infinity.
The same constant would be added to Vector3i and Vector4i.

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

_VariantCall::add_variant_constant(Variant::VECTOR2I, "MAX", Vector2i(INT_MAX, INT_MAX));
_VariantCall::add_variant_constant(Variant::VECTOR3I, "MAX", Vector3i(INT_MAX, INT_MAX, INT_MAX));
_VariantCall::add_variant_constant(Variant::VECTOR4I, "MAX", Vector4i(INT_MAX, INT_MAX, INT_MAX, INT_MAX));

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

Yes, with custom constants. But it's inconvenient, because they can't be global, so the code becomes verbose.

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

Only the workaround can be an addon.

@Calinou
Copy link
Member

Calinou commented Jul 21, 2023

MIN constants should probably be added as well.

@ghost
Copy link

ghost commented Jul 21, 2023

Some climits constants should probably be added as well.

@kleonc
Copy link
Member

kleonc commented Jul 21, 2023

Related: #2411 (currently there are no min/max constants for ints exposed whatsoever).

@Chaosus
Copy link
Member

Chaosus commented Jul 22, 2023

Note that Vector2i/3i uses signed 32-bit integer, so INT_MAX value will be (2,147,483,647) for them (while the size of standard integer in Godot is signed 64-bit which is much larger).

@Calinou
Copy link
Member

Calinou commented Jul 23, 2023

Note that Vector2i/3i uses signed 32-bit integer, so INT_MAX value will be (2,147,483,647) for them (while the size of standard integer in Godot is signed 64-bit which is much larger).

Note that if #7210 is implemented, INT_MAX would vary depending on the build type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants