Revision: 38415
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38415
Author: psy-fi
Date: 2011-07-15 16:51:32 +0000 (Fri, 15 Jul 2011)
Log Message:
-----------
seams from islands commit #1
============================
-implemented operator.
-want to add a property to select between two different schemes of operation,
right now only one is implemented.
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_image.py
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_image.py
2011-07-15 16:50:12 UTC (rev 38414)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_image.py
2011-07-15 16:51:32 UTC (rev 38415)
@@ -264,6 +264,7 @@
layout.operator("uv.average_islands_scale")
layout.operator("uv.minimize_stretch")
layout.operator("uv.stitch")
+ layout.operator("uv.seams_from_islands")
layout.operator("mesh.faces_mirror_uv")
layout.separator()
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
2011-07-15 16:50:12 UTC (rev 38414)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
2011-07-15 16:51:32 UTC (rev 38415)
@@ -73,6 +73,15 @@
#include "uvedit_intern.h"
+#define SFI_ISLAND_SEMANTICS 1
+#define SFI_EDGE_SEMANTICS 2
+
+EnumPropertyItem island_to_seam_items[] = {
+ {SFI_ISLAND_SEMANTICS, "ISLAND_SEMANTICS", 0, "Island Semantics", "Tag
seams only if both of its UVs are unconnected"},
+ {SFI_EDGE_SEMANTICS, "EDGE_SEMANTICS", 0, "Edge Semantics", "Tag seams
even if one of its UVs is unconnected"},
+ {0, NULL, 0, NULL, NULL}};
+
+
/************************* state testing ************************/
int ED_uvedit_test(Object *obedit)
@@ -3868,7 +3877,6 @@
/* api callbacks */
ot->exec= set_tile_exec;
- ot->invoke= set_tile_invoke;
ot->poll= ED_operator_image_active; /* requires space image */;
/* flags */
@@ -3878,6 +3886,82 @@
RNA_def_int_vector(ot->srna, "tile", 2, NULL, 0, INT_MAX, "Tile", "Tile
coordinate.", 0, 10);
}
+static int seams_from_islands_exec(bContext *C, wmOperator *op)
+{
+ UvVertMap *vmap;
+ Object *ob = CTX_data_edit_object(C);
+ EditMesh *em;
+ EditEdge *editedge;
+ float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
+ int operationMode = RNA_enum_get(op->ptr, "island_to_seam_items");
+
+ em = BKE_mesh_get_editmesh(ob->data);
+ if(!EM_texFaceCheck(em)){
+ return OPERATOR_CANCELLED;
+ BKE_mesh_end_editmesh(ob->data, em);
+ }
+
+ /* important, make_uv_vert_map sets tmp.l of editverts to their index,
+ * will be used later */
+ vmap = EM_make_uv_vert_map(em, 0, 1, limit);
+
+ for(editedge = em->edges.first; editedge; editedge = editedge->next){
+ char flag1 = 0, flag2 = 0;
+ UvMapVert *mapVert, *initMapVert;
+ /* first clean previous seam flag */
+ editedge->seam = 0;
+
+ initMapVert = vmap->vert[editedge->v1->tmp.l];
+ for(mapVert = initMapVert; mapVert; mapVert = mapVert->next){
+ /* if there are uv's that are not coincident, flag the
vert */
+ if(mapVert->separate && mapVert != initMapVert){
+ flag1 = 1;
+ break;
+ }
+ }
+
+ initMapVert = vmap->vert[editedge->v2->tmp.l];
+ for(mapVert = initMapVert; mapVert; mapVert = mapVert->next){
+ /* if there are uv's that are not coincident, flag the
vert */
+ if(mapVert->separate && mapVert != initMapVert){
+ flag2 = 1;
+ break;
+ }
+ }
+
+ if(flag1 && flag2){
+ editedge->seam = 1;
+ }
+ }
+
+ EM_free_uv_vert_map(vmap);
+
+ BKE_mesh_end_editmesh(ob->data, em);
+
+ DAG_id_tag_update(ob->data, 0);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
+
+ return OPERATOR_FINISHED;
+}
+
+static void UV_OT_seams_from_islands(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Seams From Islands";
+ ot->description= "Set mesh seams according to island setup in the UV
editor";
+ ot->idname= "UV_OT_seams_from_islands";
+
+ /* api callbacks */
+ ot->exec= seams_from_islands_exec;
+ ot->poll= ED_operator_image_active; /* requires space image */;
+
+ /* properties */
+ RNA_def_enum(ot->srna, "island_to_seam_items", island_to_seam_items, 1,
"Semantics", "");
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ************************** registration **********************************/
void ED_operatortypes_uvedit(void)
@@ -3897,6 +3981,7 @@
WM_operatortype_append(UV_OT_align);
WM_operatortype_append(UV_OT_stitch);
+ WM_operatortype_append(UV_OT_seams_from_islands);
WM_operatortype_append(UV_OT_weld);
WM_operatortype_append(UV_OT_pin);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs