Fix #134451: SVG: Reuse material data on SVG Import
Reuse SVG Material and prevent creation of duplicate material multiple times. Issue occurred because the check for a duplicate material was placed too early. Co-authored-by: Nig3l <nig3lpro@gmail.com> Pull Request: https://projects.blender.org/blender/blender/pulls/134529
This commit is contained in:
@@ -180,9 +180,6 @@ def SVGGetMaterial(color, context):
|
||||
materials = context['materials']
|
||||
rgb_re = re.compile(r'^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,(\d+)\s*\)\s*$')
|
||||
|
||||
if color in materials:
|
||||
return materials[color]
|
||||
|
||||
diff = None
|
||||
if color.startswith('#'):
|
||||
color = color[1:]
|
||||
@@ -206,6 +203,9 @@ def SVGGetMaterial(color, context):
|
||||
diffuse_color[1] = srgb_to_linearrgb(diffuse_color[1])
|
||||
diffuse_color[2] = srgb_to_linearrgb(diffuse_color[2])
|
||||
|
||||
if color in materials:
|
||||
return materials[color]
|
||||
|
||||
mat = bpy.data.materials.new(name='SVGMat')
|
||||
mat.diffuse_color = (*diffuse_color, 1.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user