Revision: 41380
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41380
Author:   campbellbarton
Date:     2011-10-30 09:19:07 +0000 (Sun, 30 Oct 2011)
Log Message:
-----------
move make_uv_vert_map() to bmesh - use MLoopUV's rather than MTFace's.
also some formatting on BLI_array

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
    branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
    branches/bmesh/blender/source/blender/blenlib/BLI_array.h

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2011-10-30 
09:05:47 UTC (rev 41379)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2011-10-30 
09:19:07 UTC (rev 41380)
@@ -52,6 +52,7 @@
 struct CustomData;
 struct DerivedMesh;
 struct Scene;
+struct MLoopUV;
 
 #ifdef __cplusplus
 extern "C" {
@@ -153,7 +154,7 @@
        unsigned char tfindex, separate, flag;
 } UvMapVert;
 
-UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, 
unsigned int totface, unsigned int totvert, int selected, float *limit);
+UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct 
MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, 
float *limit);
 UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v);
 void free_uv_vert_map(UvVertMap *vmap);
 

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c      
2011-10-30 09:05:47 UTC (rev 41379)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c      
2011-10-30 09:19:07 UTC (rev 41380)
@@ -1981,27 +1981,31 @@
        return cos;
 }
 
-UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, 
unsigned int totface, unsigned int totvert, int selected, float *limit)
+
+/* ngon version wip, based on EDBM_make_uv_vert_map */
+/* 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 *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct 
MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, 
float *limit)
 {
        UvVertMap *vmap;
        UvMapVert *buf;
-       MFace *mf;
-       MTFace *tf;
+       MPoly *mp;
+       MLoopUV *luv;
        unsigned int a;
        int     i, totuv, nverts;
 
        totuv = 0;
 
        /* generate UvMapVert array */
-       mf= mface;
-       tf= tface;
-       for(a=0; a<totface; a++, mf++, tf++)
-               if(!selected || (!(mf->flag & ME_HIDE) && (mf->flag & 
ME_FACE_SEL)))
-                       totuv += (mf->v4)? 4: 3;
-               
+       mp= mpoly;
+       for(a=0; a<totpoly; a++, mp++)
+               if(!selected || (!(mp->flag & ME_HIDE) && (mp->flag & 
ME_FACE_SEL)))
+                       totuv += mp->totloop;
+
        if(totuv==0)
                return NULL;
-       
+
        vmap= (UvVertMap*)MEM_callocN(sizeof(*vmap), "UvVertMap");
        if (!vmap)
                return NULL;
@@ -2014,25 +2018,23 @@
                return NULL;
        }
 
