Revision: 48968
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48968
Author:   campbellbarton
Date:     2012-07-16 13:13:27 +0000 (Mon, 16 Jul 2012)
Log Message:
-----------
svn merge ^/trunk/blender -r48961:48967

Revision Links:
--------------
    
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48961

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_rasterize.c
    branches/soc-2011-tomato/source/blender/blenlib/intern/math_geom.c

Property Changed:
----------------
    branches/soc-2011-tomato/
    branches/soc-2011-tomato/source/blender/editors/interface/interface.c
    branches/soc-2011-tomato/source/blender/editors/space_outliner/


Property changes on: branches/soc-2011-tomato
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/vgroup_modifiers:38694-39989
/trunk/blender:36831-48961
   + 
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/vgroup_modifiers:38694-39989
/trunk/blender:36831-48967

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c    
2012-07-16 13:12:52 UTC (rev 48967)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c    
2012-07-16 13:13:27 UTC (rev 48968)
@@ -254,7 +254,7 @@
        /* cyclic shapes are more usually used */
        // spline->flag |= MASK_SPLINE_CYCLIC; // disable because its not so 
nice for drawing. could be done differently
 
-       spline->weight_interp = MASK_SPLINE_INTERP_LINEAR;
+       spline->weight_interp = MASK_SPLINE_INTERP_EASE;
 
        BKE_mask_parent_init(&spline->parent);
 

Modified: 
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_rasterize.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_rasterize.c  
2012-07-16 13:12:52 UTC (rev 48967)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_rasterize.c  
2012-07-16 13:13:27 UTC (rev 48968)
@@ -302,6 +302,10 @@
 
 static void layer_bucket_init_dummy(MaskRasterLayer *layer)
 {
+       layer->face_tot = 0;
+       layer->face_coords = NULL;
+       layer->face_array  = NULL;
+
        layer->buckets_x = 0;
        layer->buckets_y = 0;
 
@@ -309,6 +313,8 @@
        layer->buckets_xy_scalar[1] = 0.0f;
 
        layer->buckets_face = NULL;
+
+       BLI_rctf_init(&layer->bounds, -1.0f, -1.0f, -1.0f, -1.0f);
 }
 
 static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
