Commit: 30b45d5591fdd20e5cd5abd0cf3be62622c0b0db
Author: Campbell Barton
Date:   Sun May 17 23:04:34 2015 +1000
Branches: master
https://developer.blender.org/rB30b45d5591fdd20e5cd5abd0cf3be62622c0b0db

BMesh: don't check winding for uv-vert-map

Made link-select separate front/back with projected UV's

===================================================================

M       source/blender/blenkernel/BKE_mesh_mapping.h
M       source/blender/blenkernel/intern/mesh_mapping.c
M       source/blender/blenkernel/intern/subsurf_ccg.c
M       source/blender/editors/include/ED_mesh.h
M       source/blender/editors/mesh/editmesh_utils.c
M       source/blender/editors/uvedit/uvedit_ops.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h 
b/source/blender/blenkernel/BKE_mesh_mapping.h
index dcf5d2e..a2f4785 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -102,7 +102,8 @@ typedef struct MeshElemMap {
 /* mapping */
 UvVertMap *BKE_mesh_uv_vert_map_create(
         struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv,
-        unsigned int totpoly, unsigned int totvert, int selected, float 
*limit, bool use_winding);
+        unsigned int totpoly, unsigned int totvert,
+        const float limit[2], const bool selected, const bool use_winding);
 UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v);
 void       BKE_mesh_uv_vert_map_free(UvVertMap *vmap);
 
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c 
b/source/blender/blenkernel/intern/mesh_mapping.c
index e4a85eb..8b41ade 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -54,8 +54,10 @@
 /* this replaces the non bmesh function (in trunk) which takes MTFace's, if we 
ever need it back we could
  * but for now this replaces it because its unused. */
 
-UvVertMap *BKE_mesh_uv_vert_map_create(struct MPoly *mpoly, struct MLoop 
*mloop, struct MLoopUV *mloopuv,
-                                       unsigned int totpoly, unsigned int 
totvert, int selected, float *limit, bool use_winding)
+UvVertMap *BKE_mesh_uv_vert_map_create(
+        struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv,
+        unsigned int totpoly, unsigned int totvert,
+        const float limit[2], const bool selected, const bool use_winding)
 {
        UvVertMap *vmap;
        UvMapVert *buf;
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c 
b/source/blender/blenkernel/intern/subsurf_ccg.c
index e4d178d..b640591 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -304,7 +304,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf 
*origss, DerivedMesh *dm,
         * UV map in really simple cases with mirror + subsurf, see second part 
of T44530. Also, initially
         * intention is to treat merged vertices from mirror modifier as seams, 
see code below with ME_VERT_MERGED
         * This fixes a very old regression (2.49 was correct here) */
-       vmap = BKE_mesh_uv_vert_map_create(mpoly, mloop, mloopuv, totface, 
totvert, 0, limit, true);
+       vmap = BKE_mesh_uv_vert_map_create(mpoly, mloop, mloopuv, totface, 
totvert, limit, false, true);
        if (!vmap)
                return 0;
        
diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index ea54413..3f16055 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -116,7 +116,9 @@ struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh 
*em, struct BMFace *
 
 void              BM_uv_vert_map_free(struct UvVertMap *vmap);
 struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int 
v);
-struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, bool use_select, 
const float limit[2]);
+struct UvVertMap *BM_uv_vert_map_create(
+        struct BMesh *bm,
+        const float limit[2], const bool use_select, const bool use_winding);
 
 void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag);
 void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag);
diff --git a/source/blender/editors/mesh/editmesh_utils.c 
b/source/blender/editors/mesh/editmesh_utils.c
index 4706f04..51b4d62 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -614,7 +614,9 @@ void undo_push_mesh(bContext *C, const char *name)
 /**
  * Return a new UVVertMap from the editmesh
  */
-UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool use_select, const float 
limit[2])
+UvVertMap *BM_uv_vert_map_create(
+        BMesh *bm,
+        const float limit[2], const bool use_select, const bool use_winding)
 {
        BMVert *ev;
        BMFace *efa;
@@ -628,7 +630,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool 
use_select, const float limit[2
        unsigned int a;
        int totverts, i, totuv, totfaces;
        const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, 
CD_MLOOPUV);
-       bool *winding;
+       bool *winding = NULL;
        BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, 
BM_DEFAULT_NGON_STACK_SIZE);
 
        BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
@@ -654,7 +656,9 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool 
use_select, const float limit[2
 
        vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totverts, 
"UvMapVert_pt");
        buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, 
"UvMapVert");
-       winding = MEM_callocN(sizeof(*winding) * totfaces, "winding");
+       if (use_winding) {
+               winding = MEM_callocN(sizeof(*winding) * totfaces, "winding");
+       }
 
        if (!vmap->vert || !vmap->buf) {
                BKE_mesh_uv_vert_map_free(vmap);
@@ -663,7 +667,11 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool 
use_select, const float limit[2
        
        BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, a) {
                if ((use_select == false) || BM_elem_flag_test(efa, 
BM_ELEM_SELECT)) {
-                       float (*tf_uv)[2]     = (float 
(*)[2])BLI_buffer_resize_data(&tf_uv_buf, vec2f, efa->len);
+                       float (*tf_uv)[2];
+
+                       if (use_winding) {
+                               tf_uv = (float 
(*)[2])BLI_buffer_resize_data(&tf_uv_buf, vec2f, efa->len);
+                       }
 
                        BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i) 
{
                                buf->tfindex = i;
@@ -672,14 +680,17 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool 
use_select, const float limit[2
                                
                                buf->next = vmap->vert[BM_elem_index_get(l->v)];
                                vmap->vert[BM_elem_index_get(l->v)] = buf;
-                               
-                               luv = BM_ELEM_CD_GET_VOID_P(l, 
cd_loop_uv_offset);
-                               copy_v2_v2(tf_uv[i], luv->uv);
-
                                buf++;
+
+                               if (use_winding) {
+                                       luv = BM_ELEM_CD_GET_VOID_P(l, 
cd_loop_uv_offset);
+                                       copy_v2_v2(tf_uv[i], luv->uv);
+                               }
                        }
 
-                       winding[a] = cross_poly_v2((const float (*)[2])tf_uv, 
efa->len) > 0;
+                       if (use_winding) {
+                               winding[a] = cross_poly_v2((const float 
(*)[2])tf_uv, efa->len) > 0;
+                       }
                }
        }
        
@@ -717,7 +728,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool 
use_select, const float limit[2
                                sub_v2_v2v2(uvdiff, uv2, uv);
 
                                if (fabsf(uvdiff[0]) < limit[0] && 
fabsf(uvdiff[1]) < limit[1] &&
-                                   winding[iterv->f] == winding[v->f])
+                                   (!use_winding || winding[iterv->f] == 
winding[v->f]))
                                {
                                        if (lastv) lastv->next = next;
                                        else vlist = next;
@@ -737,7 +748,10 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool 
use_select, const float limit[2
                vmap->vert[a] = newvlist;
        }
 
-       MEM_freeN(winding);
+       if (use_winding) {
+               MEM_freeN(winding);
+       }
+
        BLI_buffer_free(&tf_uv_buf);
 
        return vmap;
diff --git a/source/blender/editors/uvedit/uvedit_ops.c 
b/source/blender/editors/uvedit/uvedit_ops.c
index a5c5a01..2e155e4 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1028,7 +1028,7 @@ static int uv_select_edgeloop(Scene *scene, Image *ima, 
BMEditMesh *em, NearestH
 
        /* setup */
        BM_mesh_elem_table_ensure(em->bm, BM_FACE);
-       vmap = BM_uv_vert_map_create(em->bm, 0, limit);
+       vmap = BM_uv_vert_map_create(em->bm, 0, limit, false);
 
        BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
 
@@ -1131,7 +1131,7 @@ static void uv_select_linked(Scene *scene, Image *ima, 
BMEditMesh *em, const flo
        const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, 
CD_MTEXPOLY);
 
        BM_mesh_elem_table_ensure(em->bm, BM_FACE); /* we can use this too */
-       vmap = BM_uv_vert_map_create(em->bm, !select_faces, limit);
+       vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
 
        if (vmap == NULL)
                return;
@@ -2714,7 +2714,7 @@ static void uv_select_flush_from_tag_face(SpaceImage 
*sima, Scene *scene, Object
                uvedit_pixel_to_float(sima, limit, 0.05);
                
                BM_mesh_elem_table_ensure(em->bm, BM_FACE);
-               vmap = BM_uv_vert_map_create(em->bm, 0, limit);
+               vmap = BM_uv_vert_map_create(em->bm, limit, false, false);
                if (vmap == NULL) {
                        return;
                }
@@ -2805,7 +2805,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage 
*sima, Scene *scene, Object
                uvedit_pixel_to_float(sima, limit, 0.05);
 
                BM_mesh_elem_table_ensure(em->bm, BM_FACE);
-               vmap = BM_uv_vert_map_create(em->bm, 0, limit);
+               vmap = BM_uv_vert_map_create(em->bm, limit, false, false);
                if (vmap == NULL) {
                        return;
                }
@@ -4037,7 +4037,7 @@ static int uv_seams_from_islands_exec(bContext *C, 
wmOperator *op)
 
        /* This code sets editvert->tmp.l to the index. This will be useful 
later on. */
        BM_mesh_elem_table_ensure(bm, BM_FACE);
-       vmap = BM_uv_vert_map_create(bm, 0, limit);
+       vmap = BM_uv_vert_map_create(bm, limit, false, false);
 
        BM_ITER_MESH (editedge, &iter, bm, BM_EDGES_OF_MESH) {
                /* flags to determine if we uv is separated from first editface 
match */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to