Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / editors / uvedit / uvedit_unwrap_ops.c
index b20d390..c4f4704 100644 (file)
@@ -44,7 +44,6 @@
 #include "BKE_customdata.h"
 #include "BKE_depsgraph.h"
 #include "BKE_global.h"
-#include "BKE_image.h"
 #include "BKE_mesh.h"
 #include "BKE_utildefines.h"
 
@@ -76,11 +75,6 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
        EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
-       Image *ima;
-       bScreen *sc;
-       ScrArea *sa;
-       SpaceLink *slink;
-       SpaceImage *sima;
 
        if(ED_uvedit_test(obedit)) {
                BKE_mesh_end_editmesh(obedit->data, em);
@@ -94,31 +88,10 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
                BKE_mesh_end_editmesh(obedit->data, em);
                return 0;
        }
-
-       ima= CTX_data_edit_image(C);
-
-       if(!ima) {
-               /* no image in context in the 3d view, we find first image window .. */
-               sc= CTX_wm_screen(C);
-
-               for(sa=sc->areabase.first; sa; sa=sa->next) {
-                       slink= sa->spacedata.first;
-                       if(slink->spacetype == SPACE_IMAGE) {
-                               sima= (SpaceImage*)slink;
-
-                               ima= sima->image;
-                               if(ima) {
-                                       if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
-                                               ima= NULL;
-                                       else
-                                               break;
-                               }
-                       }
-               }
-       }
        
-       if(ima)
-               ED_uvedit_assign_image(scene, obedit, ima, NULL);
+       // XXX this image is not in context in 3d view .. only
+       // way to get would be to find the first image window?
+       ED_uvedit_assign_image(scene, obedit, CTX_data_edit_image(C), NULL);
        
        /* select new UV's */
        for(efa=em->faces.first; efa; efa=efa->next) {
@@ -290,8 +263,8 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact
 
                ms->lasttime = PIL_check_seconds_timer();
 
-               DAG_id_flush_update(ms->obedit->data, OB_RECALC_DATA);
-               WM_event_add_notifier(C, NC_GEOM|ND_DATA, ms->obedit->data);
+               DAG_object_flush_update(ms->scene, ms->obedit, OB_RECALC_DATA);
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ms->obedit);
        }
 }
 
@@ -313,8 +286,8 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel)
        param_stretch_end(ms->handle);
        param_delete(ms->handle);
 
-       DAG_id_flush_update(ms->obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, ms->obedit->data);
+       DAG_object_flush_update(ms->scene, ms->obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ms->obedit);
 
        MEM_freeN(ms);
        op->customdata= NULL;
@@ -440,8 +413,8 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
        param_flush(handle);
        param_delete(handle);
        
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -473,8 +446,8 @@ static int average_islands_scale_exec(bContext *C, wmOperator *op)
        param_flush(handle);
        param_delete(handle);
        
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -837,8 +810,8 @@ static int unwrap_exec(bContext *C, wmOperator *op)
 
        param_delete(handle);
 
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -970,8 +943,8 @@ static int from_view_exec(bContext *C, wmOperator *op)
 
        uv_map_clip_correct(em, op);
 
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -1037,8 +1010,8 @@ static int reset_exec(bContext *C, wmOperator *op)
                }
        }
 
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -1125,8 +1098,8 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
 
        uv_map_clip_correct(em, op);
 
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -1197,8 +1170,8 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
 
        uv_map_clip_correct(em, op);
 
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;
@@ -1284,8 +1257,8 @@ static int cube_project_exec(bContext *C, wmOperator *op)
 
        uv_map_clip_correct(em, op);
 
-       DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
        BKE_mesh_end_editmesh(obedit->data, em);
        return OPERATOR_FINISHED;