[Bf-extensions-cvs] [d2808959] master: Magic UV: Release v6.1
Nutti
noreply at git.blender.org
Sun May 19 09:46:42 CEST 2019
Commit: d2808959bb845ec945aa7fac494db42a9228021b
Author: Nutti
Date: Sun May 19 16:45:14 2019 +0900
Branches: master
https://developer.blender.org/rBAd2808959bb845ec945aa7fac494db42a9228021b
Magic UV: Release v6.1
[Update features]
- World Scale UV
- Add option "Texture" to allow the user to specify the texture for the density calculation
[Other updates]
- 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/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_updator.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 5bac5fd2..e8a82c93 100644
--- a/magic_uv/__init__.py
+++ b/magic_uv/__init__.py
@@ -20,8 +20,8 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.0"
-__date__ = "26 Jan 2019"
+__version__ = "6.1"
+__date__ = "19 May 2019"
bl_info = {
@@ -29,7 +29,7 @@ bl_info = {
"author": "Nutti, Mifth, Jace Priester, kgeogeo, mem, imdjs"
"Keith (Wahooney) Boshoff, McBuff, MaxRobinot, "
"Alexander Milovsky",
- "version": (6, 0, 0),
+ "version": (6, 1, 0),
"blender": (2, 80, 0),
"location": "See Add-ons Preferences",
"description": "UV Toolset. See Add-ons Preferences for details",
diff --git a/magic_uv/common.py b/magic_uv/common.py
index 78a88308..066fa969 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.0"
-__date__ = "26 Jan 2019"
+__version__ = "6.1"
+__date__ = "19 May 2019"
from collections import defaultdict
from pprint import pprint
@@ -41,7 +41,7 @@ __DEBUG_MODE = False
def is_console_mode():
if "MUV_CONSOLE_MODE" not in os.environ:
return False
- return os.environ["MUV_CONSOLE_MODE"] == "True"
+ return os.environ["MUV_CONSOLE_MODE"] == "true"
def is_debug_mode():
@@ -382,6 +382,8 @@ def find_texture_layer(bm):
def find_texture_nodes(obj):
nodes = []
for mat in obj.material_slots:
+ if not mat.material:
+ continue
if not mat.material.node_tree:
continue
for node in mat.material.node_tree.nodes:
@@ -399,23 +401,34 @@ def find_texture_nodes(obj):
def find_image(obj, face=None, tex_layer=None):
+ images = find_images(obj, face, tex_layer)
+
+ if len(images) >= 2:
+ raise RuntimeError("Find more than 2 images")
+ if len(images) == 0:
+ return None
+
+ return images[0]
+
+
+def find_images(obj, face=None, tex_layer=None):
+ images = []
+
# try to find from texture_layer
- img = None
if tex_layer and face:
- img = face[tex_layer].image
+ if face[tex_layer].image is not None:
+ images.append(face[tex_layer].image)
# not found, then try to search from node
- if not img:
+ if not images:
nodes = find_texture_nodes(obj)
- if len(nodes) >= 2:
- raise RuntimeError("Find more than 2 texture nodes")
- if len(nodes) == 1:
- img = nodes[0].image
+ for n in nodes:
+ images.append(n.image)
- return img
+ return images
-def measure_uv_area(obj, tex_size=None):
+def measure_uv_area(obj, method='FIRST', tex_size=None):
bm = bmesh.from_edit_mesh(obj.data)
if check_version(2, 73, 0) >= 0:
bm.verts.ensure_lookup_table()
@@ -437,17 +450,53 @@ def measure_uv_area(obj, tex_size=None):
f_uv_area = calc_polygon_2d_area(uvs)
# user specified
- if tex_size:
- uv_area = uv_area + f_uv_area * tex_size[0] * tex_size[1]
- continue
-
- img = find_image(obj, f, tex_layer)
-
- # can not find from node, so we can not get texture size
- if not img:
- return None
+ if method == 'USER_SPECIFIED' and tex_size is not None:
+ img_size = tex_size
+ # first texture if there are more than 2 textures assigned
+ # to the object
+ elif method == 'FIRST':
+ img = find_image(obj, f, tex_layer)
+ # can not find from node, so we can not get texture size
+ if not img:
+ return None
+ img_size = img.size
+ # average texture size
+ elif method == 'AVERAGE':
+ imgs = find_images(obj, f, tex_layer)
+ if not imgs:
+ return None
+
+ img_size_total = [0.0, 0.0]
+ for img in imgs:
+ img_size_total = [img_size_total[0] + img.size[0],
+ img_size_total[1] + img.size[1]]
+ img_size = [img_size_total[0] / len(imgs),
+ img_size_total[1] / len(imgs)]
+ # max texture size
+ elif method == 'MAX':
+ imgs = find_images(obj, f, tex_layer)
+ if not imgs:
+ return None
+
+ img_size_max = [-99999999.0, -99999999.0]
+ for img in imgs:
+ img_size_max = [max(img_size_max[0], img.size[0]),
+ max(img_size_max[1], img.size[1])]
+ img_size = img_size_max
+ # min texture size
+ elif method == 'MIN':
+ imgs = find_images(obj, f, tex_layer)
+ if not imgs:
+ return None
+
+ img_size_min = [99999999.0, 99999999.0]
+ for img in imgs:
+ img_size_min = [min(img_size_min[0], img.size[0]),
+ min(img_size_min[1], img.size[1])]
+ img_size = img_size_min
+ else:
+ raise RuntimeError("Unexpected method: {}".format(method))
- img_size = img.size
uv_area = uv_area + f_uv_area * img_size[0] * img_size[1]
return uv_area
diff --git a/magic_uv/lib/__init__.py b/magic_uv/lib/__init__.py
index db6f9df9..8ba994d9 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.0"
-__date__ = "26 Jan 2019"
+__version__ = "6.1"
+__date__ = "19 May 2019"
if "bpy" in locals():
import importlib
diff --git a/magic_uv/op/__init__.py b/magic_uv/op/__init__.py
index d637e78a..25882d9c 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.0"
-__date__ = "26 Jan 2019"
+__version__ = "6.1"
+__date__ = "19 May 2019"
if "bpy" in locals():
import importlib
diff --git a/magic_uv/op/align_uv.py b/magic_uv/op/align_uv.py
index f8ea4176..92ce2a61 100644
--- a/magic_uv/op/align_uv.py
+++ b/magic_uv/op/align_uv.py
@@ -20,8 +20,8 @@
__author__ = "imdjs, Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.0"
-__date__ = "26 Jan 2019"
+__version__ = "6.1"
+__date__ = "19 May 2019"
import math
from math import atan2, tan, sin, cos
@@ -356,7 +356,7 @@ class _Properties:
@compat.make_annotations
class MUV_OT_AlignUV_Circle(bpy.types.Operator):
- bl_idname = "uv.muv_ot_align_uv_circle"
+ bl_idname = "uv.muv_align_uv_circle"
bl_label = "Align UV (Circle)"
bl_description = "Align UV coordinates to Circle"
bl_options = {'REGISTER', 'UNDO'}
@@ -397,22 +397,39 @@ class MUV_OT_AlignUV_Circle(bpy.types.Operator):
c, r = _get_circle(uvs[0:3])
new_uvs = _calc_v_on_circle(uvs, c, r)
- # check center UV of circle
+ # check if center is identical
+ center_is_identical = False
center = loop_seqs[0][-1][0].vert
- 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'}
+ 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:]:
+ if len(hseq[-1]) == 1:
+ self.report({'WARNING'}, "Last face must not be triangle")
+ return {'CANCELLED'}
+ if hseq[-1][0].vert == center:
+ self.report({'WARNING'}, "Center must not be identical")
+ return {'CANCELLED'}
# align to circle
if self.transmission:
for hidx, hseq in enumerate(loop_seqs):
for vidx, pair in enumerate(hseq):
all_ = int((len(hseq) + 1) / 2)
- r = (all_ - int((vidx + 1) / 2)) / all_
+ if center_is_identical:
+ r = (all_ - int((vidx + 1) / 2)) / all_
+ else:
+ r = (1 + all_ - int((vidx + 1) / 2)) / all_
pair[0][uv_layer].uv = c + (new_uvs[hidx] - c) * r
if self.select:
pair[0][uv_layer].select = True
@@ -442,7 +459,7 @@ class MUV_OT_AlignUV_Circle(bpy.types.Operator):
@compat.make_annotations
class MUV_OT_AlignUV_Straighten(bpy.types.Operator):
- bl_idname = "uv.muv_ot_align_uv_straighten"
+ bl_idname = "uv.muv_align_uv_straighten"
bl_label = "Align UV (Straighten)"
bl_description = "Straighten UV coordinates"
bl_options = {'REGISTER', 'UNDO'}
@@ -594,7 +611,7 @@ class MUV_OT_AlignUV_Straighten(bpy.types.Operator):
@compat.make_annotations
class MUV_OT_AlignUV_Axis(bpy.types.Operator):
- bl_idname = "uv.muv_ot_align_uv_axis"
+ bl_idname = "uv.muv_align_uv_axis"
bl_label = "Align UV (XY-Axis)"
bl_description = "Align UV to XY-axis"
bl_options = {'REGISTER', 'UNDO'}
diff --git a/magic_uv/op/align_uv_cursor.py b/magic_uv/op/align_uv_cursor.py
index 24c111d0..2189d764 100644
--- a/magic_uv/op/align_uv_cursor.py
+++ b/magic_uv/op/align_uv_cursor.py
@@ -20,8 +20,8 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "6.0"
-__date__ = "26 Jan 2019"
+__version__ = "6.1"
+__date__ = "19 May 2019"
import bpy
from mathutils import Vector
@@ -60,7 +60,7 @@ class _Properties:
b
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list