Fixup normals in add_mesh_solid generated meshes. #105117
@ -325,6 +325,26 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
|
|||||||
return dvOutput, dfOutput
|
return dvOutput, dfOutput
|
||||||
|
|
||||||
|
|
||||||
|
def fixup_normals(obj):
|
||||||
|
"""
|
||||||
|
Some of the presets have their faces with wrong normals. This fixes them.
|
||||||
|
"""
|
||||||
|
curr_active = bpy.context.view_layer.objects.active
|
||||||
|
|
||||||
|
# Select new object,
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = obj
|
||||||
|
|
||||||
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
|
bpy.ops.mesh.select_all(action='SELECT') # select all faces
|
||||||
|
bpy.ops.mesh.normals_make_consistent(inside=False)
|
||||||
|
bpy.ops.object.editmode_toggle() # return to object mode
|
||||||
|
|
||||||
|
# Reset to previously active
|
||||||
|
bpy.context.view_layer.objects.active = curr_active
|
||||||
|
|
||||||
|
|
||||||
class Solids(bpy.types.Operator):
|
class Solids(bpy.types.Operator):
|
||||||
"""Add one of the (regular) solids (mesh)"""
|
"""Add one of the (regular) solids (mesh)"""
|
||||||
bl_idname = "mesh.primitive_solid_add"
|
bl_idname = "mesh.primitive_solid_add"
|
||||||
@ -509,7 +529,10 @@ class Solids(bpy.types.Operator):
|
|||||||
# Update mesh geometry after adding stuff.
|
# Update mesh geometry after adding stuff.
|
||||||
mesh.update()
|
mesh.update()
|
||||||
|
|
||||||
object_data_add(context, mesh, operator=None)
|
obj = object_data_add(context, mesh, operator=None)
|
||||||
|
|
||||||
|
fixup_normals(obj)
|
||||||
|
|
||||||
# object generation done
|
# object generation done
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
Loading…
Reference in New Issue
Block a user