Fix: Add Mesh Extra Objects: Inverted normals of solids when vertex positions are inverted #105123

Merged
Thomas Barlow merged 3 commits from Mysteryem/blender-addons:fix_mesh_extra_objects_solid_inverted_normals into main 2024-01-16 21:38:19 +01:00
Showing only changes of commit f07fee1b0b - Show all commits

View File

@ -52,8 +52,8 @@ def vSum(list):
# Get a copy of the input faces, but with the normals flipped by reversing the order of the vertex indices of each face.
def flipped_face_normals(faces):
return [list(reversed(vertex_indices)) for vertex_indices in faces]
def flippedFaceNormals(faces):
return [list(reversed(vertexIndices)) for vertexIndices in faces]
# creates the 5 platonic solids as a base for the rest
@ -152,7 +152,7 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
supposedSize = vSum(vInput[i] for i in fInput[0]).length / len(fInput[0])
vInput = [-i * supposedSize for i in vInput] # mirror it
# Inverting vInput turns the mesh inside-out, so normals need to be flipped.
return vInput, flipped_face_normals(fInput)
return vInput, flippedFaceNormals(fInput)
return source(plato)
elif 0 < vtrunc <= 0.5: # simple truncation of the source
vInput, fInput = source(plato)
@ -168,7 +168,7 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
return vInput, fInput
vInput = [-i * supposedSize for i in vInput]
# Inverting vInput turns the mesh inside-out, so normals need to be flipped.
return vInput, flipped_face_normals(fInput)
return vInput, flippedFaceNormals(fInput)
# generate connection database
vDict = [{} for i in vInput]
@ -277,9 +277,9 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
supposedSize *= len(fvOutput[0]) / vSum(vOutput[i] for i in fvOutput[0]).length
vOutput = [-i * supposedSize for i in vOutput]
# Inverting vOutput turns the mesh inside-out, so normals need to be flipped.
flip_normals = True
flipNormals = True
else:
flip_normals = False
flipNormals = False
# create new faces by replacing old vert IDs by newly generated verts
ffOutput = [[] for i in fInput]
@ -299,8 +299,8 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
if not dual:
fOutput = fvOutput + feOutput + ffOutput
if flip_normals:
fOutput = flipped_face_normals(fOutput)
if flipNormals:
fOutput = flippedFaceNormals(fOutput)
return vOutput, fOutput
else:
# do the same procedure as above, only now on the generated mesh