1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix usages of mesh simplification functions in float=64 builds

This commit is contained in:
Marc Gilleron
2022-10-24 21:40:34 +01:00
parent ee43b7da28
commit 2aefdcc26e
5 changed files with 54 additions and 7 deletions

View File

@@ -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;
}