[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39825] branches/soc-2011-onion-uv-tools/ source/blender/editors/uvedit/uvedit_ops.c: smart stitch recode:
Antony Riakiotakis
kalast at gmail.com
Wed Aug 31 20:53:51 CEST 2011
Revision: 39825
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39825
Author: psy-fi
Date: 2011-08-31 18:53:49 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
smart stitch recode:
=====================
-Implement some utility functions, #ifdef'd out, no functional changes
Recode will include:
-Operation not based on selection flags internally(This left selection dirty on undo)
-cleaner separation of stitchability testing and preview code. These are currently mixed making the code unreadable/unmaintainable.
-Will most likely separate the UVEdge generation code used in UV sculpting into its own file so that the module is reusable(by smart stitch in this case)
-Will address redoing by introducing a new dynamic RNA type
Modified Paths:
--------------
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-08-31 14:46:27 UTC (rev 39824)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2011-08-31 18:53:49 UTC (rev 39825)
@@ -1265,6 +1265,16 @@
unsigned short count;
} UVVertAverage;
+typedef struct UvEdge {
+ /* index to uvelement buffer */
+ unsigned int uv1;
+ unsigned int uv2;
+ /* general use flag (Used to check if edge is boundary here, and propagates to adjacency elements) */
+ char flag;
+}UvEdge;
+
+//#define STITCHNEW
+
/* stitch state object */
typedef struct StitchState {
/* edge or vertex stitch mode */
@@ -1279,6 +1289,18 @@
EditMesh *em;
/* vertmap, contains vertices sharing uv's in linked lists. */
UvElementMap *vmap;
+
+#ifdef STITCHNEW
+ /* Edge container */
+ UvEdge *uvedges;
+ /* container of first of a group of coincident uvs, these will be operated upon */
+ UvElement *uvs;
+ /* maps uvelements to their first coincident uv */
+ int *map;
+ /* hold selection related information */
+ void *selection_stack;
+ int selection_size;
+#endif
} StitchState;
@@ -1458,6 +1480,8 @@
}
}
+#ifndef STITCHNEW
+
static void stitch_island_calculate_rotation(UvElement *element, int i, StitchState *state, UVVertAverage *uv_average, IslandStitchData *island_stitch_data)
{
EditFace *efa;
@@ -2111,7 +2135,84 @@
return 1;
}
+#else
+/* New stitch stuff */
+/* Checks for remote uvs that may be stitched with a certain uv, flags them if stitchable. */
+int determine_uv_stitchability(UvElement *element, StitchState *state){
+ int vert_index;
+ UvElement *element_iter;
+ float limit= state->limitDist;
+ int do_limit = state->use_limit;
+
+ vert_index = (*(&element->face->v1 + element->tfindex))->tmp.l;
+ element_iter = state->vmap->vert[vert_index];
+
+ for(; element_iter; element_iter = element_iter->next){
+ if(element_iter->separate){
+ if(element_iter == element){
+ continue;
+ }
+ if(do_limit){
+ MTFace *mt_orig = CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
+ MTFace *mt_iter = CustomData_em_get(&state->em->fdata, element_iter->face->data, CD_MTFACE);
+
+ if(fabs(mt_orig->uv[element->tfindex][0] - mt_iter->uv[element_iter->tfindex][0]) < limit
+ && fabs(mt_orig->uv[element->tfindex][1] - mt_iter->uv[element_iter->tfindex][1]) < limit){
+ element->flag |= STITCH_STITCHABLE;
+ element_iter->flag |= STITCH_STITCHABLE;
+ return 1;
+ }
+ }
+ /* if no limit exists, then the mere existence of a separate flag means that the uv is stitchable */
+ element->flag |= STITCH_STITCHABLE;
+ element_iter->flag |= STITCH_STITCHABLE;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+
+static int stitch_process_data(StitchState *state, int final, Scene *scene, int doIndexInit)
+{
+ return 1;
+}
+
+static int stitch_init(bContext *C, wmOperator *op)
+{
+ StitchState *stitch_state = MEM_mallocN(sizeof(StitchState), "stitch_state");
+ StitchPreviewer *preview = stitch_preview_init();
+ Scene *scene = CTX_data_scene(C);
+
+ Object *obedit = CTX_data_edit_object(C);
+
+ preview->enabled = 1;
+ op->customdata = stitch_state;
+
+ if(!stitch_state)
+ return 0;
+
+ /* initialize state */
+ stitch_state->use_limit = RNA_boolean_get(op->ptr, "use_limit");
+ stitch_state->limitDist = RNA_float_get(op->ptr, "limit");
+ stitch_state->em = BKE_mesh_get_editmesh((Mesh*)obedit->data);
+ stitch_state->mode = RNA_enum_get(op->ptr, "mode");
+ stitch_state->snapIslands = RNA_boolean_get(op->ptr, "snap_islands");
+ stitch_state->vmap = EM_make_uv_element_map(stitch_state->em, 1, 1);
+
+ if(!stitch_state->vmap){
+ return 0;
+ }
+ stitch_process_data(stitch_state, 0, scene, 1);
+
+ stitch_update_header(stitch_state, C);
+ return 1;
+}
+
+#endif
+
static int stitch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Object *obedit = CTX_data_edit_object(C);;
More information about the Bf-blender-cvs
mailing list