diff options
author | nutti <nutti.metro@gmail.com> | 2020-10-23 14:18:09 +0300 |
---|---|---|
committer | nutti <nutti.metro@gmail.com> | 2020-10-23 14:18:09 +0300 |
commit | 40e34a8bbb30c6a4ddc73aa11e92c6bd2095eb80 (patch) | |
tree | 5c46bb7af6381407596cab713f21dede0aa65f27 /magic_uv/common.py | |
parent | ec3c96a37e2daddd5ca9f652c4b018b00a3acc53 (diff) |
Magic UV: Release v6.4
* Support multiple objects editing mode
* Add snap to point/edge features
* Fix bugs
Diffstat (limited to 'magic_uv/common.py')
-rw-r--r-- | magic_uv/common.py | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/magic_uv/common.py b/magic_uv/common.py index 11696667..3817486c 100644 --- a/magic_uv/common.py +++ b/magic_uv/common.py @@ -20,8 +20,8 @@ __author__ = "Nutti <nutti.metro@gmail.com>" __status__ = "production" -__version__ = "6.3" -__date__ = "10 Aug 2020" +__version__ = "6.4" +__date__ = "23 Oct 2020" from collections import defaultdict from pprint import pprint @@ -44,6 +44,14 @@ def is_console_mode(): return os.environ["MUV_CONSOLE_MODE"] == "true" +def is_valid_space(context, allowed_spaces): + for area in context.screen.areas: + for space in area.spaces: + if space.type in allowed_spaces: + return True + return False + + def is_debug_mode(): return __DEBUG_MODE @@ -422,23 +430,30 @@ def find_texture_layer(bm): return bm.faces.layers.tex.verify() -def find_texture_nodes(obj): +def find_texture_nodes_from_material(mtrl): nodes = [] - for mat in obj.material_slots: - if not mat.material: + if not mtrl.node_tree: + return nodes + for node in mtrl.node_tree.nodes: + tex_node_types = [ + 'TEX_ENVIRONMENT', + 'TEX_IMAGE', + ] + if node.type not in tex_node_types: continue - if not mat.material.node_tree: + if not node.image: continue - for node in mat.material.node_tree.nodes: - tex_node_types = [ - 'TEX_ENVIRONMENT', - 'TEX_IMAGE', - ] - if node.type not in tex_node_types: - continue - if not node.image: - continue - nodes.append(node) + nodes.append(node) + + return nodes + + +def find_texture_nodes(obj): + nodes = [] + for slot in obj.material_slots: + if not slot.material: + continue + nodes.extend(find_texture_nodes_from_material(slot.material)) return nodes @@ -1166,6 +1181,18 @@ def __is_points_in_polygon(points, subject_points): return True +def get_uv_editable_objects(context): + if compat.check_version(2, 80, 0) < 0: + objs = [context.active_object] + else: + objs = [o for o in bpy.data.objects + if compat.get_object_select(o) and o.type == 'MESH'] + objs.append(context.active_object) + + objs = list(set(objs)) + return objs + + def get_overlapped_uv_info(bm_list, faces_list, uv_layer_list, mode): # at first, check island overlapped isl = [] |