franMarz / TexTools-Blender

TexTools is a UV and Texture toolset created several years ago for Blender and Max by @renderhjs. In this open repository, originally created by @SavMartin, we develop the current version of this popular Blender add-on.
Other
2.02k stars 137 forks source link

Simplify Some Code #108

Closed ldo closed 8 months ago

ldo commented 3 years ago

I just noticed this in op_color_assign.py:

if len(obj.data.vertex_colors) > 0 :
    vclsNames = [vcl.name for vcl in obj.data.vertex_colors]
    if 'TexTools_colorID' in vclsNames:
        obj.data.vertex_colors['TexTools_colorID'].active = True
    else:
        obj.data.vertex_colors.new(name='TexTools_colorID')
        obj.data.vertex_colors['TexTools_colorID'].active = True
else:
    obj.data.vertex_colors.new(name='TexTools_colorID')

It can be simplified to:

if 'TexTools_colorID' not in obj.data.vertex_colors :
    obj.data.vertex_colors.new(name='TexTools_colorID')
obj.data.vertex_colors['TexTools_colorID'].active = True

I see one or two other similar circumlocutions in that file, too.

franMarz commented 3 years ago

Yes, some modules have plenty of these issues.

franMarz commented 8 months ago

This will be naturally addressed during the ongoing process of refactoring the modules. Closing.