[Bf-extensions-cvs] [da5a1175] master: OscurarTools: new feature, select flipped uvs, like maya

Eugenio Pignataro noreply at git.blender.org
Thu Sep 5 13:41:47 CEST 2019


Commit: da5a1175e30c347fbce05e49e2f5f895be30bd5b
Author: Eugenio Pignataro
Date:   Thu Sep 5 08:41:39 2019 -0300
Branches: master
https://developer.blender.org/rBAda5a1175e30c347fbce05e49e2f5f895be30bd5b

OscurarTools: new feature, select flipped uvs, like maya

===================================================================

M	oscurart_tools/__init__.py
A	oscurart_tools/mesh/flipped_uvs.py

===================================================================

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



More information about the Bf-extensions-cvs mailing list