@@ -383,14 +389,21 @@
                                CLAMP(ymax, 0.0f,  1.0f);
 
                                {
-                                       const unsigned int xi_min = (unsigned 
int) ((xmin - layer->bounds.xmin) * layer->buckets_xy_scalar[0]);
-                                       const unsigned int xi_max = (unsigned 
int) ((xmax - layer->bounds.xmin) * layer->buckets_xy_scalar[0]);
-                                       const unsigned int yi_min = (unsigned 
int) ((ymin - layer->bounds.ymin) * layer->buckets_xy_scalar[1]);
-                                       const unsigned int yi_max = (unsigned 
int) ((ymax - layer->bounds.ymin) * layer->buckets_xy_scalar[1]);
+                                       unsigned int xi_min = (unsigned int) 
((xmin - layer->bounds.xmin) * layer->buckets_xy_scalar[0]);
+                                       unsigned int xi_max = (unsigned int) 
((xmax - layer->bounds.xmin) * layer->buckets_xy_scalar[0]);
+                                       unsigned int yi_min = (unsigned int) 
((ymin - layer->bounds.ymin) * layer->buckets_xy_scalar[1]);
+                                       unsigned int yi_max = (unsigned int) 
((ymax - layer->bounds.ymin) * layer->buckets_xy_scalar[1]);
                                        void *face_index_void = 
SET_UINT_IN_POINTER(face_index);
 
                                        unsigned int xi, yi;
 
+                                       /* this should _almost_ never happen 
but since it can in extreme cases,
+                                        * we have to clamp the values or we 
overrun the buffer and crash */
+                                       CLAMP(xi_min, 0, layer->buckets_x - 1);
+                                       CLAMP(xi_max, 0, layer->buckets_x - 1);
+                                       CLAMP(yi_min, 0, layer->buckets_y - 1);
+                                       CLAMP(yi_max, 0, layer->buckets_y - 1);
+
                                        for (yi = yi_min; yi <= yi_max; yi++) {
                                                unsigned int bucket_index = 
(layer->buckets_x * yi) + xi_min;
                                                for (xi = xi_min; xi <= xi_max; 
xi++, bucket_index++) {
@@ -471,9 +484,9 @@
 
        for (masklay = mask->masklayers.first, masklay_index = 0; masklay; 
masklay = masklay->next, masklay_index++) {
 
-               const unsigned int tot_splines = 
BLI_countlist(&masklay->splines);
                /* we need to store vertex ranges for open splines for filling 
*/
-               MaskRasterSplineInfo *open_spline_ranges = 
MEM_callocN(sizeof(*open_spline_ranges) * tot_splines, __func__);
+               unsigned int tot_splines;
+               MaskRasterSplineInfo *open_spline_ranges;
                unsigned int   open_spline_index = 0;
 
                MaskSpline *spline;
@@ -487,10 +500,16 @@
                unsigned int sf_vert_tot = 0;
                unsigned int tot_feather_quads = 0;
 
-               if (masklay->restrictflag & MASK_RESTRICT_RENDER) {
+               if (masklay->restrictflag & MASK_RESTRICT_RENDER || 
masklay->alpha == 0.0f) {
+                       MaskRasterLayer *layer = 
&mr_handle->layers[masklay_index];
+                       layer_bucket_init_dummy(layer);
+                       layer->alpha = 0.0f; /* signal to skip this layer */
                        continue;
                }
 
+               tot_splines = BLI_countlist(&masklay->splines);
+               open_spline_ranges = MEM_callocN(sizeof(*open_spline_ranges) * 
tot_splines, __func__);
+
                BLI_scanfill_begin(&sf_ctx);
 
                for (spline = masklay->splines.first; spline; spline = 
spline->next) {
@@ -819,13 +838,7 @@
                                        MEM_freeN(face_coords);
                                        MEM_freeN(face_array);
 
-                                       layer->face_tot = 0;
-                                       layer->face_coords = NULL;
-                                       layer->face_array  = NULL;
-
                                        layer_bucket_init_dummy(layer);
-
-                                       BLI_rctf_init(&layer->bounds, -1.0f, 
-1.0f, -1.0f, -1.0f);
                                }
 
                                /* copy as-is */
@@ -849,6 +862,7 @@
 /* --------------------------------------------------------------------- */
 
 /* 2D ray test */
+#if 0
 static float maskrasterize_layer_z_depth_tri(const float pt[2],
                                              const float v1[3], const float 
v2[3], const float v3[3])
 {
@@ -856,14 +870,16 @@
        barycentric_weights_v2(v1, v2, v3, pt, w);
        return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]);
 }
+#endif
 
-#if 0
+#if 1
 static float maskrasterize_layer_z_depth_quad(const float pt[2],
                                               const float v1[3], const float 
v2[3], const float v3[3], const float v4[3])
 {
        float w[4];
        barycentric_weights_v2_quad(v1, v2, v3, v4, pt, w);
-       return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * 
w[3]);
+       //return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * 
w[3]);
+       return w[2] + w[3];  /* we can make this assumption for small speedup */
 }
 #endif
 
@@ -904,8 +920,12 @@
                {
 
                        /* needs work */
-#if 0
-                       if (isect_point_quad_v2(xy, cos[face[0]], cos[face[1]], 
cos[face[2]], cos[face[3]])) {
+#if 1
+                       /* quad check fails for bowtie, so keep using 2 tri 
checks */
+                       //if (isect_point_quad_v2(xy, cos[face[0]], 
cos[face[1]], cos[face[2]], cos[face[3]]))
+                       if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], 
cos[face[2]]) ||
+                           isect_point_tri_v2(xy, cos[face[0]], cos[face[2]], 
cos[face[3]]))
+                       {
                                return maskrasterize_layer_z_depth_quad(xy, 
cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]);
                        }
 #elif 1
