Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-01-01 20:48:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-01 20:48:48 +0300
commitd0ec3f428c5bafd46d7bd80dedff15c6c7f9f8e6 (patch)
tree4a012220e713924746cc1c5016b1d718bbd1549d /source/blender/editors/gpencil
parent7cc72d5830c8440a2b05ef15f1eeba42c615fdc3 (diff)
- grease pencil option to only use the endpoint depths. this makes drawing shapes in 3D easier since it wont stick to every depth the line passes through.
- use a 8x8 area when finding stroke depths since thin lines can get ignored if the point is not close enough to them.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c26
2 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index 4f12f072e72..e93788bc495 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -266,6 +266,10 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
row= uiLayoutRow(col, 1);
uiItemEnumR_string(row, NULL, 0, &gpd_ptr, "draw_mode", "SURFACE");
uiItemEnumR_string(row, NULL, 0, &gpd_ptr, "draw_mode", "STROKE");
+
+ row= uiLayoutRow(col, 0);
+ uiLayoutSetActive(row, (gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0);
+ uiItemR(row, NULL, 0, &gpd_ptr, "use_stroke_endpoints", 0);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index d48ff411f10..5efc9d916c1 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -218,7 +218,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[], flo
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) {
- if(gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out, depth))) {
+ if(gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out, 0, depth))) {
/* projecting onto 3D-Geometry
* - nothing more needs to be done here, since view_autodist_simple() has already done it
*/
@@ -458,6 +458,8 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
bGPDspoint *pt;
tGPspoint *ptc;
int i, totelem;
+ /* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
+ int depth_margin = (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 4 : 0;
/* get total number of points to allocate space for
* - drawing straight-lines only requires the endpoints
@@ -525,7 +527,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) {
mval[0]= ptc->x; mval[1]= ptc->y;
- if(view_autodist_depth(p->ar, mval, depth_arr+i) == 0)
+ if(view_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0)
interp_depth= TRUE;
else
found_depth= TRUE;
@@ -537,6 +539,26 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
depth_arr[i] = 0.9999f;
}
else if(interp_depth) {
+ if(p->gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS) {
+ /* remove all info between the valid endpoints */
+ int first_valid = 0;
+ int last_valid = 0;
+
+ for (i=0; i < gpd->sbuffer_size; i++)
+ if(depth_arr[i] != FLT_MAX)
+ break;
+ first_valid= i;
+
+ for (i=gpd->sbuffer_size-1; i >= 0; i--)
+ if(depth_arr[i] != FLT_MAX)
+ break;
+ last_valid= i;
+
+ /* invalidate non-endpoints, so only blend between first and last */
+ for (i=first_valid+1; i < last_valid; i++)
+ depth_arr[i]= FLT_MAX;
+ }
+
interp_sparse_array(depth_arr, gpd->sbuffer_size, FLT_MAX);
}
}