Skip to content

Commit

Permalink
Fix for GDScript float (which is double) semantic conversion into 32 …
Browse files Browse the repository at this point in the history
…bit float
  • Loading branch information
pkpro committed Aug 11, 2023
1 parent f76e2bd commit 3266fe5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions core/io/marshalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1829,17 +1829,14 @@ Error to_raw_bytes(const Variant &p_variant, PackedByteArray &r_out_sink) {
memcpy(out.ptrw() + offset, &v, sizeof(v));
} break;
case Variant::FLOAT: {
#ifdef REAL_T_IS_DOUBLE
double v = p_variant;
size_t offset = out.size();
out.resize(out.size() + sizeof(v));
memcpy(out.ptrw() + offset, &v, sizeof(v));
#else
// always convert to float at a cost of precision
// while 64 bit values are inpractical in shaders

Check failure on line 1833 in core/io/marshalls.cpp

View workflow job for this annotation

GitHub Actions / 📊 Static checks / Code style, file formatting, and docs

inpractical ==> impractical
// and there is no easy way to know what precision
// a programmer needs in GDScript.
float v = p_variant;
size_t offset = out.size();
out.resize(out.size() + sizeof(v));
memcpy(out.ptrw() + offset, &v, sizeof(v));
#endif
} break;
case Variant::VECTOR2: {
Vector2 v = p_variant;
Expand Down

0 comments on commit 3266fe5

Please sign in to comment.