Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Pignataro <info@oscurart.com.ar>2019-09-05 14:41:39 +0300
committerEugenio Pignataro <info@oscurart.com.ar>2019-09-05 14:41:39 +0300
commitda5a1175e30c347fbce05e49e2f5f895be30bd5b (patch)
treec5c0b4f649972acd29e17791705886c663ed55dc /oscurart_tools
parent46b1ada7f5f2d396f712e9a1376922ca89475486 (diff)
OscurarTools: new feature, select flipped uvs, like maya
Diffstat (limited to 'oscurart_tools')
-rw-r--r--oscurart_tools/__init__.py7
-rw-r--r--oscurart_tools/mesh/flipped_uvs.py60
2 files changed, 65 insertions, 2 deletions
diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py
index 83914359..22fcc1d3 100644
--- a/oscurart_tools/__init__.py
+++ b/oscurart_tools/__init__.py
@@ -50,7 +50,7 @@ from oscurart_tools.mesh import apply_linked_meshes
from oscurart_tools.render import render_tokens
from oscurart_tools.render import batch_maker
from oscurart_tools.render import material_overrides
-
+from oscurart_tools.mesh import flipped_uvs
from bpy.types import (
AddonPreferences,
@@ -95,12 +95,14 @@ class IMAGE_MT_uvs_oscurarttools(Menu):
layout.operator("mesh.uv_island_copy")
layout.operator("mesh.uv_island_paste")
layout.operator("mesh.overlap_uv_faces")
+ layout.operator("mesh.select_flipped_uvs")
layout.separator()
layout.operator("image.reload_images_osc")
layout.operator("file.save_incremental_backup")
layout.operator("file.collect_all_images")
layout.operator("file.create_batch_maker_osc")
+
def menu_funcImage(self, context):
self.layout.menu("IMAGE_MT_uvs_oscurarttools")
self.layout.separator()
@@ -157,7 +159,8 @@ classes = (
material_overrides.OscRemoveOverridesSlot,
material_overrides.OscOverridesUp,
material_overrides.OscOverridesDown,
- material_overrides.OscOverridesKill
+ material_overrides.OscOverridesKill,
+ flipped_uvs.selectFlippedUvs
)
def register():
diff --git a/oscurart_tools/mesh/flipped_uvs.py b/oscurart_tools/mesh/flipped_uvs.py
new file mode 100644
index 00000000..3cafea7d
--- /dev/null
+++ b/oscurart_tools/mesh/flipped_uvs.py
@@ -0,0 +1,60 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+
+import bpy
+import bmesh
+
+def defSelectFlippedUvs(self, context):
+ bm = bmesh.from_edit_mesh(bpy.context.active_object.data)
+ bpy.context.scene.tool_settings.use_uv_select_sync = True
+
+ uvLayer = bm.loops.layers.uv.verify()
+
+
+ for face in bm.faces:
+ sum_edges = 0
+
+ for i in range(3):
+ uv_A = face.loops[i][uvLayer].uv
+ uv_B = face.loops[(i+1)%3][uvLayer].uv
+ sum_edges += uv_B.cross(uv_A)
+
+ if sum_edges > 0:
+ face.select_set(True)
+
+ bmesh.update_edit_mesh(bpy.context.object.data)
+
+
+class selectFlippedUvs(bpy.types.Operator):
+ """Copy Uv Island"""
+ bl_idname = "mesh.select_flipped_uvs"
+ bl_label = "Select Flipped Uvs"
+ bl_options = {"REGISTER", "UNDO"}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.active_object is not None and
+ context.active_object.type == 'MESH' and
+ context.active_object.mode == "EDIT")
+
+ def execute(self, context):
+ defSelectFlippedUvs(self, context)
+ return {'FINISHED'} \ No newline at end of file