Unverified Commit 6d46d2fe by Rémi Verschelde Committed by GitHub

Merge pull request #38672 from madmiraal/fix-physicsw-warning

Fix 'physicsw' may be used uninitialized warning in csg_shape.cpp
parents 0a695456 b835cfb5
...@@ -346,21 +346,31 @@ void CSGShape3D::_update_shape() { ...@@ -346,21 +346,31 @@ void CSGShape3D::_update_shape() {
} }
} }
//fill arrays // Update collision faces.
Vector<Vector3> physics_faces;
bool fill_physics_faces = false;
if (root_collision_shape.is_valid()) { if (root_collision_shape.is_valid()) {
Vector<Vector3> physics_faces;
physics_faces.resize(n->faces.size() * 3); physics_faces.resize(n->faces.size() * 3);
fill_physics_faces = true; Vector3 *physicsw = physics_faces.ptrw();
}
{ for (int i = 0; i < n->faces.size(); i++) {
Vector3 *physicsw;
int order[3] = { 0, 1, 2 };
if (n->faces[i].invert) {
SWAP(order[1], order[2]);
}
if (fill_physics_faces) { physicsw[i * 3 + 0] = n->faces[i].vertices[order[0]];
physicsw = physics_faces.ptrw(); 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++) { for (int i = 0; i < n->faces.size(); i++) {
int order[3] = { 0, 1, 2 }; int order[3] = { 0, 1, 2 };
...@@ -369,12 +379,6 @@ void CSGShape3D::_update_shape() { ...@@ -369,12 +379,6 @@ void CSGShape3D::_update_shape() {
SWAP(order[1], order[2]); 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]];
}
int mat = n->faces[i].material; int mat = n->faces[i].material;
ERR_CONTINUE(mat < -1 || mat >= face_count.size()); ERR_CONTINUE(mat < -1 || mat >= face_count.size());
int idx = mat == -1 ? face_count.size() - 1 : mat; int idx = mat == -1 ? face_count.size() - 1 : mat;
...@@ -458,10 +462,6 @@ void CSGShape3D::_update_shape() { ...@@ -458,10 +462,6 @@ void CSGShape3D::_update_shape() {
root_mesh->surface_set_material(idx, surfaces[i].material); 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()); set_base(root_mesh->get_rid());
} }
AABB CSGShape3D::get_aabb() const { AABB CSGShape3D::get_aabb() const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment