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>2016-05-04 08:45:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-05-04 08:45:55 +0300
commit6f2797b50b15634f43fd47d5be352c6b21f19ec9 (patch)
treecdb1884306cfec63cc3b24b4cc8b415b9cf115e0
parent568514c875d47def3bd05c89b4c03c7a1ece35bc (diff)
Curve Draw: option to apply absolute offset
Offset used curve radius, which isn't useful drawing without any bevel radius.
-rw-r--r--release/scripts/startup/bl_ui/space_view3d_toolbar.py3
-rw-r--r--source/blender/editors/curve/editcurve_paint.c26
-rw-r--r--source/blender/makesdna/DNA_scene_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_scene.c6
4 files changed, 25 insertions, 13 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 7748618a0aa..49c7600c055 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -597,7 +597,8 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
col = layout.column()
if cps.depth_mode == 'SURFACE':
- col.prop(cps, "radius_offset")
+ col.prop(cps, "surface_offset")
+ col.prop(cps, "use_offset_absolute")
col.prop(cps, "use_stroke_endpoints")
if cps.use_stroke_endpoints:
colsub = layout.column(align=True)
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index f17349822c9..014592eb434 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -194,6 +194,8 @@ struct CurveDrawData {
/* offset projection by this value */
bool use_offset;
float offset[3]; /* worldspace */
+ float surface_offset;
+ bool use_surface_offset_absolute;
} project;
/* cursor sampling */
@@ -204,7 +206,6 @@ struct CurveDrawData {
struct {
float min, max, range;
- float offset;
} radius;
struct {
@@ -243,7 +244,10 @@ static float stroke_elem_radius(const struct CurveDrawData *cdd, const struct St
static void stroke_elem_pressure_set(const struct CurveDrawData *cdd, struct StrokeElem *selem, float pressure)
{
- if ((cdd->radius.offset != 0.0f) && !is_zero_v3(selem->normal_local)) {
+ if ((cdd->project.surface_offset != 0.0f) &&
+ !cdd->project.use_surface_offset_absolute &&
+ !is_zero_v3(selem->normal_local))
+ {
const float adjust = stroke_elem_radius_from_pressure(cdd, pressure) -
stroke_elem_radius_from_pressure(cdd, selem->pressure);
madd_v3_v3fl(selem->location_local, selem->normal_local, adjust);
@@ -269,7 +273,7 @@ static void stroke_elem_interp(
static bool stroke_elem_project(
const struct CurveDrawData *cdd,
const int mval_i[2], const float mval_fl[2],
- const float radius_offset, const float radius,
+ float surface_offset, const float radius,
float r_location_world[3], float r_normal_world[3])
{
View3D *v3d = cdd->vc.v3d;
@@ -307,10 +311,11 @@ static bool stroke_elem_project(
zero_v3(r_normal_world);
}
- if (radius_offset != 0.0f) {
+ if (surface_offset != 0.0f) {
+ const float offset = cdd->project.use_surface_offset_absolute ? 1.0f : radius;
float normal[3];
if (depth_read_normal(&cdd->vc, &cdd->mats, mval_i, normal)) {
- madd_v3_v3fl(r_location_world, normal, radius_offset * radius);
+ madd_v3_v3fl(r_location_world, normal, offset * surface_offset);
if (r_normal_world) {
copy_v3_v3(r_normal_world, normal);
}
@@ -333,14 +338,14 @@ static bool stroke_elem_project(
static bool stroke_elem_project_fallback(
const struct CurveDrawData *cdd,
const int mval_i[2], const float mval_fl[2],
- const float radius_offset, const float radius,
+ const float surface_offset, const float radius,
const float location_fallback_depth[3],
float r_location_world[3], float r_location_local[3],
float r_normal_world[3], float r_normal_local[3])
{
bool is_depth_found = stroke_elem_project(
cdd, mval_i, mval_fl,
- radius_offset, radius,
+ surface_offset, radius,
r_location_world, r_normal_world);
if (is_depth_found == false) {
ED_view3d_win_to_3d(cdd->vc.ar, location_fallback_depth, mval_fl, r_location_world);
@@ -372,7 +377,7 @@ static bool stroke_elem_project_fallback_elem(
const float radius = stroke_elem_radius(cdd, selem);
return stroke_elem_project_fallback(
cdd, mval_i, selem->mval,
- cdd->radius.offset, radius,
+ cdd->project.surface_offset, radius,
location_fallback_depth,
selem->location_world, selem->location_local,
selem->normal_world, selem->normal_local);
@@ -637,7 +642,7 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event)
/* Special case for when we only have offset applied on the first-hit,
* the remaining stroke must be offset too. */
- if (cdd->radius.offset != 0.0f) {
+ if (cdd->project.surface_offset != 0.0f) {
const float mval_fl[2] = {UNPACK2(event->mval)};
float location_no_offset[3];
@@ -688,7 +693,8 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
cdd->radius.min = cps->radius_min;
cdd->radius.max = cps->radius_max;
cdd->radius.range = cps->radius_max - cps->radius_min;
- cdd->radius.offset = cps->radius_offset;
+ cdd->project.surface_offset = cps->surface_offset;
+ cdd->project.use_surface_offset_absolute = (cps->flag & CURVE_PAINT_FLAG_DEPTH_STROKE_OFFSET_ABS) != 0;
cdd->stroke_elem_pool = BLI_mempool_create(
sizeof(struct StrokeElem), 0, 512, BLI_MEMPOOL_ALLOW_ITER);
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 1ace2b42f15..39508e17be5 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1275,7 +1275,7 @@ typedef struct CurvePaintSettings {
int error_threshold;
float radius_min, radius_max;
float radius_taper_start, radius_taper_end;
- float radius_offset;
+ float surface_offset;
float corner_angle;
} CurvePaintSettings;
@@ -1284,6 +1284,7 @@ enum {
CURVE_PAINT_FLAG_CORNERS_DETECT = (1 << 0),
CURVE_PAINT_FLAG_PRESSURE_RADIUS = (1 << 1),
CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS = (1 << 2),
+ CURVE_PAINT_FLAG_DEPTH_STROKE_OFFSET_ABS = (1 << 3),
};
/* CurvePaintSettings.depth_mode */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 91939636032..e89edaf74ad 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2639,6 +2639,10 @@ static void rna_def_curve_paint_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS);
RNA_def_property_ui_text(prop, "Only First", "Use the start of the stroke for the depth");
+ prop = RNA_def_property(srna, "use_offset_absolute", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVE_PAINT_FLAG_DEPTH_STROKE_OFFSET_ABS);
+ RNA_def_property_ui_text(prop, "Absolute Offset", "Apply a fixed offset (don't scale by the radius)");
+
prop = RNA_def_property(srna, "error_threshold", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Tolerance", "Allow deviation for a smoother, less precise line");
@@ -2669,7 +2673,7 @@ static void rna_def_curve_paint_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.0f, 1.0, 1, 2);
RNA_def_property_ui_text(prop, "Radius Max", "Taper factor for the radius of each point along the curve");
- prop = RNA_def_property(srna, "radius_offset", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "surface_offset", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, -10.0, 10.0);
RNA_def_property_ui_range(prop, -1.0f, 1.0, 1, 2);
RNA_def_property_ui_text(prop, "Offset", "Offset the stroke from the surface");