merge with/from trunk at r35190
[blender.git] / source / blender / editors / sculpt_paint / paint_vertex.c
index 12b9e982d02cd3d7638196cafe433be718d2f4dd..e16dac94076d17e377c7e685c7d46dbb69fc109a 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
@@ -42,6 +42,7 @@
 #include "BLI_math.h"
 #include "BLI_memarena.h"
 #include "BLI_cellalloc.h"
+#include "BLI_utildefines.h"
 #include "BLI_ghash.h"
 
 #include "IMB_imbuf.h"
@@ -158,7 +159,7 @@ static int *get_indexarray(Mesh *me)
 /* in contradiction to cpack drawing colors, the MCOL colors (vpaint colors) are per byte! 
    so not endian sensitive. Mcol = ABGR!!! so be cautious with cpack calls */
 
-unsigned int rgba_to_mcol(float r, float g, float b, float a)
+static unsigned int rgba_to_mcol(float r, float g, float b, float a)
 {
        int ir, ig, ib, ia;
        unsigned int col;
@@ -334,7 +335,7 @@ static void make_vertexcol(Object *ob)      /* single ob */
 
        memset(me->mcol, 255, 4*sizeof(MCol)*me->totface);
 
-       DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&me->id, 0);
        
 }
 
@@ -409,7 +410,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol)
                }
        }
        
-       DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&me->id, 0);
 }
 
 
@@ -493,7 +494,7 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
                                                dw->weight= paintweight;
                                                
                                                if(me->editflag & ME_EDIT_MIRROR_X) {   /* x mirror painting */
-                                                       int j= mesh_get_x_mirror_vert(ob, faceverts[i]);
+                                                       int j= -1; //BMESH_TODO mesh_get_x_mirror_vert(ob, faceverts[i]);
                                                        if(j>=0) {
                                                                /* copy, not paint again */
                                                                if(vgroup_mirror != -1) {
@@ -523,10 +524,10 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
        MEM_freeN(indexar);
        copy_wpaint_prev(wp, NULL, 0);
 
-       DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&me->id, 0);
 }
 
-/* XXX: should be re-implemented as a vertex/weight paint 'colour correct' operator
+/* XXX: should be re-implemented as a vertex/weight paint 'color correct' operator
  
 void vpaint_dogamma(Scene *scene)
 {
@@ -928,7 +929,7 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float
 /*     sets wp->weight to the closest weight value to vertex */
 /*     note: we cant sample frontbuf, weight colors are interpolated too unpredictable */
 #if 0
-void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode)
+static void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int mode)
 {
        ViewContext vc;
        ToolSettings *ts= scene->toolsettings;
@@ -987,7 +988,7 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *v3d, int mode)
                                        val= 0; // XXX pupmenu(str);
                                        if(val>=0) {
                                                ob->actdef= val+1;
-                                               DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+                                               DAG_id_tag_update(&me->id, 0);
                                        }
                                        MEM_freeN(str);
                                }
@@ -1102,7 +1103,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
        do_weight_paint_auto_normalize(me->dvert+index, vgroup, validmap);
 
        if(me->editflag & ME_EDIT_MIRROR_X) {   /* x mirror painting */
-               int j= mesh_get_x_mirror_vert(ob, index);
+               int j= -1; //BMESH_TODO mesh_get_x_mirror_vert(ob, index);
                if(j>=0) {
                        /* copy, not paint again */
                        if(vgroup_mirror != -1)
@@ -1120,7 +1121,7 @@ static void do_weight_paint_vertex(VPaint *wp, Object *ob, int index,
 
 /* *************** set wpaint operator ****************** */
 
-static int set_wpaint(bContext *C, wmOperator *op)             /* toggle */
+static int set_wpaint(bContext *C, wmOperator *UNUSED(op))             /* toggle */
 {              
        Object *ob= CTX_data_active_object(C);
        Scene *scene= CTX_data_scene(C);
@@ -1139,7 +1140,7 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                * exit (exit needs doing regardless because we
                                * should redeform).
                */
-       DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&me->id, 0);
        
        if(ob->mode & OB_MODE_WEIGHT_PAINT) {
                Object *par;
@@ -1150,7 +1151,7 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
                paint_cursor_start(C, weight_paint_poll);
                
-               mesh_octree_table(ob, NULL, NULL, 's');
+               //BMESH_TODO mesh_octree_table(ob, NULL, NULL, 's');
                
                /* verify if active weight group is also active bone */
                par= modifiers_isDeformedByArmature(ob);
@@ -1162,8 +1163,8 @@ static int set_wpaint(bContext *C, wmOperator *op)                /* toggle */
                }
        }
        else {
-               mesh_octree_table(NULL, NULL, NULL, 'e');
-               mesh_mirrtopo_table(NULL, 'e');
+               //BMESH_TODO mesh_octree_table(NULL, NULL, NULL, 'e');
+               //BMESH_TODO mesh_mirrtopo_table(NULL, 'e');
        }
        
        WM_event_add_notifier(C, NC_SCENE|ND_MODE, scene);
@@ -1315,7 +1316,7 @@ struct WPaintData {
        char *vgroup_validmap; /*stores if vgroups tie to deforming bones or not*/
 };
 
-static char *wpaint_make_validmap(Mesh *me, Object *ob)
+static char *wpaint_make_validmap(Object *ob)
 {
        bDeformGroup *dg;
        ModifierData *md;
@@ -1373,7 +1374,7 @@ static char *wpaint_make_validmap(Mesh *me, Object *ob)
        return validmap;
 }
 
-static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event)
+static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
        Scene *scene= CTX_data_scene(C);
        struct PaintStroke *stroke = op->customdata;
@@ -1397,8 +1398,10 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event)
        makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH);
 
        /* if nothing was added yet, we make dverts and a vertex deform group */
