diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-11 23:48:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 23:48:24 +0100 |
commit | d5076439e44e6eab5732e1d2fc0f30bb6f34e5f9 (patch) | |
tree | 6bc26eef0b75c81a99116c529f85af76f30266dc /modules/csg | |
parent | f94ada39b35bfc2c313528bed23112b74cf4c97a (diff) | |
parent | ec2984f7c7b9543b1353d3a605c7fcdfe5642703 (diff) |
Merge pull request #59039 from MythTitans/fix-smoothed-normals-computation
Fix mixed smoothed and non-smoothed face normals computation for CSG shapes
Diffstat (limited to 'modules/csg')
-rw-r--r-- | modules/csg/csg_shape.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 34f3ba9296..be9bf9538f 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -303,17 +303,19 @@ void CSGShape3D::_update_shape() { ERR_CONTINUE(mat < -1 || mat >= face_count.size()); int idx = mat == -1 ? face_count.size() - 1 : mat; - Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]); + if (n->faces[i].smooth) { + Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]); - for (int j = 0; j < 3; j++) { - Vector3 v = n->faces[i].vertices[j]; - Vector3 add; - if (vec_map.lookup(v, add)) { - add += p.normal; - } else { - add = p.normal; + for (int j = 0; j < 3; j++) { + Vector3 v = n->faces[i].vertices[j]; + Vector3 add; + if (vec_map.lookup(v, add)) { + add += p.normal; + } else { + add = p.normal; + } + vec_map.set(v, add); } - vec_map.set(v, add); } face_count.write[idx]++; |