Skip to content

Drop floating point noise in color values - #44

Merged
EliCDavis merged 1 commit into
EliCDavis:mainfrom
alexykot:bugfix/colors-drop-float-noise
Dec 6, 2024
Merged

Drop floating point noise in color values#44
EliCDavis merged 1 commit into
EliCDavis:mainfrom
alexykot:bugfix/colors-drop-float-noise

Conversation

@alexykot

@alexykot alexykot commented Dec 6, 2024

Copy link
Copy Markdown
Contributor

This drops the floating point long trails of meaningless dust values in serialised color values.

I've opted to hardcode it to 3 decimal points because this should fully cover resolution provided by color.Color integer values. So no higher precision is necessary here, and this threshold is unlikely to ever change.

This only affects color values since those have well known precision, limited by RGBA data structure. No other values affected.


This actually doesn't affect my case, because draco transcoder already takes care of it, and even without it the difference is not huge. But it was also very easy to do, so I've dropped this one in.

It didn't need JSON serialisation override, JSON is smart enough to not output trailing zeros, so correct rounding was enough here.

@EliCDavis EliCDavis left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man it was that easy huh. Man I was afraid I was going to have to create a special datatype that overrides how it get's serialized to JSON.

Thanks for this!

@EliCDavis
EliCDavis merged commit 48d1610 into EliCDavis:main Dec 6, 2024
@alexykot
alexykot deleted the bugfix/colors-drop-float-noise branch December 6, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants