Revision: 40223
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40223
Author:   psy-fi
Date:     2011-09-15 12:07:53 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
More initialization stuff with cleaner (I hope) stitch code. Still no 
functionality restored, but soon the code will not rely on selection tweaking 
at all during operation. Also exposed generic get_uv_element function in 
uvedit_intern.h. Not sure whether sculpt should reference uvedit headers. Maybe 
should move this somewhere else? Looks like I will get appropriate feedback at 
merge time.

Modified Paths:
--------------
    
branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
    
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h
    branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c

Modified: 
branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
===================================================================
--- 
branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
    2011-09-15 11:49:36 UTC (rev 40222)
+++ 
branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/sculpt_uv.c
    2011-09-15 12:07:53 UTC (rev 40223)
@@ -67,7 +67,6 @@
 #include "UI_view2d.h"
 
 #define MARK_BOUNDARY  1
-#define SELECTED               2
 
 typedef struct UvAdjacencyElement {
        /* pointer to original uvelement */
@@ -78,12 +77,12 @@
        char flag;
 } UvAdjacencyElement;
 
-typedef struct UvAdjacencyEdge {
+typedef struct UvEdge {
        unsigned int uv1;
        unsigned int uv2;
        /* general use flag (Used to check if edge is boundary here, and 
propagates to adjacency elements) */
        char flag;
-}UvAdjacencyEdge;
+}UvEdge;
 
 
 typedef struct UVInitialStrokeElement{
@@ -118,7 +117,7 @@
        int totalUniqueUvs;
 
        /* Edges used for adjacency info, used with laplacian smoothing */
-       UvAdjacencyEdge *uvedges;
+       UvEdge *uvedges;
 
        /* Need I say more? */
        int totalUvEdges;
@@ -159,7 +158,7 @@
 
        /* counting neighbors */
        for (i = 0; i < sculptdata->totalUvEdges; i++){
-               UvAdjacencyEdge *tmpedge = sculptdata->uvedges+i;
+               UvEdge *tmpedge = sculptdata->uvedges+i;
                tmp_uvdata[tmpedge->uv1].ncounter++;
                tmp_uvdata[tmpedge->uv2].ncounter++;
 
@@ -177,7 +176,7 @@
        }
 
        for (i = 0; i < sculptdata->totalUvEdges; i++){
-               UvAdjacencyEdge *tmpedge = sculptdata->uvedges+i;
+               UvEdge *tmpedge = sculptdata->uvedges+i;
                add_v2_v2(tmp_uvdata[tmpedge->uv1].sum_b, 
tmp_uvdata[tmpedge->uv2].b);
                add_v2_v2(tmp_uvdata[tmpedge->uv2].sum_b, 
tmp_uvdata[tmpedge->uv1].b);
        }
@@ -215,7 +214,7 @@
        return;
 }
 
-static void smooth_laplacian_iteration_uv(EditMesh *em, UvSculptData 
*sculptdata, float mouse_coord[2], float alpha, float radius, float aspectRatio)
+static void laplacian_relaxation_iteration_uv(EditMesh *em, UvSculptData 
*sculptdata, float mouse_coord[2], float alpha, float radius, float aspectRatio)
 {
        Temp_UVData *tmp_uvdata;
        float diff[2];
@@ -227,7 +226,7 @@
 
        /* counting neighbors */
        for (i = 0; i < sculptdata->totalUvEdges; i++){
-               UvAdjacencyEdge *tmpedge = sculptdata->uvedges+i;
+               UvEdge *tmpedge = sculptdata->uvedges+i;
                tmp_uvdata[tmpedge->uv1].ncounter++;
                tmp_uvdata[tmpedge->uv2].ncounter++;
 
@@ -343,7 +342,7 @@
                if(method == UV_SCULPT_TOOL_RELAX_HC){
                        HC_relaxation_iteration_uv(em, sculptdata, co, alpha, 
radius, aspectRatio);
                }else{
-                       smooth_laplacian_iteration_uv(em, sculptdata, co, 
alpha, radius, aspectRatio);
+                       laplacian_relaxation_iteration_uv(em, sculptdata, co, 
alpha, radius, aspectRatio);
                }
        }else if(tool == UV_SCULPT_TOOL_GRAB){
                int i;
@@ -397,17 +396,6 @@
        op->customdata = NULL;
 }
 
-static UvElement *get_uv_element(UvElementMap *map, EditFace *efa, int index){
-       UvElement *element = map->vert[(*(&efa->v1 + index))->tmp.l];
-       for(;element; element = element->next){
-               if(element->face == efa){
-                       return element;
-               }
-       }
-       return NULL;
-}
-
-
 static int get_uv_element_offset_from_face(UvElementMap *map, EditFace *efa, 
int index, int island_index, int doIslands){
        UvElement *element = get_uv_element(map, efa, index);
        if(!element || (doIslands && element->island != island_index)){
@@ -418,15 +406,15 @@
 
 
 static unsigned int    uv_edge_hash(const void *key){
-       UvAdjacencyEdge *edge = (UvAdjacencyEdge *)key;
+       UvEdge *edge = (UvEdge *)key;
        return 
                BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) +
                BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1));
 }
 
 static int uv_edge_compare(const void *a, const void *b){
-       UvAdjacencyEdge *edge1 = (UvAdjacencyEdge *)a;
-       UvAdjacencyEdge *edge2 = (UvAdjacencyEdge *)b;
+       UvEdge *edge1 = (UvEdge *)a;
+       UvEdge *edge2 = (UvEdge *)b;
 
        if((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)){
                return 0;
@@ -450,7 +438,7 @@
                ARegion *ar= CTX_wm_region(C);
                float co[2];
                EditFace *efa;
-               UvAdjacencyEdge *edges;
+               UvEdge *edges;
                GHash *edgeHash;
                GHashIterator* ghi;
                MTFace *mt;
@@ -605,7 +593,7 @@
                }
                /* fill the edges with data */
                for(i = 0; !BLI_ghashIterator_isDone(ghi); 
BLI_ghashIterator_step(ghi), i++){
-                       data->uvedges[i] = *((UvAdjacencyEdge 
*)BLI_ghashIterator_getKey(ghi));
+                       data->uvedges[i] = *((UvEdge 
*)BLI_ghashIterator_getKey(ghi));
                }
                data->totalUvEdges = BLI_ghash_size(edgeHash);
 

Modified: 
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h
===================================================================
--- 
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h  
    2011-09-15 11:49:36 UTC (rev 40222)
+++ 
branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_intern.h  
    2011-09-15 12:07:53 UTC (rev 40223)
@@ -91,7 +91,10 @@
        int edge, vert2;
 } NearestHit;
 
+/* utility tool functions */
 void find_nearest_uv_vert(struct Scene *scene, struct Image *ima, struct 
EditMesh *em, float co[2], float penalty[2], struct NearestHit *hit);
+struct UvElement *get_uv_element(struct UvElementMap *map, struct EditFace 
*efa, int index);
+StitchPreviewer *uv_get_stitch_previewer(void);
 
 /* operators */
 void UV_OT_average_islands_scale(struct wmOperatorType *ot);
@@ -104,7 +107,5 @@
 void UV_OT_sphere_project(struct wmOperatorType *ot);
 void UV_OT_unwrap(struct wmOperatorType *ot);
 
-/* tool utilities */
-StitchPreviewer *uv_get_stitch_previewer(void);
 #endif /* ED_UVEDIT_INTERN_H */
 

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-09-15 11:49:36 UTC (rev 40222)
+++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 
2011-09-15 12:07:53 UTC (rev 40223)
@@ -694,6 +694,16 @@
        return NULL;
 }
 
+UvElement *get_uv_element(UvElementMap *map, EditFace *efa, int index){
+       UvElement *element = map->vert[(*(&efa->v1 + index))->tmp.l];
+       for(;element; element = element->next){
+               if(element->face == efa){
+                       return element;
+               }
+       }
+       return NULL;
+}
+
 static int uv_edge_tag_faces(UvMapVert *first1, UvMapVert *first2, int 
*totface)
 {
        UvMapVert *iterv1, *iterv2;
@@ -1255,7 +1265,7 @@
        float medianPoint[2];
        int numOfElements;
        int numOfEdges;
-       /* Flag to remember if island has been aded for preview */
+       /* Flag to remember if island has been added for preview */
        char addedForPreview;
 }IslandStitchData;
 
@@ -1294,11 +1304,11 @@
        /* Edge container */
        UvEdge *uvedges;
        /* container of first of a group of coincident uvs, these will be 
operated upon */
-       UvElement *uvs;
+       UvElement **uvs;
        /* maps uvelements to their first coincident uv */
        int *map;
        /* hold selection related information */
-       UvElement *selection_stack;
+       void **selection_stack;
        int selection_size;
 #endif
 } StitchState;
@@ -1314,6 +1324,7 @@
 #define STITCH_USE_FOR_STITCHING 16
 #define STITCH_DO_UPDATE 32
 
+#define STITCH_SELECTED 1
 
 /* Previewer stuff (see uvedit_intern.h for more info) */
 static StitchPreviewer *_stitch_preview;
@@ -1408,7 +1419,7 @@
        }
 }
 
-static void stitch_island_rotate(float rotation, float medianPoint[2], float 
uv[2]){
+static void stitch_uv_rotate(float rotation, float medianPoint[2], float 
uv[2]){
        float uv_rotation_result[2];
 
        uv[0] -= medianPoint[0];
@@ -1453,7 +1464,7 @@
                                        mt = 
CustomData_em_get(&state->em->fdata, efa->data, CD_MTFACE);
                                        if(final){
                                                if(state->mode == EDGE_STITCH){
-                                                       
stitch_island_rotate(island_stitch_data[i].rotation, 
island_stitch_data[i].medianPoint, mt->uv[element->tfindex]);
+                                                       
stitch_uv_rotate(island_stitch_data[i].rotation, 
island_stitch_data[i].medianPoint, mt->uv[element->tfindex]);
                                                }
                                                mt->uv[element->tfindex][0] += 
island_stitch_data[i].translation[0];
                                                mt->uv[element->tfindex][1] += 
island_stitch_data[i].translation[1];
@@ -1461,14 +1472,14 @@
                                        else{
                                                if(efa->v4){
                                                        if(state->mode == 
EDGE_STITCH){
-                                                               
stitch_island_rotate(island_stitch_data[i].rotation, 
island_stitch_data[i].medianPoint, &preview->previewQuads[efa->tmp.l + 
2*element->tfindex]);
+                                                               
stitch_uv_rotate(island_stitch_data[i].rotation, 
island_stitch_data[i].medianPoint, &preview->previewQuads[efa->tmp.l + 
2*element->tfindex]);
                                                        }
                                                        
preview->previewQuads[efa->tmp.l + 2*element->tfindex] += 
island_stitch_data[i].translation[0];
                                                        
preview->previewQuads[efa->tmp.l + 2*element->tfindex + 1] += 
island_stitch_data[i].translation[1];
                                                }
                                                else {
                                                        if(state->mode == 
EDGE_STITCH){
-                                                               
stitch_island_rotate(island_stitch_data[i].rotation, 
island_stitch_data[i].medianPoint, &preview->previewTris[efa->tmp.l + 
2*element->tfindex]);
+                                                               
stitch_uv_rotate(island_stitch_data[i].rotation, 
island_stitch_data[i].medianPoint, &preview->previewTris[efa->tmp.l + 
2*element->tfindex]);
                                                        }
                                                        
preview->previewTris[efa->tmp.l + 2*element->tfindex]  += 
island_stitch_data[i].translation[0];
                                                        
preview->previewTris[efa->tmp.l + 2*element->tfindex + 1] += 
island_stitch_data[i].translation[1];
@@ -2151,6 +2162,9 @@
                if(stitch_state->selection_stack){
                        MEM_freeN(stitch_state->selection_stack);
                }
+               if(stitch_state->map){
+                       MEM_freeN(stitch_state->map);
+               }
 
                MEM_freeN(stitch_state);
        }
@@ -2174,11 +2188,11 @@
                                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);
+                               MTFace *mtface_orig = 
CustomData_em_get(&state->em->fdata, element->face->data, CD_MTFACE);
+                               MTFace *mtface_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){
+                               if(fabs(mtface_orig->uv[element->tfindex][0] - 
mtface_iter->uv[element_iter->tfindex][0]) < limit
+                                               && 
fabs(mtface_orig->uv[element->tfindex][1] - 
mtface_iter->uv[element_iter->tfindex][1]) < limit){
                                        return 1;
                                }
                        }else{
@@ -2201,6 +2215,7 @@
 static int stitch_init(bContext *C, wmOperator *op)
 {
        int counter = 0, i;
+       EditFace *efa;

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to