[CG Pipeline] Refactor

This commit is contained in:
brothermechanic 2023-11-13 13:07:33 +00:00 committed by Igor Brylyov
parent 6538f70d54
commit b3612d8655
23 changed files with 634 additions and 645 deletions

View file

@ -21,16 +21,16 @@ import bpy
import math
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
def setup_meshes(obj_names, cleanup=False, sharpness=False, shading=False):
''' Setup raw meshes list after importing '''
logger.info('Hightpoly meshes setup launched...')
fixed_obj_names = []
for obj_name in obj_names:
obj = bpy.data.objects[obj_name]
if not obj.type == 'MESH':
if not bpy.data.objects.get(obj_name):
continue
obj = bpy.data.objects[obj_name]
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(state=True)
bpy.context.view_layer.objects.active = obj
@ -58,7 +58,7 @@ def setup_meshes(obj_names, cleanup=False, sharpness=False, shading=False):
bpy.ops.object.mode_set(mode='OBJECT')
if shading:
# fix shading
# fix shading TODO
bpy.ops.object.shade_smooth()
bpy.context.view_layer.objects.active.data.use_auto_smooth = 1
bpy.context.view_layer.objects.active.modifiers.new(type='DECIMATE', name='decimate')
@ -69,4 +69,6 @@ def setup_meshes(obj_names, cleanup=False, sharpness=False, shading=False):
bpy.context.object.modifiers['triangulate'].keep_custom_normals = 1
bpy.context.object.modifiers['triangulate'].show_expanded = 0
return logger.info('Setup of %s hightpoly meshes is finished!', len(obj_names))
fixed_obj_names.append(obj_name)
return logger.info('Setup of %s hightpoly meshes is finished!', len(fixed_obj_names))