-       if (!me->dvert)
+       if (!me->dvert) {
                ED_vgroup_data_create(&me->id);
+               WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
+       }
        
        /* make mode data storage */
        wpd= MEM_callocN(sizeof(struct WPaintData), "WPaintData");
@@ -1410,7 +1413,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event)
          vgroups affect deform bones*/
        wpd->auto_normalize = ts->auto_normalize;
        if (wpd->auto_normalize)
-               wpd->vgroup_validmap = wpaint_make_validmap(me, ob);
+               wpd->vgroup_validmap = wpaint_make_validmap(ob);
        
        //      if(qual & LR_CTRLKEY) {
        //              sample_wpaint(scene, ar, v3d, 0);
@@ -1493,7 +1496,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        Object *ob;
        Mesh *me;
        float mat[4][4];
-       float paintweight= ts->vgroup_weight;
+       float paintweight;
        int *indexar;
        int totindex, index, totw, flip;
        float alpha;
@@ -1578,10 +1581,10 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                        }
                                        
                        if(brush->vertexpaint_tool==VP_BLUR) {
-                               MDeformWeight *dw, *(*dw_func)(MDeformVert *, int);
+                               MDeformWeight *dw, *(*dw_func)(MDeformVert *, const int);
                                                
                                if(wp->flag & VP_ONLYVGROUP)
-                                       dw_func= (void *)defvert_find_index; /* uses a const, cast to quiet warning */
+                                       dw_func= (MDeformWeight *(*)(MDeformVert *, const int))defvert_find_index;
                                else
                                        dw_func= defvert_verify_index;
                                                
@@ -1622,7 +1625,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
                        
        swap_m4m4(vc->rv3d->persmat, mat);
                        
-       DAG_id_flush_update(ob->data, OB_RECALC_DATA);
+       DAG_id_tag_update(ob->data, 0);
        ED_region_tag_redraw(vc->ar);
 }
 
@@ -1661,7 +1664,7 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke)
                }
        }
        
-       DAG_id_flush_update(ob->data, OB_RECALC_DATA);  
+       DAG_id_tag_update(ob->data, 0);
 }
 
 
@@ -1699,7 +1702,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
        RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
 }
 
-static int weight_paint_set_exec(bContext *C, wmOperator *op)
+static int weight_paint_set_exec(bContext *C, wmOperator *UNUSED(op))
 {
        struct Scene *scene= CTX_data_scene(C);
        Object *obact = CTX_data_active_object(C);
@@ -1763,7 +1766,7 @@ static int set_vpaint(bContext *C, wmOperator *op)                /* toggle */
        
        if (me)
                /* update modifier stack for mapping requirements */
-               DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+               DAG_id_tag_update(&me->id, 0);
        
        WM_event_add_notifier(C, NC_SCENE|ND_MODE, scene);
        
@@ -1862,7 +1865,7 @@ static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me,
        }
 }
 
-static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event)
+static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *UNUSED(event))
 {
        ToolSettings *ts= CTX_data_tool_settings(C);
        struct PaintStroke *stroke = op->customdata;
@@ -1905,7 +1908,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent
 }
 
 #if 0
-static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, float mval[2], float pressure, int flip)
+static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index, float mval[2], float pressure, int UNUSED(flip))
 {
        ViewContext *vc = &vpd->vc;
        Brush *brush = paint_brush(&vp->paint);
@@ -2088,7 +2091,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
        do_shared_vertexcol(me);
 
        ED_region_tag_redraw(vc->ar);           
-       DAG_id_flush_update(ob->data, OB_RECALC_DATA);
+       DAG_id_tag_update(ob->data, 0);
 }
 
 static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke)
@@ -2157,9 +2160,9 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
        Mesh *me= ob->data;
        int type= RNA_enum_get(op->ptr, "type");
 
-       create_vgroups_from_armature(scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
+       create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
 
-       DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+       DAG_id_tag_update(&me->id, 0);
        WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
 
        return OPERATOR_FINISHED;