-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
Add half precision floating point support to StreamPeer
and FileAccess
#97716
base: master
Are you sure you want to change the base?
Add half precision floating point support to StreamPeer
and FileAccess
#97716
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.
Shouldnt we extend it to FileAccess and PackedByteArray now given the chance to do so?
1f108d2
to
e00cbe8
Compare
1aea23d
to
19fd983
Compare
We should change the title and the topics since now it also modifies |
StreamPeer
StreamPeer
and FileAccess
19fd983
to
58fe877
Compare
Friendly remainder |
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.
Tested locally, it works as expected.
Thanks for adding unit tests 🙂
extends Node2D
func _ready() -> void:
var fa := FileAccess.open("user://output.bin", FileAccess.WRITE_READ)
fa.store_half(0.123456)
fa.store_float(0.123456)
fa.store_double(0.123456)
fa.store_double(-12345)
fa.store_float(-12345)
fa.store_half(-12345)
OS.shell_open(ProjectSettings.globalize_path("user://"))
get_tree().quit()
Using ImHex to view the file written by Godot:
Note the lack of precision on the second example, as half floats can't represent all integer values outside of [-2048; 2048]
.
Closes godotengine/godot-proposals#5983 Adds put/get methods to `StreamPeer` that handles half precision floating point values. Adds endode/decode half precision floating point to `marshalls`. Adds `get_half` and `store_half` to `FileAccess` Co-Authored-By: "Alfonso J. Ramos" <[email protected]>
58fe877
to
189ee5f
Compare
Closes godotengine/godot-proposals#5983
Adds put/get methods to
StreamPeer
that handles half precision floating point values.Adds endode/decode half precision floating point to
marshalls
.This PR is rebase into master of #78872. Also I added unit tests to it.