From b835cfb551420d2fb7a3ee8e2df6082c12483b5e Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Mon, 11 May 2020 12:40:16 +0100 Subject: [PATCH] Fix 'physicsw' may be used uninitialized warning in csg_shape.cpp --- modules/csg/csg_shape.cpp | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 701c45a5d79..a5b664eeabe 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -346,20 +346,12 @@ void CSGShape3D::_update_shape() { } } - //fill arrays - Vector physics_faces; - bool fill_physics_faces = false; + // Update collision faces. if (root_collision_shape.is_valid()) { + + Vector physics_faces; physics_faces.resize(n->faces.size() * 3); - fill_physics_faces = true; - } - - { - Vector3 *physicsw; - - if (fill_physics_faces) { - physicsw = physics_faces.ptrw(); - } + Vector3 *physicsw = physics_faces.ptrw(); for (int i = 0; i < n->faces.size(); i++) { @@ -369,10 +361,22 @@ void CSGShape3D::_update_shape() { SWAP(order[1], order[2]); } - if (fill_physics_faces) { - physicsw[i * 3 + 0] = n->faces[i].vertices[order[0]]; - physicsw[i * 3 + 1] = n->faces[i].vertices[order[1]]; - physicsw[i * 3 + 2] = n->faces[i].vertices[order[2]]; + physicsw[i * 3 + 0] = n->faces[i].vertices[order[0]]; + physicsw[i * 3 + 1] = n->faces[i].vertices[order[1]]; + physicsw[i * 3 + 2] = n->faces[i].vertices[order[2]]; + } + + root_collision_shape->set_faces(physics_faces); + } + + //fill arrays + { + for (int i = 0; i < n->faces.size(); i++) { + + int order[3] = { 0, 1, 2 }; + + if (n->faces[i].invert) { + SWAP(order[1], order[2]); } int mat = n->faces[i].material; @@ -458,10 +462,6 @@ void CSGShape3D::_update_shape() { root_mesh->surface_set_material(idx, surfaces[i].material); } - if (root_collision_shape.is_valid()) { - root_collision_shape->set_faces(physics_faces); - } - set_base(root_mesh->get_rid()); } AABB CSGShape3D::get_aabb() const {