Made the remaining UV py scripts work with editmesh now.

DrawShadow option didnt check the final derived mesh had CD_MTFACE's can would crash when enabled with mirror modifier.
This commit is contained in:
Campbell Barton 2007-09-24 09:40:09 +00:00
parent adef239fc0
commit 1fde6d4570
3 changed files with 36 additions and 24 deletions

@ -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)

@ -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)

@ -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 */