[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34053] trunk/blender/source/blender: Grease Pencil: Redo for sketching sessions now works
Joshua Leung
aligorith at gmail.com
Tue Jan 4 06:57:12 CET 2011
Revision: 34053
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34053
Author: aligorith
Date: 2011-01-04 06:57:05 +0100 (Tue, 04 Jan 2011)
Log Message:
-----------
Grease Pencil: Redo for sketching sessions now works
Modified Paths:
--------------
trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
trunk/blender/source/blender/makesrna/intern/rna_brush.c
Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c 2011-01-04 04:56:27 UTC (rev 34052)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c 2011-01-04 05:57:05 UTC (rev 34053)
@@ -1376,6 +1376,15 @@
else
p->pressure= 1.0f;
+ /* fill in stroke data (not actually used directly by gpencil_draw_apply) */
+ RNA_collection_add(op->ptr, "stroke", &itemptr);
+
+ mousef[0]= p->mval[0];
+ mousef[1]= p->mval[1];
+ RNA_float_set_array(&itemptr, "mouse", mousef);
+ RNA_float_set(&itemptr, "pressure", p->pressure);
+ RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN));
+
/* special exception for start of strokes (i.e. maybe for just a dot) */
if (p->flags & GP_PAINTFLAG_FIRSTRUN) {
p->flags &= ~GP_PAINTFLAG_FIRSTRUN;
@@ -1391,15 +1400,6 @@
return;
}
- /* fill in stroke data (not actually used directly by gpencil_draw_apply) */
- // FIXME: need a way to denote new strokes (for drawing session redo)
- RNA_collection_add(op->ptr, "stroke", &itemptr);
-
- mousef[0]= p->mval[0];
- mousef[1]= p->mval[1];
- RNA_float_set_array(&itemptr, "mouse", mousef);
- RNA_float_set(&itemptr, "pressure", p->pressure);
-
/* apply the current latest drawing point */
gpencil_draw_apply(op, p);
@@ -1430,7 +1430,6 @@
/* loop over the stroke RNA elements recorded (i.e. progress of mouse movement),
* setting the relevant values in context at each step, then applying
*/
- // FIXME: this doesn't work for redoing stroke sessions
RNA_BEGIN(op->ptr, itemptr, "stroke")
{
float mousef[2];
@@ -1443,6 +1442,17 @@
p->mval[1] = (short)mousef[1];
p->pressure= RNA_float_get(&itemptr, "pressure");
+ if (RNA_boolean_get(&itemptr, "is_start")) {
+ /* if first-run flag isn't set already (i.e. not true first stroke),
+ * then we must terminate the previous one first before continuing
+ */
+ if ((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) {
+ // TODO: both of these ops can set error-status, but we probably don't need to worry
+ gp_paint_strokeend(p);
+ gp_paint_initstroke(p, p->paintmode);
+ }
+ }
+
/* if first run, set previous data too */
if (p->flags & GP_PAINTFLAG_FIRSTRUN) {
p->flags &= ~GP_PAINTFLAG_FIRSTRUN;
Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_brush.c 2011-01-04 04:56:27 UTC (rev 34052)
+++ trunk/blender/source/blender/makesrna/intern/rna_brush.c 2011-01-04 05:57:05 UTC (rev 34053)
@@ -792,6 +792,11 @@
prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Time", "");
+
+ /* used for Grease Pencil sketching sessions */
+ prop= RNA_def_property(srna, "is_start", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_IDPROPERTY);
+ RNA_def_property_ui_text(prop, "Is Stroke Start", "");
/* XXX: Tool (this will be for pressing a modifier key for a different brush,
e.g. switching to a Smooth brush in the middle of the stroke */
More information about the Bf-blender-cvs
mailing list