Made the remaining UV py scripts work with editmesh now.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 24 Sep 2007 09:40:09 +0000 (09:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 24 Sep 2007 09:40:09 +0000 (09:40 +0000)
DrawShadow option didnt check the final derived mesh had CD_MTFACE's can would crash when enabled with mirror modifier.

release/scripts/uv_export.py
release/scripts/uv_seams_from_islands.py
source/blender/src/drawimage.c

index f73b7bc7b100d4e1221028e2890d2901ddb843fb..5977a3b76f691d1b1c931b6667c0224bf94db6ef 100644 (file)
@@ -183,12 +183,16 @@ def ExportCallback(f):
        
        time1= Blender.sys.time()
 
-       if obj.type != "Mesh":
+       if not obj or obj.type != "Mesh":
                BPyMessages.Error_NoMeshActive()
                return
-
+       
+       is_editmode = Blender.Window.EditMode()
+       if is_editmode: Blender.Window.EditMode(0)
+       
        mesh = obj.getData(mesh=1)
        if not mesh.faceUV:
+               if is_editmode: Blender.Window.EditMode(1)
                BPyMessages.Error_NoMeshUvActive()
                return
 
@@ -207,6 +211,8 @@ def ExportCallback(f):
        
        UVFaces = ExtractUVFaces(mesh, bAllFaces.val)
        
+       if is_editmode: Blender.Window.EditMode(1)
+               
        if not bSVG.val:
                print "TGA export is running..."
                UV_Export_TGA(UVFaces, bSize.val, bWSize.val, bWrap.val, name)
index dd27aab4ce97a68ddc496d5918d8298eebbe1749..241f38fc4aa83a0737fe755a0d5e003fb0fa8ac9 100644 (file)
@@ -37,7 +37,6 @@ def seams_from_islands(me):
        # add seams
        SEAM = Mesh.EdgeFlags.SEAM
        for ed in me.edges:
-               print len(set(edge_uvs[ed.key]))
                if len(set(edge_uvs[ed.key])) > 1:
                        ed.flag |= SEAM
 
@@ -59,7 +58,7 @@ def main():
        # editmode if its enabled, we cant make
        # changes to the mesh data while in editmode.
        is_editmode = Window.EditMode()
-       if is_editmode: Window.EditMode(1)
+       if is_editmode: Window.EditMode(0)
        
        Window.WaitCursor(1)
        
@@ -68,8 +67,10 @@ def main():
        # Run the mesh editing function
        seams_from_islands(me)
        
+       if is_editmode: Window.EditMode(1)
+       
        # Timing the script is a good way to be aware on any speed hits when scripting
-       print 'My Script finished in %.2f seconds' % (sys.time()-t)
+       print 'UV Seams from Islands finished in %.2f seconds' % (sys.time()-t)
        Window.WaitCursor(0)
        
        
index 5bc8dad86afd5d5e0f7793689ceb91d2563157f7..4c1333d0ce235d9b57cb7d3473f3b6e26b5edf55 100644 (file)
@@ -481,29 +481,34 @@ void draw_uvs_sima(void)
                return; /* only draw shadow mesh */
        } else if (G.sima->flag & SI_DRAWSHADOW) {
                /* draw shadow mesh - this is the mesh with the modifier applied */
-               DerivedMesh *finalDM, *cageDM;
-               
                glColor3ub(112, 112, 112);
-               if (G.editMesh->derivedFinal && G.editMesh->derivedFinal->drawUVEdges) {
-                       G.editMesh->derivedFinal->drawUVEdges(G.editMesh->derivedFinal);
-               }
-
-               /* draw final mesh with modifiers applied */
-               cageDM = editmesh_get_derived_cage_and_final(&finalDM, CD_MASK_BAREMESH | CD_MASK_MTFACE);
-               
-               if              (finalDM->drawUVEdges &&
-                               DM_get_face_data_layer(finalDM, CD_MTFACE) &&
-                               /* When sync selection is enabled, all faces are drawn (except for hidden)
-                                * so if cage is the same as the final, theres no point in drawing the shadowmesh. */
-                               !((G.sima->flag & SI_SYNC_UVSEL && cageDM==finalDM))
+               if (    em->derivedFinal &&
+                               em->derivedFinal->drawUVEdges &&
+                               CustomData_has_layer(&em->derivedFinal->faceData, CD_MTFACE)
                ) {
+                       /* we can use the existing final mesh */
                        glColor3ub(112, 112, 112);
-                       finalDM->drawUVEdges(finalDM);
+                       G.editMesh->derivedFinal->drawUVEdges(G.editMesh->derivedFinal);
+               } else {
+                       DerivedMesh *finalDM, *cageDM;
+                       
+                       /* draw final mesh with modifiers applied */
+                       cageDM = editmesh_get_derived_cage_and_final(&finalDM, CD_MASK_BAREMESH | CD_MASK_MTFACE);
+                       
+                       if              (finalDM->drawUVEdges &&
+                                       DM_get_face_data_layer(finalDM, CD_MTFACE) &&
+                                       /* When sync selection is enabled, all faces are drawn (except for hidden)
+                                        * so if cage is the same as the final, theres no point in drawing the shadowmesh. */
+                                       !((G.sima->flag & SI_SYNC_UVSEL && cageDM==finalDM))
+                       ) {
+                               glColor3ub(112, 112, 112);
+                               finalDM->drawUVEdges(finalDM);
+                       }
+                       
+                       if (cageDM != finalDM)
+                               cageDM->release(cageDM);
+                       finalDM->release(finalDM);
                }
-               
-               if (cageDM != finalDM)
-                       cageDM->release(cageDM);
-               finalDM->release(finalDM);
        }
        
        /* draw transparent faces */