[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49030] branches/soc-2011-tomato: svn merge ^/trunk/blender -r49024:49029
Campbell Barton
ideasman42 at gmail.com
Wed Jul 18 14:56:36 CEST 2012
Revision: 49030
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49030
Author: campbellbarton
Date: 2012-07-18 12:56:36 +0000 (Wed, 18 Jul 2012)
Log Message:
-----------
svn merge ^/trunk/blender -r49024:49029
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49024
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_rasterize.c
branches/soc-2011-tomato/source/blender/editors/transform/transform.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-49024
+ /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-49029
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-18 12:54:13 UTC (rev 49029)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask_rasterize.c 2012-07-18 12:56:36 UTC (rev 49030)
@@ -47,8 +47,10 @@
#ifndef USE_RASKTER
-#define SPLINE_RESOL_CAP 32
-#define SPLINE_RESOL 32
+#define SPLINE_RESOL_CAP_PER_PIXEL 2
+#define SPLINE_RESOL_CAP_MIN 8
+#define SPLINE_RESOL_CAP_MAX 64
+
#define BUCKET_PIXELS_PER_CELL 8
#define SF_EDGE_IS_BOUNDARY 0xff
@@ -68,28 +70,30 @@
BLI_assert(_t[3] < vert_max || _t[3] == TRI_VERT); \
} (void)0
-void rotate_point(const float cent[2], const float angle, float p[2], const float asp[2])
+static void rotate_point_v2(float r_p[2], const float p[2], const float cent[2], const float angle, const float asp[2])
{
const float s = sinf(angle);
const float c = cosf(angle);
float p_new[2];
/* translate point back to origin */
- p[0] -= cent[0];
- p[1] -= cent[1];
+ r_p[0] = (p[0] - cent[0]) / asp[0];
+ r_p[1] = (p[1] - cent[1]) / asp[1];
- p[0] /= asp[0];
- p[1] /= asp[1];
-
/* rotate point */
- p_new[0] = ((p[0] * c) - (p[1] * s)) * asp[0];
- p_new[1] = ((p[0] * s) + (p[1] * c)) * asp[1];
+ p_new[0] = ((r_p[0] * c) - (r_p[1] * s)) * asp[0];
+ p_new[1] = ((r_p[0] * s) + (r_p[1] * c)) * asp[1];
/* translate point back */
- p[0] = p_new[0] + cent[0];
- p[1] = p_new[1] + cent[1];
+ r_p[0] = p_new[0] + cent[0];
+ r_p[1] = p_new[1] + cent[1];
}
+BLI_INLINE unsigned int clampis_uint(const unsigned int v, const unsigned int min, const unsigned int max)
+{
+ return v < min ? min : (v > max ? max : v);
+}
+
/* --------------------------------------------------------------------- */
/* local structs for mask rasterizeing */
/* --------------------------------------------------------------------- */
@@ -131,8 +135,14 @@
} MaskRasterLayer;
typedef struct MaskRasterSplineInfo {
+ /* body of the spline */
unsigned int vertex_offset;
unsigned int vertex_total;
+
+ /* capping for non-filled, non cyclic splines */
+ unsigned int vertex_total_cap_head;
+ unsigned int vertex_total_cap_tail;
+
unsigned int is_cyclic;
} MaskRasterSplineInfo;
@@ -503,6 +513,8 @@
{
const rctf default_bounds = {0.0f, 1.0f, 0.0f, 1.0f};
const float pixel_size = 1.0f / MIN2(width, height);
+ const float asp_xy[2] = {(do_aspect_correct && width > height) ? (float)height / (float)width : 1.0f,
+ (do_aspect_correct && width < height) ? (float)width / (float)height : 1.0f};
const float zvec[3] = {0.0f, 0.0f, 1.0f};
MaskLayer *masklay;
@@ -684,10 +696,7 @@
open_spline_ranges[open_spline_index].vertex_offset = sf_vert_tot;
open_spline_ranges[open_spline_index].vertex_total = tot_diff_point;
- open_spline_ranges[open_spline_index].is_cyclic = is_cyclic;
- open_spline_index++;
-
/* TODO, an alternate functions so we can avoid double vector copy! */
for (j = 0; j < tot_diff_point; j++) {
@@ -722,52 +731,68 @@
tot_feather_quads -= 2;
}
- /*cap ends */
+ /* cap ends */
+
+ /* dummy init value */
+ open_spline_ranges[open_spline_index].vertex_total_cap_head = 0;
+ open_spline_ranges[open_spline_index].vertex_total_cap_tail = 0;
+
if (!is_cyclic) {
+ float *fp_cent;
+ float *fp_turn;
+
unsigned int k;
- float asp[2] = {1.0f, 1.0f};
+ fp_cent = diff_points[0];
+ fp_turn = diff_feather_points[0];
- if (do_aspect_correct) {
- if (width != height) {
- if (width < height) {
- asp[1] = (float)width / (float)height;
- }
- else {
- asp[0] = (float)height / (float)width;
- }
+#define CALC_CAP_RESOL \
+ clampis_uint((len_v2v2(fp_cent, fp_turn) / (pixel_size * SPLINE_RESOL_CAP_PER_PIXEL)), \
+ SPLINE_RESOL_CAP_MIN, \
+ SPLINE_RESOL_CAP_MAX)
+
+ {
+ const unsigned int vertex_total_cap = CALC_CAP_RESOL;
+
+ for (k = 1; k < vertex_total_cap; k++) {
+ const float angle = (float)k * (1.0f / vertex_total_cap) * (float)M_PI;
+ rotate_point_v2(co_feather, fp_turn, fp_cent, angle, asp_xy);
+
+ sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
+ sf_vert->tmp.u = sf_vert_tot;
+ sf_vert->keyindex = SF_KEYINDEX_TEMP_ID;
+ sf_vert_tot++;
}
+ tot_feather_quads += vertex_total_cap;
+
+ open_spline_ranges[open_spline_index].vertex_total_cap_head = vertex_total_cap;
}
- for (k = 1; k < SPLINE_RESOL_CAP; k++) {
- const float angle = (float)k * (1.0f / SPLINE_RESOL_CAP) * (float)M_PI;
- copy_v2_v2(co_feather, diff_feather_points[0]);
- rotate_point(diff_points[0], angle, co_feather, asp);
+ fp_cent = diff_points[tot_diff_point - 1];
+ fp_turn = diff_feather_points[tot_diff_point - 1];
- sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
- sf_vert->tmp.u = sf_vert_tot;
- sf_vert->keyindex = SF_KEYINDEX_TEMP_ID;
- sf_vert_tot++;
- }
+ {
+ const unsigned int vertex_total_cap = CALC_CAP_RESOL;
- tot_feather_quads += SPLINE_RESOL_CAP;
+ for (k = 1; k < vertex_total_cap; k++) {
+ const float angle = (float)k * (1.0f / vertex_total_cap) * (float)M_PI;
+ rotate_point_v2(co_feather, fp_turn, fp_cent, -angle, asp_xy);
- for (k = 1; k < SPLINE_RESOL_CAP; k++) {
- const float angle = (float)k * (1.0f / SPLINE_RESOL_CAP) * (float)M_PI;
- copy_v2_v2(co_feather, diff_feather_points[tot_diff_point - 1]);
- rotate_point(diff_points[tot_diff_point - 1], -angle, co_feather, asp);
+ sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
+ sf_vert->tmp.u = sf_vert_tot;
+ sf_vert->keyindex = SF_KEYINDEX_TEMP_ID;
+ sf_vert_tot++;
+ }
+ tot_feather_quads += vertex_total_cap;
- sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
- sf_vert->tmp.u = sf_vert_tot;
- sf_vert->keyindex = SF_KEYINDEX_TEMP_ID;
- sf_vert_tot++;
+ open_spline_ranges[open_spline_index].vertex_total_cap_tail = vertex_total_cap;
}
+ }
- tot_feather_quads += SPLINE_RESOL_CAP;
+ open_spline_ranges[open_spline_index].is_cyclic = is_cyclic;
+ open_spline_index++;
-
- }
-
+#undef CALC_CAP_RESOL
/* end capping */
}
@@ -852,16 +877,18 @@
/* feather only splines */
while (open_spline_index > 0) {
- unsigned int start_vidx = open_spline_ranges[--open_spline_index].vertex_offset;
- unsigned int tot_diff_point_sub1 = open_spline_ranges[ open_spline_index].vertex_total - 1;
+ const unsigned int vertex_offset = open_spline_ranges[--open_spline_index].vertex_offset;
+ unsigned int vertex_total = open_spline_ranges[ open_spline_index].vertex_total;
+ unsigned int vertex_total_cap_head = open_spline_ranges[ open_spline_index].vertex_total_cap_head;
+ unsigned int vertex_total_cap_tail = open_spline_ranges[ open_spline_index].vertex_total_cap_tail;
unsigned int k, j;
- j = start_vidx;
+ j = vertex_offset;
/* subtract one since we reference next vertex triple */
- for (k = 0; k < tot_diff_point_sub1; k++, j += 3) {
+ for (k = 0; k < vertex_total - 1; k++, j += 3) {
- BLI_assert(j == start_vidx + (k * 3));
+ BLI_assert(j == vertex_offset + (k * 3));
*(face++) = j + 3; /* next span */ /* z 1 */
*(face++) = j + 0; /* z 1 */
@@ -879,28 +906,28 @@
}
if (open_spline_ranges[open_spline_index].is_cyclic) {
- *(face++) = start_vidx + 0; /* next span */ /* z 1 */
- *(face++) = j + 0; /* z 1 */
- *(face++) = j + 1; /* z 0 */
- *(face++) = start_vidx + 1; /* next span */ /* z 0 */
+ *(face++) = vertex_offset + 0; /* next span */ /* z 1 */
+ *(face++) = j + 0; /* z 1 */
+ *(face++) = j + 1; /* z 0 */
+ *(face++) = vertex_offset + 1; /* next span */ /* z 0 */
face_index++;
FACE_ASSERT(face - 4, sf_vert_tot);
- *(face++) = j + 0; /* z 1 */
- *(face++) = start_vidx + 0; /* next span */ /* z 1 */
- *(face++) = start_vidx + 2; /* next span */ /* z 0 */
- *(face++) = j + 2; /* z 0 */
+ *(face++) = j + 0; /* z 1 */
+ *(face++) = vertex_offset + 0; /* next span */ /* z 1 */
+ *(face++) = vertex_offset + 2; /* next span */ /* z 0 */
+ *(face++) = j + 2; /* z 0 */
face_index++;
FACE_ASSERT(face - 4, sf_vert_tot);
}
else {
- unsigned int midvidx = start_vidx;
+ unsigned int midvidx = vertex_offset;
/***************
* cap end 'a' */
- j = midvidx + (open_spline_ranges[open_spline_index].vertex_total * 3);
+ j = midvidx + (vertex_total * 3);
- for (k = 0; k < SPLINE_RESOL_CAP - 2; k++, j++) {
+ for (k = 0; k < vertex_total_cap_head - 2; k++, j++) {
*(face++) = midvidx + 0; /* z 1 */
*(face++) = midvidx + 0; /* z 1 */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list