@@ -978,6 +998,11 @@
        for (i = 0; i < layers_tot; i++, layer++) {
                float value_layer;
 
+               /* also used as signal for unused layer (when render is 
disabled) */
+               if (layer->alpha == 0.0f) {
+                       continue;
+               }
+
                if (BLI_in_rctf_v(&layer->bounds, xy)) {
                        value_layer = 1.0f - layer_bucket_depth_from_xy(layer, 
xy);
 

Modified: branches/soc-2011-tomato/source/blender/blenlib/intern/math_geom.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenlib/intern/math_geom.c  
2012-07-16 13:12:52 UTC (rev 48967)
+++ branches/soc-2011-tomato/source/blender/blenlib/intern/math_geom.c  
2012-07-16 13:13:27 UTC (rev 48968)
@@ -1977,35 +1977,45 @@
 }
 
 /* same as #barycentric_weights_v2 but works with a quad,
- * note: untested for values outside the quad's bounds.
- * note: there may be a more efficient method to do this, just figured it out 
- campbell */
+ * note: untested for values outside the quad's bounds
+ * this is #interp_weights_poly_v2 expanded for quads only */
 void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const 
float v3[2], const float v4[2],
                                  const float co[2], float w[4])
 {
-       float wtot;
+#define MEAN_VALUE_HALF_TAN_V2(_area, i1, i2) ((_area = cross_v2v2(dirs[i1], 
dirs[i2])) != 0.0f ? \
+                                                  (((lens[i1] * lens[i2]) - 
dot_v2v2(dirs[i1], dirs[i2])) / _area) : 0.0f)
 
-       const float areas_co[4] = {
-           area_tri_signed_v2(v1, v2, co),
-           area_tri_signed_v2(v2, v3, co),
-           area_tri_signed_v2(v3, v4, co),
-           area_tri_signed_v2(v4, v1, co),
+       float wtot, area;
+
+       const float dirs[4][2] = {
+           {v1[0] - co[0], v1[1] - co[1]},
+           {v2[0] - co[0], v2[1] - co[1]},
+           {v3[0] - co[0], v3[1] - co[1]},
+           {v4[0] - co[0], v4[1] - co[1]},
        };
 
-       const float areas_diag[4] = {
-           area_tri_signed_v2(v4, v1, v2),
-           area_tri_signed_v2(v1, v2, v3),
-           area_tri_signed_v2(v2, v3, v4),
-           area_tri_signed_v2(v3, v4, v1),
+       const float lens[4] = {
+           len_v2(dirs[0]),
+           len_v2(dirs[1]),
+           len_v2(dirs[2]),
+           len_v2(dirs[3]),
        };
 
-       const float u = areas_co[3] / (areas_co[1] + areas_co[3]);
-       const float v = areas_co[0] / (areas_co[0] + areas_co[2]);
+       /* inline mean_value_half_tan four times here */
+       float t[4] = {
+           MEAN_VALUE_HALF_TAN_V2(area, 0, 1),
+           MEAN_VALUE_HALF_TAN_V2(area, 1, 2),
+           MEAN_VALUE_HALF_TAN_V2(area, 2, 3),
+           MEAN_VALUE_HALF_TAN_V2(area, 3, 0),
+       };
 
-       w[0] = ((1.0f - u) * (1.0f - v)) * sqrtf(areas_diag[0] / areas_diag[2]);
-       w[1] = ((       u) * (1.0f - v)) * sqrtf(areas_diag[1] / areas_diag[3]);
-       w[2] = ((       u) * (       v)) * sqrtf(areas_diag[2] / areas_diag[0]);
-       w[3] = ((1.0f - u) * (       v)) * sqrtf(areas_diag[3] / areas_diag[1]);
+#undef MEAN_VALUE_HALF_TAN_V2
 
+       w[0] = (t[3] + t[0]) / lens[0];
+       w[1] = (t[0] + t[1]) / lens[1];
+       w[2] = (t[1] + t[2]) / lens[2];
+       w[3] = (t[2] + t[3]) / lens[3];
+
        wtot = w[0] + w[1] + w[2] + w[3];
 
        if (wtot != 0.0f) {
@@ -2190,6 +2200,7 @@
 
 void interp_weights_poly_v3(float *w, float v[][3], const int n, const float 
co[3])
 {
+       /* TODO: t1 and t2 overlap each iter, we could call this only once per 
iter and reuse previous value */
        float totweight, t1, t2, len, *vmid, *vprev, *vnext;
        int i;
 
@@ -2217,6 +2228,7 @@
 
 void interp_weights_poly_v2(float *w, float v[][2], const int n, const float 
co[2])
 {

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to