-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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 length and length_squared to Vector2i/3i #53618
Conversation
It would be good to add tests to validate that the methods work properly. |
74c351e
to
0ca9024
Compare
61c1a77
to
e449ce2
Compare
e449ce2
to
653679b
Compare
core/math/vector3i.h
Outdated
double Vector3i::length() const { | ||
int64_t x2 = x * int64_t(x); | ||
int64_t y2 = y * int64_t(y); | ||
int64_t z2 = z * int64_t(z); | ||
|
||
return Math::sqrt(double(x2 + y2 + z2)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be sqrt
of length_squared()
I guess unless we're really concerned that it wouldn't be inlined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done this way to be consistent with how it's currently done in Vector3, but I agree that it's simpler to just take the sqrt
of length_squared()
, so updated. I left Vector3 alone.
PR meeting: We decided to only implement |
653679b
to
2c52f16
Compare
Thanks! |
See godotengine/godot-proposals#2297 (does not close it).