From 26318f3bd1b9fa9c7b7708cbef95b4cee56f1718 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 5 Oct 2019 10:30:13 +0300 Subject: [PATCH] Fix Vector3 ambiguities and out of bounds init. --- core/math/vector3.cpp | 4 ++-- editor/import/editor_scene_importer_gltf.cpp | 2 +- main/tests/test_math.cpp | 4 ++-- modules/assimp/editor_scene_importer_assimp.cpp | 3 +-- servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp | 3 +-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 71ff79c0fca..353b2acd168 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -103,7 +103,7 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, Vector3 out; out = 0.5 * ((p1 * 2.0) + (-p0 + p2) * t + - (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; } @@ -122,7 +122,7 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c Vector3 out; out = 0.5 * ((p1 * 2.0) + (-p0 + p2) * t + - (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + + (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; } diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 65da85b684c..c0d84b61b4c 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2618,7 +2618,7 @@ struct EditorSceneImporterGLTFInterpolate { const float t2 = t * t; const float t3 = t2 * t; - return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); + return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); } T bezier(T start, T control_1, T control_2, T end, float t) { diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index af537fb3f47..2c4ba08c6db 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -618,8 +618,8 @@ MainLoop *test() { print_line("minus: " + (Vector3(1, 2, 3) - Vector3(Vector3(4, 5, 7)))); print_line("mul: " + (Vector3(1, 2, 3) * Vector3(Vector3(4, 5, 7)))); print_line("div: " + (Vector3(1, 2, 3) / Vector3(Vector3(4, 5, 7)))); - print_line("mul scalar: " + (Vector3(1, 2, 3) * 2)); - print_line("premul scalar: " + (2 * Vector3(1, 2, 3))); + print_line("mul scalar: " + (Vector3(1, 2, 3) * 2.0)); + print_line("premul scalar: " + (2.0 * Vector3(1, 2, 3))); print_line("div scalar: " + (Vector3(1, 2, 3) / 3.0)); print_line("length: " + rtos(Vector3(1, 2, 3).length())); print_line("length squared: " + rtos(Vector3(1, 2, 3).length_squared())); diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 7a84a5329d7..2e653f4c5d9 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -167,8 +167,7 @@ struct EditorSceneImporterAssetImportInterpolate { float t2 = t * t; float t3 = t2 * t; - return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + - (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); + return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); } T bezier(T start, T control_1, T control_2, T end, float t) { diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp index b6228bf1652..000fdfda0c6 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -517,9 +517,8 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ push_constant.color_texture_pixel_size[0] = 0; push_constant.color_texture_pixel_size[1] = 0; + push_constant.pad[0] = 0; push_constant.pad[1] = 0; - push_constant.pad[2] = 0; - push_constant.pad[3] = 0; push_constant.lights[0] = 0; push_constant.lights[1] = 0;