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

Expose Vector* component-wise min/max to scripting #7439

Closed
AThousandShips opened this issue Aug 3, 2023 · 3 comments · Fixed by godotengine/godot#80223
Closed

Expose Vector* component-wise min/max to scripting #7439

AThousandShips opened this issue Aug 3, 2023 · 3 comments · Fixed by godotengine/godot#80223

Comments

@AThousandShips
Copy link
Member

AThousandShips commented Aug 3, 2023

Describe the project you are working on

N/A

Describe the problem or limitation you are having in your project

Manually creating min/max vectors in GDScript is tedious and error prone, one use case is #7333 (comment)

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

The built-in functions accomplish this task directly, and adds parity with other already exposed cases such as floor, clamp, round, etc.

Having access to these would greatly reduce clutter, improve readability, and reduce errors

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

Expose the already existing component-wise min/max methods of these classes

I already have a branch ready for this

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

It can, but it is error prone

Vector2(min(a.x, b.x), min(a.y, b.y))
Vector3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z))
Vector4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.z))

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

It relates to binds in core

@rburing
Copy link
Member

rburing commented Aug 3, 2023

Please explain why one would want to perform these operations, preferably with concrete examples.

@AThousandShips
Copy link
Member Author

AThousandShips commented Aug 3, 2023

Here: #7333 (comment)

Generally cases like tracking min/max grouped, can be used for audio with vectors, there are also some places in the code base that would benefit from the already existing functions, like Geometry2D::is_point_in_polygon

It is also used in the engine in TileSetAtlasSourceEditor::_tile_atlas_control_gui_input, and in TileSet for example

@yosoyfreeman
Copy link

Please explain why one would want to perform these operations, preferably with concrete examples.

Just today i was trying to do this to get the maximum velocity vector along the axes.

@AThousandShips AThousandShips added this to the 4.x milestone Jan 13, 2024
@akien-mga akien-mga modified the milestones: 4.x, 4.3 May 2, 2024
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.

4 participants