Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_unwrap_ops.c')
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index e24b34f0b8f..eeb21f5cb02 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -44,6 +44,7 @@
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_mesh.h"
#include "BKE_utildefines.h"
#include "BKE_tessmesh.h"
@@ -77,6 +78,11 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh;
BMFace *efa;
BMIter iter;
+ Image *ima;
+ bScreen *sc;
+ ScrArea *sa;
+ SpaceLink *slink;
+ SpaceImage *sima;
if(ED_uvedit_test(obedit)) {
return 1;
@@ -90,10 +96,31 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
if(!ED_uvedit_test(obedit)) {
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;
+ }
+ }
+ }
+ }
- // 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);
+ if(ima)
+ ED_uvedit_assign_image(scene, obedit, ima, NULL);
/* select new UV's */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -299,8 +326,8 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact
ms->lasttime = PIL_check_seconds_timer();
- DAG_object_flush_update(ms->scene, ms->obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ms->obedit);
+ DAG_id_flush_update(ms->obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, ms->obedit->data);
}
}
@@ -322,8 +349,8 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel)
param_stretch_end(ms->handle);
param_delete(ms->handle);
- DAG_object_flush_update(ms->scene, ms->obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ms->obedit);
+ DAG_id_flush_update(ms->obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, ms->obedit->data);
MEM_freeN(ms);
op->customdata= NULL;
@@ -421,6 +448,7 @@ void UV_OT_minimize_stretch(wmOperatorType *ot)
ot->name= "Minimize Stretch";
ot->idname= "UV_OT_minimize_stretch";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->description="DOC_BROKEN";
/* api callbacks */
ot->exec= minimize_stretch_exec;
@@ -449,8 +477,8 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
param_flush(handle);
param_delete(handle);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -481,8 +509,8 @@ static int average_islands_scale_exec(bContext *C, wmOperator *op)
param_flush(handle);
param_delete(handle);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -839,8 +867,8 @@ static int unwrap_exec(bContext *C, wmOperator *op)
param_delete(handle);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -968,8 +996,8 @@ static int from_view_exec(bContext *C, wmOperator *op)
uv_map_clip_correct(em, op);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1070,8 +1098,8 @@ static int reset_exec(bContext *C, wmOperator *op)
}
}
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
V_FREE(uvs);
@@ -1175,8 +1203,8 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
uv_map_clip_correct(em, op);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1248,8 +1276,8 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
uv_map_clip_correct(em, op);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1333,8 +1361,8 @@ static int cube_project_exec(bContext *C, wmOperator *op)
uv_map_clip_correct(em, op);
- DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+ DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}