[Bf-extensions-cvs] [40e34a8b] master: Magic UV: Release v6.4
nutti
noreply at git.blender.org
Fri Oct 23 13:19:56 CEST 2020
Commit: 40e34a8bbb30c6a4ddc73aa11e92c6bd2095eb80
Author: nutti
Date: Fri Oct 23 20:18:09 2020 +0900
Branches: master
https://developer.blender.org/rBA40e34a8bbb30c6a4ddc73aa11e92c6bd2095eb80
Magic UV: Release v6.4
* Support multiple objects editing mode
* Add snap to point/edge features
* Fix bugs
===================================================================
M magic_uv/__init__.py
M magic_uv/common.py
M magic_uv/lib/__init__.py
M magic_uv/op/__init__.py
M magic_uv/op/align_uv.py
M magic_uv/op/align_uv_cursor.py
M magic_uv/op/clip_uv.py
M magic_uv/op/copy_paste_uv.py
M magic_uv/op/copy_paste_uv_object.py
M magic_uv/op/copy_paste_uv_uvedit.py
M magic_uv/op/flip_rotate_uv.py
M magic_uv/op/mirror_uv.py
M magic_uv/op/move_uv.py
M magic_uv/op/pack_uv.py
M magic_uv/op/preserve_uv_aspect.py
M magic_uv/op/select_uv.py
M magic_uv/op/smooth_uv.py
M magic_uv/op/texture_lock.py
M magic_uv/op/texture_projection.py
M magic_uv/op/texture_wrap.py
M magic_uv/op/transfer_uv.py
M magic_uv/op/unwrap_constraint.py
M magic_uv/op/uv_bounding_box.py
M magic_uv/op/uv_inspection.py
M magic_uv/op/uv_sculpt.py
M magic_uv/op/uvw.py
M magic_uv/op/world_scale_uv.py
M magic_uv/preferences.py
M magic_uv/properites.py
M magic_uv/ui/IMAGE_MT_uvs.py
M magic_uv/ui/VIEW3D_MT_object.py
M magic_uv/ui/VIEW3D_MT_uv_map.py
M magic_uv/ui/__init__.py
M magic_uv/ui/uvedit_copy_paste_uv.py
M magic_uv/ui/uvedit_editor_enhancement.py
M magic_uv/ui/uvedit_uv_manipulation.py
M magic_uv/ui/view3d_copy_paste_uv_editmode.py
M magic_uv/ui/view3d_copy_paste_uv_objectmode.py
M magic_uv/ui/view3d_uv_manipulation.py
M magic_uv/ui/view3d_uv_mapping.py
M magic_uv/updater.py
M magic_uv/utils/__init__.py
M magic_uv/utils/addon_updater.py
M magic_uv/utils/bl_class_registry.py
M magic_uv/utils/compatibility.py
M magic_uv/utils/property_class_registry.py
===================================================================
diff --git a/magic_uv/__init__.py b/magic_uv/__init__.py
index 0df3d49f..e9c95f24 100644
--- a/magic_uv/__init__.py
+++ b/magic_uv/__init__.py
@@ -20,21 +20,23 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.3"
-__date__ = "10 Aug 2020"
+__version__ = "6.4"
+__date__ = "23 Oct 2020"
bl_info = {
"name": "Magic UV",
"author": "Nutti, Mifth, Jace Priester, kgeogeo, mem, imdjs"
"Keith (Wahooney) Boshoff, McBuff, MaxRobinot, "
- "Alexander Milovsky, Dusan Stevanovic",
- "version": (6, 3, 0),
+ "Alexander Milovsky, Dusan Stevanovic, MatthiasThDs",
+ "version": (6, 4, 0),
"blender": (2, 80, 0),
"location": "See Add-ons Preferences",
"description": "UV Toolset. See Add-ons Preferences for details",
"warning": "",
"support": "COMMUNITY",
+ "wiki_url": "https://docs.blender.org/manual/en/dev/addons/"
+ "uv/magic_uv.html",
"doc_url": "{BLENDER_MANUAL_URL}/addons/uv/magic_uv.html",
"tracker_url": "https://github.com/nutti/Magic-UV",
"category": "UV",
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 at 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 = []
diff --git a/magic_uv/lib/__init__.py b/magic_uv/lib/__init__.py
index 5e06552d..8bed4656 100644
--- a/magic_uv/lib/__init__.py
+++ b/magic_uv/lib/__init__.py
@@ -20,8 +20,8 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.3"
-__date__ = "10 Aug 2020"
+__version__ = "6.4"
+__date__ = "23 Oct 2020"
if "bpy" in locals():
import importlib
diff --git a/magic_uv/op/__init__.py b/magic_uv/op/__init__.py
index b7316192..459a37e0 100644
--- a/magic_uv/op/__init__.py
+++ b/magic_uv/op/__init__.py
@@ -20,8 +20,8 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.3"
-__date__ = "10 Aug 2020"
+__version__ = "6.4"
+__date__ = "23 Oct 2020"
if "bpy" in locals():
import importlib
diff --git a/magic_uv/op/align_uv.py b/magic_uv/op/align_uv.py
index 77afcc25..cb68bf25 100644
--- a/magic_uv/op/align_uv.py
+++ b/magic_uv/op/align_uv.py
@@ -20,14 +20,19 @@
__author__ = "imdjs, Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.3"
-__date__ = "10 Aug 2020"
+__version__ = "6.4"
+__date__ = "23 Oct 2020"
import math
from math import atan2, tan, sin, cos
import bpy
-from bpy.props import EnumProperty, BoolProperty, FloatProperty
+from bpy.props import (
+ EnumProperty,
+ BoolProperty,
+ FloatProperty,
+ FloatVectorProperty,
+)
import bmesh
from mathutils import Vector
@@ -39,23 +44,18 @@ from .. import common
def _is_valid_context(context):
- obj = context.object
+ objs = common.get_uv_editable_objects(context)
+ if not objs:
+ return False
# only edit mode is allowed to execute
- if obj is None:
- return False
- if obj.type != 'MESH':
- return False
if context.object.mode != 'EDIT':
return False
# 'IMAGE_EDITOR' and 'VIEW_3D' space is allowed to execute.
# If 'View_3D' space is not allowed, you can't find option in Tool-Shelf
# after the execution
- for space in context.area.spaces:
- if (space.type == 'IMAGE_EDITOR') or (space.type == 'VIEW_3D'):
- break
- else:
+ if not common.is_valid_space(context, ['IMAGE_EDITOR', 'VIEW_3D']):
return False
return True
@@ -339,6 +339,66 @@ class _Properties:
default='MIDDLE'
)
+ scene.muv_align_uv_snap_method = EnumProperty(
+ name="Snap Method",
+ description="Snap method",
+ items=[
+ ('POINT', "Point", "Snap to point"),
+ ('EDGE', "Edge", "Snap to edge"),
+ ],
+ default='POINT'
+ )
+ scene.muv_align_uv_snap_point_group = EnumProperty(
+ name="Snap Group (Point)",
+ description="Group that snap (point) operation applies for",
+ items=[
+ ('VERT', "Vertex", "Vertex"),
+ ('FACE', "Face", "Face"),
+ ('UV_ISLAND', "UV Island", "UV Island"),
+ ],
+ default='FACE'
+ )
+ scene.muv_align_uv_snap_point_target = FloatVectorProperty(
+ name="Snap Target (Point)",
+ description="Target point where UV vertices snap to",
+ size=2,
+ precision=4,
+ soft_min=-1.0,
+ soft_max=1.0,
+ step=1,
+ default=(0.000, 0.000),
+ )
+ scene.muv_align_uv_snap_edge_group = EnumProperty(
+ name="Snap Group (Edge)",
+ description="Group that snap (edge) operation applies for",
+ items=[
+ ('EDGE', "Edge", "Edge"),
+ ('FACE', "Face", "Face"),
+ ('UV_ISLAND', "UV Island", "UV Island"),
+ ],
+ default='FACE'
+ )
+ scene.muv_align_uv_snap_edge_target_1 = FloatVectorProperty(
+ name="Snap Target (Edge)",
+ description="Target edge where UV vertices snap to",
+ size=2,
+ precision=4,
+ soft_min=-1.0,
+ soft_max=1.0,
+ step=1,
+ default=(0.000, 0.000),
+ )
+ scene.muv_align_uv_snap_edge_target_2 = FloatVectorProperty(
+ name="Snap Target (Edge)",
+ description="Target edge where UV vertices snap to",
+ size=2,
+ precision=4,
+ soft_min=-1.0,
+ soft_max=1.0,
+ step=1,
+ default=(0.000, 0.000),
+ )
+
@classmethod
def del_props(cls, scene):
del scene.muv_align_uv_enabled
@@ -348,6 +408,12 @@ class _Properties:
del scene.muv_align_uv_horizontal
del scene.muv_align_uv_mesh_infl
del scene.muv_align_uv_location
+ del scene.muv_align_uv_snap_method
+ del scene.muv_align_uv_snap_point_group
+ del scene.muv_align_uv_snap_point_target
+ del scene.muv_align_uv_snap_edge_group
+ del scene.muv_align_uv_snap_edge_target_1
+ del scene.muv_align_uv_snap_edge_target_2
@BlClassRegistry()
@@ -378,77 +444,90 @@ class MUV_OT_AlignUV_Circle(bpy.types.Operator):
return _is_valid_context(context)
def execute(self, context):
- obj = context.active_object
- bm = bmesh.from_edit_mesh(obj.data)
- if common.check_version(2, 73, 0) >= 0:
- bm.faces.ensure_lookup_table()
- uv_layer = bm.loops.layers.uv.verify()
-
- # loop_seqs[horizontal][vertical][loop]
- loop_seqs, error = common.get_loop_sequences(bm, uv_layer, True)
- if not loop_seqs:
- self.report({'WARNING'}, error)
- return {'CANCELLED'}
-
- # get circle and new UVs
- uvs = [hseq[0][0][uv_layer].uv.copy() for hseq in loop_seqs]
- c, r = _get_circle(uvs[0:3])
- new_uvs = _calc_v_on_circle(uvs, c, r)
-
- # check if center is identical
- center_is_identical = False
- center = loop_seqs[0][-1][0].vert
- if (len(loop_seqs[0][-1]) == 1) and loop_seqs[0][-1][0].vert == center:
- center_is_identical = True
-
- # check if topology is correct
- if center_is_identical:
- for hseq in loop_seqs[1:]:
- if len(hseq[-1]) != 1:
- self.report({'WARNING'}, "Last face must be triangle")
- return {'CANCELLED'}
- if hseq[-1][0].vert != center:
- self.report({'WARNING'}, "Center must be identical")
- return {'CANCELLED'}
- else:
- for hseq in loop_seqs[1:]:
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list