From 29d0a21011a0ee066a40f8416bc0c9ebb9644c0f Mon Sep 17 00:00:00 2001 From: Fabian Mathews Date: Sat, 17 Jun 2017 09:43:13 +0930 Subject: Fixed decompression of normals --- servers/visual_server.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 2f53465d11..127c744fad 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -465,7 +465,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ for (int i = 0; i < p_vertex_array_len; i++) { - uint8_t vector[4] = { + int8_t vector[4] = { CLAMP(src[i].x * 127, -128, 127), CLAMP(src[i].y * 127, -128, 127), CLAMP(src[i].z * 127, -128, 127), @@ -1233,11 +1233,12 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector::Write w = arr.write(); + const float multiplier = 1.f / 127.f; for (int j = 0; j < p_vertex_len; j++) { - const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]]; - w[j] = Vector3(float(v[0] / 255.0) * 2.0 - 1.0, float(v[1] / 255.0) * 2.0 - 1.0, float(v[2] / 255.0) * 2.0 - 1.0); + const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]]; + w[j] = Vector3(float(v[0]) * multiplier, float(v[1]) * multiplier, float(v[2]) * multiplier); } } else { PoolVector::Write w = arr.write(); -- cgit v1.2.3 From ff0ac9d916b7d2145a3bb000b3cf2be38c3937bc Mon Sep 17 00:00:00 2001 From: Fabian Mathews Date: Sat, 17 Jun 2017 10:47:25 +0930 Subject: Fixed decompression of vertex colors --- servers/visual_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 127c744fad..c71ef07be9 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1294,7 +1294,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, PoolVector::Write w = arr.write(); -- cgit v1.2.3