summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-04-28 14:28:31 +0200
committerGitHub <noreply@github.com>2020-04-28 14:28:31 +0200
commit39f7a4092533a600eeada6638016af8bd4bd2271 (patch)
treedc3ec9da0434f227c34d13c85e1327987beef755
parente71b05d365b35c889c53faaaa58e65f5efea4828 (diff)
parent9bd305bfe22f55bb1f0ac61d240b4ab0fcbb65f5 (diff)
Merge pull request #37163 from madmiraal/fix-csg-normal
Fix CSG vertex normal calculation.
-rw-r--r--modules/csg/csg_shape.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 5557da3014..d38ddf3f90 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -296,20 +296,18 @@ void CSGShape3D::_update_shape() {
int mat = n->faces[i].material;
ERR_CONTINUE(mat < -1 || mat >= face_count.size());
int idx = mat == -1 ? face_count.size() - 1 : mat;
- if (n->faces[i].smooth) {
- Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]);
+ 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;
- }
- vec_map.set(v, add);
+ 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);
}
face_count.write[idx]++;