-
-
Notifications
You must be signed in to change notification settings - Fork 22.1k
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
Fix Color::get_{r,g,b,a}8
#47726
Fix Color::get_{r,g,b,a}8
#47726
Conversation
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.
This is good, but while we're changing these lines, this can be better. Color always uses 32-bit floats, so these should have f
as a suffix (or we could also do 255
without the .0
for the same behavior, but 255.0f
makes our intentions clear):
_FORCE_INLINE_ void set_r8(int32_t r8) { r = (CLAMP(r8, 0, 255) / 255.0); }
_FORCE_INLINE_ int32_t get_r8() const { return int32_t(CLAMP(Math::round(r * 255.0f), 0.0f, 255.0f)); }
_FORCE_INLINE_ void set_g8(int32_t g8) { g = (CLAMP(g8, 0, 255) / 255.0); }
_FORCE_INLINE_ int32_t get_g8() const { return int32_t(CLAMP(Math::round(g * 255.0f), 0.0f, 255.0f)); }
_FORCE_INLINE_ void set_b8(int32_t b8) { b = (CLAMP(b8, 0, 255) / 255.0); }
_FORCE_INLINE_ int32_t get_b8() const { return int32_t(CLAMP(Math::round(b * 255.0f), 0.0f, 255.0f)); }
_FORCE_INLINE_ void set_a8(int32_t a8) { a = (CLAMP(a8, 0, 255) / 255.0); }
_FORCE_INLINE_ int32_t get_a8() const { return int32_t(CLAMP(Math::round(a * 255.0f), 0.0f, 255.0f)); }
Can we do this: _FORCE_INLINE_ int32_t get_r8() const { return CLAMP(int32_t(Math::round(r * 255.0f)), 0, 255); } ? |
The core devs did the opposite in this commit, so I don't think we should undo it: 771b3c5#diff-338a6122d06ba451b648508685a84917a457cf904b0aa28e736c62fe4dd950b6R197 |
Thanks! |
In #47022 you state that it affects Lines 1664 to 1671 in 137f71f
Lines 2507 to 2518 in 137f71f
If the issue is still reproducible in |
@akien-mga The problem is reproduced in 3.3. But it seems that the reason is really something else. I can't figure out what. |
Closes #47022.