fix reading out of buffer bounds for recent vertex paint commit.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 14 Mar 2013 05:59:34 +0000 (05:59 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 14 Mar 2013 05:59:34 +0000 (05:59 +0000)
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/editors/sculpt_paint/paint_vertex.c

index f44436f965cd9fc255529753ef2237fee342588f..3a4684257f62aff9245360c27e95c1ab74468392 100644 (file)
@@ -70,7 +70,7 @@ float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* u
 
 /* sampling */
 float BKE_brush_sample_tex_3D(const Scene *scene, struct Brush *br, const float point[3],
-                              float rgba[3], const int thread, struct ImagePool *pool);
+                              float rgba[4], const int thread, struct ImagePool *pool);
 float BKE_brush_sample_tex_2D(const struct Scene *scene, struct Brush *brush, const float xy[2],
                               float rgba[4], struct ImagePool *pool);
 void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size,
index 5d7f9afa78c84bddef4f32276254f5cb02339b5b..d341a2c06e1c045c6931377256370cce1b04ba2b 100644 (file)
@@ -476,7 +476,7 @@ int BKE_brush_clone_image_delete(Brush *brush)
  * region space mouse coordinates, or 3d world coordinates for 3D mapping */
 float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
                               const float point[3],
-                              float rgba[3], const int thread,
+                              float rgba[4], const int thread,
                               struct ImagePool *pool)
 {
        UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
index 8f1d241dd9f5cb3102c086e89a7d95a64fa08aeb..e38b92a8a4cdd575158382c91282a1b34babc0a6 100644 (file)
@@ -858,25 +858,28 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
 static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co[3],
                                  const float mval[2], const float brush_size_pressure, float rgba[4])
 {
-       float vertco[2];
+       float co_ss[2];  /* screenspace */
 
        if (ED_view3d_project_float_object(vc->ar,
-                                          co, vertco,
+                                          co, co_ss,
                                           V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
        {
                float delta[2];
                float dist_squared;
 
-               sub_v2_v2v2(delta, mval, vertco);
+               sub_v2_v2v2(delta, mval, co_ss);
                dist_squared = dot_v2v2(delta, delta); /* len squared */
                if (dist_squared <= brush_size_pressure * brush_size_pressure) {
                        Brush *brush = paint_brush(&vp->paint);
                        const float dist = sqrtf(dist_squared);
                        if (brush->mtex.tex && rgba) {
-                               if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D)
+                               if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) {
                                        BKE_brush_sample_tex_3D(vc->scene, brush, co, rgba, 0, NULL);
-                               else
-                                       BKE_brush_sample_tex_3D(vc->scene, brush, vertco, rgba, 0, NULL);
+                               }
+                               else {
+                                       const float co_ss_3d[3] = {co_ss[0], co_ss[1], 0.0f};  /* we need a 3rd empty value */
+                                       BKE_brush_sample_tex_3D(vc->scene, brush, co_ss_3d, rgba, 0, NULL);
+                               }
                        }
                        return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
                }