Revision: 39572
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39572
Author:   psy-fi
Date:     2011-08-20 20:19:35 +0000 (Sat, 20 Aug 2011)
Log Message:
-----------
uv paint brushes
=================
-fixes for UV synch mode + use the better find_nearest_uv_vert function for 
island detection(old way was missing some hits).

Yes, screencasts do expose bugs :)

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c
    branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h
    branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt  
2011-08-20 19:16:46 UTC (rev 39571)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt  
2011-08-20 20:19:35 UTC (rev 39572)
@@ -28,6 +28,7 @@
        ../../imbuf
        ../../makesdna
        ../../makesrna
+       ../uvedit
        ../../render/extern/include
        ../../windowmanager
        ../../../../intern/guardedalloc

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c      
2011-08-20 19:16:46 UTC (rev 39571)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_uv.c      
2011-08-20 20:19:35 UTC (rev 39572)
@@ -62,6 +62,7 @@
 #include "RNA_enum_types.h"
 
 #include "paint_intern.h"
+#include "uvedit_intern.h"
 
 #include "UI_view2d.h"
 
@@ -463,10 +464,18 @@
                data->uvpaint = &ts->uvpaint->paint;
 
                if(do_island_optimization){
-                       data->elementMap = EM_make_uv_element_map(em, 0, 1);
-               }else {
                        /* We will need island information */
-                       data->elementMap = EM_make_uv_element_map(em, 0, 0);
+                       if(ts->uv_flag & UV_SYNC_SELECTION){
+                               data->elementMap = EM_make_uv_element_map(em, 
0, 1);
+                       }else{
+                               data->elementMap = EM_make_uv_element_map(em, 
1, 1);
+                       }
+               }else {
+                       if(ts->uv_flag & UV_SYNC_SELECTION){
+                               data->elementMap = EM_make_uv_element_map(em, 
0, 0);
+                       }else{
+                               data->elementMap = EM_make_uv_element_map(em, 
1, 0);
+                       }
                }
 
                if(!data->elementMap){
@@ -479,30 +488,12 @@
 
                /* we need to find the active island here */
                if(do_island_optimization){
-                       float mindist = 1e10;
-                       EditFace *nearest_face;
-                       int nearest_index;
                        UvElement *element;
+                       NearestHit hit;
+                       Image *ima= CTX_data_edit_image(C);
+                       find_nearest_uv_vert(scene, ima, em, co, NULL, &hit);
 
-                       for(efa = em->faces.first; efa; efa = efa->next){
-                               int nverts = efa->v4 ? 4 : 3;
-                               if(efa->h)
-                                       continue;
-                               mt = CustomData_em_get(&em->fdata, efa->data, 
CD_MTFACE);
-                               for(i = 0; i < nverts; i++){
-                                       float diff[2], dist;
-                                       sub_v2_v2v2(diff, mt->uv[i], co);
-                                       dist = fabs(diff[0]) + fabs(diff[0]);
-                                       if(dist <= mindist)
-                                       {
-                                               mindist = dist;
-                                               nearest_face = efa;
-                                               nearest_index = i;
-                                       }
-                               }
-                       }
-
-                       element = get_uv_element(data->elementMap, 
nearest_face, nearest_index);
+                       element = get_uv_element(data->elementMap, hit.efa, 
hit.uv);
                        island_index = element->island;
                }
 
@@ -682,14 +673,6 @@
 
                        data->initial_stroke->totalInitialSelected = counter;
                }
-
-               if(!(ts->uv_paint_settings & UV_PAINT_ALL_ISLANDS)){
-/*                     UvElement *element = map->vert[(*(&efa->v1 + 
index))->tmp.l];
-                               for(;element; element = element->next){
-                                       if(element->face == efa)
-                                               return element - map->buf;
-                               }*/
-               }
        }
 
        return op->customdata;

Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h       
2011-08-20 19:16:46 UTC (rev 39571)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_intern.h       
2011-08-20 20:19:35 UTC (rev 39572)
@@ -82,6 +82,17 @@
 float uv_area(float uv[][2], int quad);
 void uv_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy);
 
+/* find nearest */
+typedef struct NearestHit {
+       struct EditFace *efa;
+       struct MTFace *tf;
+
+       int vert, uv;
+       int edge, vert2;
+} NearestHit;
+
+void find_nearest_uv_vert(struct Scene *scene, struct Image *ima, struct 
EditMesh *em, float co[2], float penalty[2], struct NearestHit *hit);
+
 /* operators */
 void UV_OT_average_islands_scale(struct wmOperatorType *ot);
 void UV_OT_cube_project(struct wmOperatorType *ot);

Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c  
2011-08-20 19:16:46 UTC (rev 39571)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c  
2011-08-20 20:19:35 UTC (rev 39572)
@@ -478,14 +478,6 @@
 
 /************************** find nearest ****************************/
 
-typedef struct NearestHit {
-       EditFace *efa;
-       MTFace *tf;
-
-       int vert, uv;
-       int edge, vert2;
-} NearestHit;
-
 static void find_nearest_uv_edge(Scene *scene, Image *ima, EditMesh *em, float 
co[2], NearestHit *hit)
 {
        MTFace *tf;
@@ -585,7 +577,7 @@
        return (c1*c2 >= 0.0f);
 }
 
-static void find_nearest_uv_vert(Scene *scene, Image *ima, EditMesh *em, float 
co[2], float penalty[2], NearestHit *hit)
+void find_nearest_uv_vert(Scene *scene, Image *ima, EditMesh *em, float co[2], 
float penalty[2], NearestHit *hit)
 {
        EditFace *efa;
        EditVert *eve;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to