Skip to content

Commit

Permalink
Merge pull request #67336 from jbcolli2/Normal-of-CylinderMesh
Browse files Browse the repository at this point in the history
Fix bug in CylinderMesh when computing normals
  • Loading branch information
akien-mga committed Oct 13, 2022
2 parents 5882271 + 491ec62 commit 9eb8eb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scene/resources/primitive_meshes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++;
Expand Down

0 comments on commit 9eb8eb5

Please sign in to comment.