Add Mesh Extra Objects: make solids use ngons #105128

Merged
Damien Picard merged 3 commits from pioverfour/blender-addons:dp_solids_ngons into main 2024-01-16 22:06:39 +01:00
Showing only changes of commit 9550a3cef0 - Show all commits

View File

@ -16,35 +16,6 @@ from bpy.props import (
from bpy_extras.object_utils import object_data_add from bpy_extras.object_utils import object_data_add
# this function creates a chain of quads and, when necessary, a remaining tri
# for each polygon created in this script. be aware though, that this function
# assumes each polygon is convex.
# poly: list of faces, or a single face, like those
# needed for mesh.from_pydata.
# returns the tessellated faces.
def createPolys(poly):
# check for faces
if len(poly) == 0:
return []
# one or more faces
if type(poly[0]) == type(1):
poly = [poly] # if only one, make it a list of one face
faces = []
for i in poly:
L = len(i)
# let all faces of 3 or 4 verts be
if L < 5:
faces.append(i)
# split all polygons in half and bridge the two halves
else:
f = [[i[x], i[x + 1], i[L - 2 - x], i[L - 1 - x]] for x in range(L // 2 - 1)]
faces.extend(f)
if L & 1 == 1:
faces.append([i[L // 2 - 1 + x] for x in [0, 1, 2]])
return faces
# function to make the reduce function work as a workaround to sum a list of vectors # function to make the reduce function work as a workaround to sum a list of vectors
def vSum(list): def vSum(list):
@ -489,9 +460,6 @@ class Solids(bpy.types.Operator):
self.snub self.snub
) )
# turn n-gons in quads and tri's
faces = createPolys(faces)
# resize to normal size, or if keepSize, make sure all verts are of length 'size' # resize to normal size, or if keepSize, make sure all verts are of length 'size'
if self.keepSize: if self.keepSize:
rad = self.size / verts[-1 if self.dual else 0].length rad = self.size / verts[-1 if self.dual else 0].length