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

Improve QOL by including additional addition/mutliplication arithmetic operators for ImVec2 #8258

Conversation

ArashPartow
Copy link

No description provided.

@ocornut
Copy link
Owner

ocornut commented Dec 23, 2024

Hello Arash,

My stance is that ImVec2 x float is justified but addition/subtraction isn’t. It’s an extremely rare and odd operation to perform, and adding those create a wider surface for mistakes being made and not reported by compilers. I don’t therefore believe they are a good idea.

Not having float x imvec2 is more arbitrary and arguable but since imvec2 x float is rare enough it felt like a legitimate trade off to explicitly only support one.

@ArashPartow
Copy link
Author

@ocornut I only added addition and multiplication. As subtraction would have a different meaning.

The idea was to allow for the following operations:

ImVec2 v1;
ImVec2 v2;

v1 = 1.234 + v2;
v1 = 1.234 * v2;

That being said, I'm happy to remove the addition operator from the PR. Let me know, otherwise feel free to close the PR.

@ocornut
Copy link
Owner

ocornut commented Jan 6, 2025

Thanks for clarifying, sorry for assuming - was in there.
As mentioned I am firmly against ImVec2+float as I believe it creates much larger surface for user mistake.

Not having float x imvec2 is more arbitrary and arguable but since imvec2 x float is rare enough it felt like a legitimate trade off to explicitly only support one.

I stand by this, this is a rare enough operation, halving the error surface is worth it.
I added a comment to clarify:

// - We intentionally provide ImVec2*float but not float*ImVec2: this is rare enough and we want to reduce the surface for possible user mistake.

Afaik you are free to implement them in your codebase if you like!

@ocornut ocornut closed this Jan 6, 2025
@ArashPartow
Copy link
Author

All good, thanks for considering it and providing an explanation.

happy new year 👍

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.

2 participants