Commit: d2d3b934a0f9ffecaa8b05ae55bf256ed9da35b8
Author: Antony Riakiotakis
Date:   Tue Apr 29 23:05:22 2014 +0300
https://developer.blender.org/rBd2d3b934a0f9ffecaa8b05ae55bf256ed9da35b8

Add evil warning when object does not have a UV map. It would be ideal
to generate a UV map, but I think algorithms all require edit mode.

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

M       source/blender/editors/sculpt_paint/paint_image.c
M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/sculpt_paint/paint_intern.h

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

diff --git a/source/blender/editors/sculpt_paint/paint_image.c 
b/source/blender/editors/sculpt_paint/paint_image.c
index 0077c6f..ec036b8 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -745,8 +745,10 @@ static PaintOperation *texture_paint_init(bContext *C, 
wmOperator *op, const flo
 
        /* initialize from context */
        if (CTX_wm_region_view3d(C)) {
+               Object *ob = OBACT;
+               paint_proj_mesh_data_ensure(C, ob, op);
                pop->mode = PAINT_MODE_3D_PROJECT;
-               pop->custom_paint = paint_proj_new_stroke(C, OBACT, mouse, 
mode);
+               pop->custom_paint = paint_proj_new_stroke(C, ob, mouse, mode);
        }
        else {
                pop->mode = PAINT_MODE_2D;
@@ -1343,7 +1345,7 @@ static int texture_paint_toggle_poll(bContext *C)
 
 
 /* Make sure that active object has a material, and assign UVs and image 
layers (TODO) if they do not exist */
-void paint_proj_mesh_data_ensure(bContext *C, Object *ob)
+void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
 {
        Mesh *me;
        int layernum;
@@ -1385,6 +1387,8 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob)
        layernum = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY);
 
        if (layernum == 0) {
+               BKE_reportf(op->reports, RPT_WARNING, "Object did not have UV 
map. Recommend manual unwrap");
+
                ED_mesh_uv_texture_add(me, "UVMap", true);
        }
 
@@ -1436,7 +1440,7 @@ static int texture_paint_toggle_exec(bContext *C, 
wmOperator *op)
                 * cache in case we are loading a file */
                refresh_object_texpaint_images(ob, use_nodes);
 
-               paint_proj_mesh_data_ensure(C, ob);
+               paint_proj_mesh_data_ensure(C, ob, op);
 
                ob->mode |= mode_flag;
 
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 15a40c0..7b96692 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4479,8 +4479,6 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, 
const float mouse[2], int m
 {
        ProjPaintState *ps = MEM_callocN(sizeof(ProjPaintState), 
"ProjectionPaintState");
 
-       paint_proj_mesh_data_ensure(C, ob);
-
        project_state_init(C, ob, ps, mode);
 
        if (ps->tool == PAINT_TOOL_CLONE && mode == BRUSH_STROKE_INVERT) {
@@ -4565,10 +4563,11 @@ static int texture_paint_camera_project_exec(bContext 
*C, wmOperator *op)
        int orig_brush_size;
        IDProperty *idgroup;
        IDProperty *view_data = NULL;
+       Object *ob = OBACT;
 
-       paint_proj_mesh_data_ensure(C, OBACT);
+       paint_proj_mesh_data_ensure(C, ob, op);
 
-       project_state_init(C, OBACT, &ps, BRUSH_STROKE_NORMAL);
+       project_state_init(C, ob, &ps, BRUSH_STROKE_NORMAL);
 
        if (ps.ob == NULL || ps.ob->type != OB_MESH) {
                BKE_report(op->reports, RPT_ERROR, "No active mesh object");
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h 
b/source/blender/editors/sculpt_paint/paint_intern.h
index 7af490e..f03f2c5 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -165,7 +165,7 @@ void *paint_proj_new_stroke(struct bContext *C, struct 
Object *ob, const float m
 void paint_proj_stroke(const struct bContext *C, void *ps, const float 
prevmval_i[2], const float mval_i[2], float pressure, float distance, float 
size);
 void paint_proj_redraw(const struct bContext *C, void *pps, bool final);
 void paint_proj_stroke_done(void *ps);
-void paint_proj_mesh_data_ensure(bContext *C, struct Object *ob);
+void paint_proj_mesh_data_ensure(bContext *C, struct Object *ob, struct 
wmOperator *op);
 bool proj_paint_add_slot(bContext *C, int type, struct Material *ma);
 
 void paint_brush_color_get(struct Brush *br, bool color_correction, bool 
invert, float distance, float pressure, float color[3], struct 
ColorManagedDisplay *display);

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

Reply via email to