summaryrefslogtreecommitdiff
path: root/core/io/marshalls.cpp
diff options
context:
space:
mode:
authorClay John <claynjohn@gmail.com>2023-01-02 12:33:44 -0700
committerGitHub <noreply@github.com>2023-01-02 12:33:44 -0700
commit61c7b7fb13f7cef8737d0a047db1c2340d1ce661 (patch)
treea99568a423305343923ffb2e7d477688239a03c7 /core/io/marshalls.cpp
parentb29bb11a4cb5ffcca6ddcc4d495656f146bfd22a (diff)
parent2aefdcc26eb98a0fb93f160dbd8f0789e77ae6c7 (diff)
Merge pull request #67853 from Zylann/fix_lods_with_doubles
Fix usages of mesh simplification functions in float=64 builds
Diffstat (limited to 'core/io/marshalls.cpp')
-rw-r--r--core/io/marshalls.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 9ba653e1a9..9f89f5d8c9 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -1813,3 +1813,24 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
return OK;
}
+
+Vector<float> vector3_to_float32_array(const Vector3 *vecs, size_t count) {
+ // We always allocate a new array, and we don't memcpy.
+ // We also don't consider returning a pointer to the passed vectors when sizeof(real_t) == 4.
+ // One reason is that we could decide to put a 4th component in Vector3 for SIMD/mobile performance,
+ // which would cause trouble with these optimizations.
+ Vector<float> floats;
+ if (count == 0) {
+ return floats;
+ }
+ floats.resize(count * 3);
+ float *floats_w = floats.ptrw();
+ for (size_t i = 0; i < count; ++i) {
+ const Vector3 v = vecs[i];
+ floats_w[0] = v.x;
+ floats_w[1] = v.y;
+ floats_w[2] = v.z;
+ floats_w += 3;
+ }
+ return floats;
+}