[Bf-blender-cvs] [8ac662c] master: New freehand curve drawing tool
Campbell Barton
noreply at git.blender.org
Fri Apr 15 12:36:46 CEST 2016
Commit: 8ac662c77aa59c9eea5fc85c4a40546bcb1b4557
Author: Campbell Barton
Date: Fri Apr 15 18:10:05 2016 +1000
Branches: master
https://developer.blender.org/rB8ac662c77aa59c9eea5fc85c4a40546bcb1b4557
New freehand curve drawing tool
- Access with Shift-LMB or from the 'Create' toolbar tab.
- Uses curve fitting for bezier curves, with error and corner angle options.
- Optional tablet pressure to curve radius mapping.
- Depth can use the cursor or optionally draw onto the surface,
for the entire stroke or using the stroke start.
- Stroke plane can optionally be perpendicular to, or aligned to the surface normal.
- Optional radius tapering and for start/end points.
- Supports operator redo and calling from Python.
===================================================================
M extern/curve_fit_nd/curve_fit_nd.h
M extern/curve_fit_nd/intern/curve_fit_cubic.c
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/intern/scene.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/editors/curve/CMakeLists.txt
M source/blender/editors/curve/curve_intern.h
M source/blender/editors/curve/curve_ops.c
A source/blender/editors/curve/editcurve_paint.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/extern/curve_fit_nd/curve_fit_nd.h b/extern/curve_fit_nd/curve_fit_nd.h
index 67b0ed7..d20921c 100644
--- a/extern/curve_fit_nd/curve_fit_nd.h
+++ b/extern/curve_fit_nd/curve_fit_nd.h
@@ -55,7 +55,7 @@
*
* \returns zero on success, nonzero is reserved for error values.
*/
-int curve_fit_cubic_from_points_db(
+int curve_fit_cubic_to_points_db(
const double *points,
const unsigned int points_len,
const unsigned int dims,
@@ -67,7 +67,7 @@ int curve_fit_cubic_from_points_db(
unsigned int **r_cubic_orig_index,
unsigned int **r_corner_index_array, unsigned int *r_corner_index_len);
-int curve_fit_cubic_from_points_fl(
+int curve_fit_cubic_to_points_fl(
const float *points,
const unsigned int points_len,
const unsigned int dims,
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic.c b/extern/curve_fit_nd/intern/curve_fit_cubic.c
index d623b51..810cf92 100644
--- a/extern/curve_fit_nd/intern/curve_fit_cubic.c
+++ b/extern/curve_fit_nd/intern/curve_fit_cubic.c
@@ -846,7 +846,7 @@ static void fit_cubic_to_points(
* Take an array of 3d points.
* return the cubic splines
*/
-int curve_fit_cubic_from_points_db(
+int curve_fit_cubic_to_points_db(
const double *points,
const uint points_len,
const uint dims,
@@ -984,9 +984,9 @@ int curve_fit_cubic_from_points_db(
}
/**
- * A version of #curve_fit_cubic_from_points_db to handle floats
+ * A version of #curve_fit_cubic_to_points_db to handle floats
*/
-int curve_fit_cubic_from_points_fl(
+int curve_fit_cubic_to_points_fl(
const float *points,
const uint points_len,
const uint dims,
@@ -1009,7 +1009,7 @@ int curve_fit_cubic_from_points_fl(
float *cubic_array_fl = NULL;
uint cubic_array_len = 0;
- int result = curve_fit_cubic_from_points_db(
+ int result = curve_fit_cubic_to_points_db(
points_db, points_len, dims, error_threshold, corners, corners_len,
&cubic_array_db, &cubic_array_len,
r_cubic_orig_index,
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index d8286c6..01b46eb 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -136,6 +136,7 @@ class VIEW3D_PT_tools_add_object(View3DPanel, Panel):
@staticmethod
def draw_add_curve(layout, label=False):
+
if label:
layout.label(text="Bezier:")
layout.operator("curve.primitive_bezier_curve_add", text="Bezier", icon='CURVE_BEZCURVE')
@@ -149,6 +150,10 @@ class VIEW3D_PT_tools_add_object(View3DPanel, Panel):
layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
+ layout.separator()
+
+ layout.operator("curve.draw", icon='LINE_DATA')
+
@staticmethod
def draw_add_surface(layout):
layout.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon='SURFACE_NCURVE')
@@ -546,8 +551,61 @@ class VIEW3D_PT_tools_add_curve_edit(View3DPanel, Panel):
VIEW3D_PT_tools_add_object.draw_add_curve(col, label=True)
-# ********** default tools for editmode_surface ****************
+class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
+ bl_category = "Options"
+ bl_context = "curve_edit"
+ bl_label = "Curve Stroke"
+
+ def draw(self, context):
+ layout = self.layout
+
+ tool_settings = context.tool_settings
+ cps = tool_settings.curve_paint_settings
+
+ col = layout.column()
+
+ col.prop(cps, "curve_type")
+
+ if cps.curve_type == 'BEZIER':
+ col.label("Bezier Options:")
+ col.prop(cps, "error_threshold")
+ col.prop(cps, "use_corners_detect")
+
+ col = layout.column()
+ col.active = cps.use_corners_detect
+ col.prop(cps, "corner_angle")
+
+ col.label("Pressure Radius:")
+ row = layout.row(align=True)
+ rowsub = row.row(align=True)
+ rowsub.prop(cps, "radius_min", text="Min")
+ rowsub.prop(cps, "radius_max", text="Max")
+
+ row.prop(cps, "use_pressure_radius", text="", icon_only=True)
+
+ col = layout.column()
+ col.label("Taper Radius:")
+ row = layout.row(align=True)
+ row.prop(cps, "radius_taper_start", text="Start")
+ row.prop(cps, "radius_taper_end", text="End")
+
+ col = layout.column()
+ col.label("Projection Depth:")
+ row = layout.row(align=True)
+ row.prop(cps, "depth_mode", expand=True)
+
+ col = layout.column()
+ if cps.depth_mode == 'SURFACE':
+ col.prop(cps, "use_stroke_endpoints")
+ if cps.use_stroke_endpoints:
+ colsub = layout.column(align=True)
+ colsub.prop(cps, "surface_plane", expand=True)
+ else:
+ col.prop(cps, "radius_offset")
+
+
+# ********** default tools for editmode_surface ****************
class VIEW3D_PT_tools_transform_surface(View3DPanel, Panel):
bl_category = "Tools"
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 6b297a1..c0b7911 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -616,6 +616,12 @@ void BKE_scene_init(Scene *sce)
sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
+ sce->toolsettings->curve_paint_settings.curve_type = CU_BEZIER;
+ sce->toolsettings->curve_paint_settings.flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
+ sce->toolsettings->curve_paint_settings.error_threshold = 8;
+ sce->toolsettings->curve_paint_settings.radius_max = 1.0f;
+ sce->toolsettings->curve_paint_settings.corner_angle = DEG2RADF(70.0f);
+
sce->toolsettings->statvis.overhang_axis = OB_NEGZ;
sce->toolsettings->statvis.overhang_min = 0;
sce->toolsettings->statvis.overhang_max = DEG2RADF(45.0f);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index b9191d5..18740d4 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1072,5 +1072,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+ CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
+ if (cps->error_threshold == 0) {
+ cps->curve_type = CU_BEZIER;
+ cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
+ cps->error_threshold = 8;
+ cps->radius_max = 1.0f;
+ cps->corner_angle = DEG2RADF(70.0f);
+ }
+ }
+
}
}
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index 83346e9..ebdf6bb 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -23,20 +23,24 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
+ ../../../../intern/glew-mx
+ ../../../../extern/curve_fit_nd
)
set(INC_SYS
-
+ ${GLEW_INCLUDE_PATH}
)
set(SRC
curve_ops.c
editcurve.c
editcurve_add.c
+ editcurve_paint.c
editcurve_select.c
editfont.c
@@ -47,4 +51,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
+add_definitions(${GL_DEFINITIONS})
+
blender_add_lib(bf_editor_curve "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 1af0b49..d63616e 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -166,4 +166,7 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(struct wmOperatorType *ot);
void SURFACE_OT_primitive_nurbs_surface_sphere_add(struct wmOperatorType *ot);
void SURFACE_OT_primitive_nurbs_surface_torus_add(struct wmOperatorType *ot);
+/* editcurve_paint.c */
+void CURVE_OT_draw(struct wmOperatorType *ot);
+
#endif /* __CURVE_INTERN_H__ */
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 967187e..d1994c8 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -135,6 +135,7 @@ void ED_operatortypes_curve(void)
WM_operatortype_append(CURVE_OT_make_segment);
WM_operatortype_append(CURVE_OT_spin);
WM_operatortype_append(CURVE_OT_vertex_add);
+ WM_operatortype_append(CURVE_OT_draw);
WM_operatortype_append(CURVE_OT_extrude);
WM_operatortype_append(CURVE_OT_cyclic_toggle);
@@ -234,6 +235,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "CURVE_OT_draw", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "wait_for_input", false);
+
kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
new file mode 100644
index 0000000..4af123c
--- /dev/null
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -0,0 +1,1150 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. S
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list