Godot-proposals: Data types with different precision

Created on 21 May 2020  路  6Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
2.5d beat'em up

Describe the problem or limitation you are having in your project:
I'm actually into the multiplayer coding and only now i realized that there are no precision choices for the data types, i was probably thinking about glsl data types... anyway having the possibility to lower the precision of the data would make the transmission of data faster and cheaper.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Like in other languages i want the possibility to choose the precision of at least int and float, after all while int and float are 64bit the float components of the vector types are 32 bit, so there are already different precisions in gdscript.
Smaller data would lead to less network usage and i guess faster encryption/decryption, save/load and so on.
I'm using int variables mostly as indices so they have relatively low values, using a 64bit integer for such a thing could be a waste in my case.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
It would work by writing something like float64, float32, float16 or maybe the same keywords used in glsl lowp, mediump and highp before the type, or whatever you think is best.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
I don't think so

Is there a reason why this should be core and not an add-on in the asset library?:
This is about core Godot data types, so it can't be an addon i guess.

core

Most helpful comment

@Calinou :
Thanks, https://github.com/godotengine/godot/pull/37200 seems really promising, about the compression thanks to you now i know which one i should use :) but i imagine that same compression with smaller data would be even better right?

All 6 comments

I think the networking part is already covered by https://github.com/godotengine/godot/pull/37200. Also, you can enable network compression to decrease bandwidth usage slightly (by about 10% on average from my testing).

@Calinou :
Thanks, https://github.com/godotengine/godot/pull/37200 seems really promising, about the compression thanks to you now i know which one i should use :) but i imagine that same compression with smaller data would be even better right?

On top of networking, memory usage is another big concern. The entirety of my world can be kept in an array of bytes, but I'm forced to use an array of ints, which blows up memory usage 8x for every tile. It's extremely limiting.

@Stumblinbear There's PoolByteArray already (PackedByteArray in 4.0). Doesn't that suit your needs?

Also, Godot 4.0 will offer both 32-bit and 64-bit precision for packed float and integer arrays. (You'll be able to choose on a per-array basis.)

@Calinou That unfortunately isn't doable for a variety of reasons. I use them in a couple places, but in a few other areas, it's just not possible without complicating the systems to an unnecessarily large degree.

@Calinou That unfortunately isn't doable for a variety of reasons. I use them in a couple places, but in a few other areas, it's just not possible without complicating the systems to an unnecessarily large degree.

This is just me being curious, what are a few cases where they don't work well?

Was this page helpful?
0 / 5 - 0 ratings