-       mf= mface;
-       tf= tface;
-       for(a=0; a<totface; a++, mf++, tf++) {
-               if(!selected || (!(mf->flag & ME_HIDE) && (mf->flag & 
ME_FACE_SEL))) {
-                       nverts= (mf->v4)? 4: 3;
+       mp= mpoly;
+       for(a=0; a<totpoly; a++, mp++) {
+               if(!selected || (!(mp->flag & ME_HIDE) && (mp->flag & 
ME_FACE_SEL))) {
+                       nverts= mp->totloop;
 
                        for(i=0; i<nverts; i++) {
                                buf->tfindex= i;
                                buf->f= a;
                                buf->separate = 0;
-                               buf->next= vmap->vert[*(&mf->v1 + i)];
-                               vmap->vert[*(&mf->v1 + i)]= buf;
+                               buf->next= vmap->vert[mloop[mp->loopstart + 
i].v];
+                               vmap->vert[mloop[mp->loopstart + i].v]= buf;
                                buf++;
                        }
                }
        }
        
        /* sort individual uvs for each vert */
-       tf= tface;
        for(a=0; a<totvert; a++) {
                UvMapVert *newvlist= NULL, *vlist=vmap->vert[a];
                UvMapVert *iterv, *v, *lastv, *next;
@@ -2044,14 +2046,14 @@
                        v->next= newvlist;
                        newvlist= v;
 
-                       uv= (tf+v->f)->uv[v->tfindex];
+                       uv= mloopuv[mpoly[v->f].loopstart + v->tfindex].uv;
                        lastv= NULL;
                        iterv= vlist;
 
                        while(iterv) {
                                next= iterv->next;
 
-                               uv2= (tf+iterv->f)->uv[iterv->tfindex];
+                               uv2= mloopuv[mpoly[iterv->f].loopstart + 
iterv->tfindex].uv;
                                sub_v2_v2v2(uvdiff, uv2, uv);
 
 

Modified: branches/bmesh/blender/source/blender/blenlib/BLI_array.h
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/BLI_array.h   2011-10-30 
09:05:47 UTC (rev 41379)
+++ branches/bmesh/blender/source/blender/blenlib/BLI_array.h   2011-10-30 
09:19:07 UTC (rev 41380)
@@ -56,32 +56,32 @@
 behaviour, though it may not be the best in practice.
 */
 
-#define BLI_array_declare(arr) \
-       int _##arr##_count=0; \
-       void *_##arr##_tmp; \
+#define BLI_array_declare(arr)                                                \
+       int _##arr##_count=0;                                                   
  \
+       void *_##arr##_tmp;                                                     
  \
        void *_##arr##_static = NULL
 
-/* this will use stack space, up to maxstatic array elements, befoe
+/* this will use stack space, up to maxstatic array elements, before
  * switching to dynamic heap allocation */
-#define BLI_array_staticdeclare(arr, maxstatic) \
-       int _##arr##_count=0; \
-       void *_##arr##_tmp; \
+#define BLI_array_staticdeclare(arr, maxstatic)                               \
+       int _##arr##_count=0;                                                   
  \
+       void *_##arr##_tmp;                                                     
  \
        char _##arr##_static[maxstatic*sizeof(arr)]
 
 
 /* this returns the entire size of the array, including any buffering. */
-#define BLI_array_totalsize_dyn(arr)  ( \
-       ((arr)==NULL) ? \
-           0 : \
-           MEM_allocN_len(arr) / sizeof(*arr)  \
+#define BLI_array_totalsize_dyn(arr)  (                                       \
+       ((arr)==NULL) ?                                                         
  \
+               0 :                                                             
      \
+               MEM_allocN_len(arr) / sizeof(*arr)                              
      \
 )
 
 
-#define BLI_array_totalsize(arr)  ( \
-       (signed int) \
-       (((void *)(arr) == (void *)_##arr##_static && (void *)(arr) != NULL) ? \
-           (sizeof(_##arr##_static) / sizeof(*arr)) : \
-           BLI_array_totalsize_dyn(arr)) \
+#define BLI_array_totalsize(arr)  (                                           \
+       (signed int)                                                            
  \
+       (((void *)(arr) == (void *)_##arr##_static && (void *)(arr) != NULL) ?  
  \
+               (sizeof(_##arr##_static) / sizeof(*arr)) :                      
      \
+               BLI_array_totalsize_dyn(arr))                                   
      \
 )
 
 
@@ -89,74 +89,74 @@
 #define BLI_array_count(arr) _##arr##_count
 
 /* grow the array by one.  zeroes the new elements. */
-#define _BLI_array_growone(arr)  ( \
-       (BLI_array_totalsize(arr) > _##arr##_count) ? \
-           ++_##arr##_count : \
-           ((_##arr##_tmp = MEM_callocN( \
-                   sizeof(*arr)*(_##arr##_count*2+2), \
-                   #arr " " __FILE__ ":" STRINGIFY(__LINE__) \
-                   ) \
-            ), \
-           (arr && memcpy(_##arr##_tmp, arr, sizeof(*arr) * _##arr##_count)), \
-           (arr && ((void *)(arr) != (void*)_##arr##_static ? \
-                   (MEM_freeN(arr), arr) : \
-                   arr)), \
-           (arr = _##arr##_tmp), \
-           _##arr##_count++)  \
+#define _BLI_array_growone(arr)  (                                            \
+       (BLI_array_totalsize(arr) > _##arr##_count) ?                           
  \
+               ++_##arr##_count :                                              
      \
+               ((_##arr##_tmp = MEM_callocN(                                   
      \
+                               sizeof(*arr)*(_##arr##_count*2+2),              
              \
+                               #arr " " __FILE__ ":" STRINGIFY(__LINE__)       
              \
+                               )                                               
              \
+                ),                                                             
      \
+               (arr && memcpy(_##arr##_tmp, arr, sizeof(*arr) * 
_##arr##_count)),    \
+               (arr && ((void *)(arr) != (void*)_##arr##_static ?              
      \
+                               (MEM_freeN(arr), arr) :                         
              \
+                               arr)),                                          
              \
+               (arr = _##arr##_tmp),                                           
      \
+               _##arr##_count++)                                               
      \
 )
 
 
 /* returns length of array */
-#define BLI_array_growone(arr)  ( \
-       ((void *)(arr)==NULL && (void *)(_##arr##_static) != NULL) ? \
-           ((arr=(void*)_##arr##_static), ++_##arr##_count) : \
-           _BLI_array_growone(arr) \
+#define BLI_array_growone(arr)  (                                             \
+       ((void *)(arr)==NULL && (void *)(_##arr##_static) != NULL) ?            
  \
+               ((arr=(void*)_##arr##_static), ++_##arr##_count) :              
      \
+               _BLI_array_growone(arr)                                         
      \
 )
 
 
 /* appends an item to the array and returns a pointer to the item in the array.
  * item is not a pointer, but actual data value.*/
-#define BLI_array_append(arr, item)  ( \
-       BLI_array_growone(arr), \
-       (arr[_##arr##_count-1] = item), \
-       (arr+(_##arr##_count-1)) \
+#define BLI_array_append(arr, item)  (                                        \
+       BLI_array_growone(arr),                                                 
  \
+       (arr[_##arr##_count-1] = item),                                         
  \
+       (arr+(_##arr##_count-1))                                                
  \
 )
 
 
 /* grow an array by a specified number of items. */
 /* TODO, this could be done in a less crappy way by not looping - campbell */
-#define BLI_array_growitems(arr, num) \
-       { \
-               int _i; \
-               for (_i = 0; _i < (num); _i++) { \
-                       BLI_array_growone(arr); \
-               } \
+#define BLI_array_growitems(arr, num)                                         \
+       {                                                                       
  \
+               int _i;                                                         
      \
+               for (_i = 0; _i < (num); _i++) {                                
      \
+                       BLI_array_growone(arr);                                 
          \
+               }                                                               
      \
        }
 
-#define BLI_array_free(arr) \
-       if (arr && (char *)arr != _##arr##_static) { \
-               BLI_array_fake_user(arr); \
-               MEM_freeN(arr); \
+#define BLI_array_free(arr)                                                   \
+       if (arr && (char *)arr != _##arr##_static) {                            
  \
+               BLI_array_fake_user(arr);                                       
      \
+               MEM_freeN(arr);                                                 
      \
        }
 
-#define BLI_array_pop(arr)  ( \
-       (arr&&_##arr##_count) ? \
-           arr[--_##arr##_count] : \
-           0 \
+#define BLI_array_pop(arr)  (                                                 \
+       (arr&&_##arr##_count) ?                                                 
  \

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