summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-13 15:24:55 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-13 15:24:55 +0200
commit9eb8eb5f7de1ae9baef9750c6611fcfdeeec12b6 (patch)
tree54086f691e73eb05864cd66110d39cc0ea1acaaa /scene
parent58822717ff659ece3f290122354db20c103d2c59 (diff)
parent491ec622f641c28c919c9f8d1b0fbaad014e4714 (diff)
Merge pull request #67336 from jbcolli2/Normal-of-CylinderMesh
Fix bug in CylinderMesh when computing normals
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/primitive_meshes.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 7d0336cff3..eb83a37c7b 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -771,6 +771,7 @@ void CylinderMesh::create_mesh_array(Array &p_arr, float top_radius, float botto
thisrow = 0;
prevrow = 0;
+ const real_t side_normal_y = (bottom_radius - top_radius) / height;
for (j = 0; j <= (rings + 1); j++) {
v = j;
v /= (rings + 1);
@@ -789,7 +790,7 @@ void CylinderMesh::create_mesh_array(Array &p_arr, float top_radius, float botto
Vector3 p = Vector3(x * radius, y, z * radius);
points.push_back(p);
- normals.push_back(Vector3(x, 0.0, z));
+ normals.push_back(Vector3(x, side_normal_y, z).normalized());
ADD_TANGENT(z, 0.0, -x, 1.0)
uvs.push_back(Vector2(u, v * 0.5));
point++;