[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39335] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Fri Aug 12 16:42:07 CEST 2011
Revision: 39335
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39335
Author: nazgul
Date: 2011-08-12 14:42:07 +0000 (Fri, 12 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================
Continue improving grease pencil for manual calibration:
- Fixed bug with local undo which was caused by not dropping
re-done nodes when pushing new undo node.
- Fixed bug with conversion grease pencil to bezier curve
(last point could be dropped away on such conversion).
- Added new mode: poly line drawing.
This mode allows to draw poly-line by clicking on
it's knots. In this mode user is allowed to pan/zoom
to new position before placing next knot.
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c
branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_intern.h
branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_ops.c
branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c
branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_undo.c
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-08-12 14:41:31 UTC (rev 39334)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-08-12 14:42:07 UTC (rev 39335)
@@ -54,6 +54,9 @@
row = col.row()
row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
+
+ row = col.row()
+ row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
row = col.row()
Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c 2011-08-12 14:41:31 UTC (rev 39334)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_edit.c 2011-08-12 14:42:07 UTC (rev 39335)
@@ -527,8 +527,8 @@
copy_v3_v3(p3d_prev, p3d_cur);
copy_v3_v3(p3d_cur, p3d_next);
- if (i + 1 < tot) {
- gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect);
+ if (i + 2 < tot) {
+ gp_strokepoint_convertcoords(C, gps, pt + 2, p3d_next, subrect);
}
}
Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_intern.h 2011-08-12 14:41:31 UTC (rev 39334)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_intern.h 2011-08-12 14:42:07 UTC (rev 39335)
@@ -51,6 +51,7 @@
GP_PAINTMODE_DRAW = 0,
GP_PAINTMODE_ERASER,
GP_PAINTMODE_DRAW_STRAIGHT,
+ GP_PAINTMODE_DRAW_POLY
} eGPencil_PaintModes;
/* buttons editing --- */
Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_ops.c 2011-08-12 14:41:31 UTC (rev 39334)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_ops.c 2011-08-12 14:42:07 UTC (rev 39335)
@@ -61,6 +61,9 @@
/* draw - straight lines */
kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT);
+ /* draw - poly lines */
+ kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY);
+ RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY);
/* erase */
kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY);
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
Modified: branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c 2011-08-12 14:41:31 UTC (rev 39334)
+++ branches/soc-2011-tomato/source/blender/editors/gpencil/gpencil_paint.c 2011-08-12 14:42:07 UTC (rev 39335)
@@ -126,6 +126,7 @@
/* Runtime flags */
enum {
GP_PAINTFLAG_FIRSTRUN = (1<<0), /* operator just started */
+ GP_PAINTFLAG_STROKEADDED = (1<<1) /* stroke was already added during draw session */
};
/* ------ */
@@ -377,6 +378,43 @@
else
return GP_STROKEADD_NORMAL;
}
+ else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
+ /* get pointer to destination point */
+ pt= (tGPspoint *)(gpd->sbuffer);
+
+ /* store settings */
+ pt->x= mval[0];
+ pt->y= mval[1];
+ pt->pressure= pressure;
+
+ /* if there's stroke fir this poly line session add (or replace last) point
+ to stroke. This allows to draw lines more interactively (see new segment
+ during mouse slide, i.e.) */
+ if (p->flags & GP_PAINTFLAG_STROKEADDED) {
+ bGPDstroke *gps= p->gpf->strokes.last;
+ bGPDspoint *pts;
+
+ /* first time point is adding to temporary buffer -- need to allocate new point in stroke */
+ if (gpd->sbuffer_size == 0) {
+ gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint)*(gps->totpoints+1));
+ gps->totpoints++;
+ }
+
+ pts = &gps->points[gps->totpoints-1];
+
+ /* convert screen-coordinates to appropriate coordinates (and store them) */
+ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL);
+
+ /* copy pressure */
+ pts->pressure= pt->pressure;
+ }
+
+ /* increment counters */
+ if (gpd->sbuffer_size == 0)
+ gpd->sbuffer_size++;
+
+ return GP_STROKEADD_NORMAL;
+ }
/* return invalid state for now... */
return GP_STROKEADD_INVALID;
@@ -397,7 +435,7 @@
int i=0, cmx=gpd->sbuffer_size;
/* only smooth if smoothing is enabled, and we're not doing a straight line */
- if (!(U.gp_settings & GP_PAINT_DOSMOOTH) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT))
+ if (!(U.gp_settings & GP_PAINT_DOSMOOTH) || ELEM(p->paintmode, GP_PAINTMODE_DRAW_STRAIGHT, GP_PAINTMODE_DRAW_POLY))
return;
/* don't try if less than 2 points in buffer */
@@ -529,17 +567,28 @@
return;
}
+ /* special case for poly line -- for already added stroke during session
+ coordinates are getting added to stroke immediatelly to allow more
+ interactive behavior */
+ if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
+ if (p->flags & GP_PAINTFLAG_STROKEADDED)
+ return;
+ }
+
/* allocate memory for a new stroke */
gps= MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
- /* allocate enough memory for a continuous array for storage points */
- pt= gps->points= MEM_callocN(sizeof(bGPDspoint)*totelem, "gp_stroke_points");
-
/* copy appropriate settings for stroke */
gps->totpoints= totelem;
gps->thickness= p->gpl->thickness;
gps->flag= gpd->sbuffer_sflag;
+ /* allocate enough memory for a continuous array for storage points */
+ gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points");
+
+ /* set pointer to first non-initialized point */
+ pt= gps->points + (gps->totpoints - totelem);
+
/* copy points from the buffer to the stroke */
if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
/* straight lines only -> only endpoints */
@@ -567,6 +616,16 @@
pt->pressure= ptc->pressure;
}
}
+ else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
+ /* first point */
+ ptc= gpd->sbuffer;
+
+ /* convert screen-coordinates to appropriate coordinates (and store them) */
+ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
+
+ /* copy pressure */
+ pt->pressure= ptc->pressure;
+ }
else {
float *depth_arr= NULL;
@@ -645,7 +704,9 @@
MEM_freeN(depth_arr);
}
- /* add stroke to frame */
+ p->flags |= GP_PAINTFLAG_STROKEADDED;
+
+ /* add stroke to frame */
BLI_addtail(&p->gpf->strokes, gps);
}
@@ -893,8 +954,10 @@
bGPdata *gpd= p->gpd;
/* clear memory of buffer (or allocate it if starting a new session) */
- if (gpd->sbuffer)
+ if (gpd->sbuffer) {
+ //printf("\t\tGP - reset sbuffer\n");
memset(gpd->sbuffer, 0, sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX);
+ }
else {
//printf("\t\tGP - allocate sbuffer\n");
gpd->sbuffer= MEM_callocN(sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer");
@@ -907,24 +970,21 @@
gpd->sbuffer_sflag= 0;
}
-/* init new painting session */
-static tGPsdata *gp_session_initpaint (bContext *C)
+/* (re)init new painting data */
+static int gp_session_initdata (bContext *C, tGPsdata *p)
{
- tGPsdata *p = NULL;
bGPdata **gpd_ptr = NULL;
ScrArea *curarea= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
+ p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: No active view for painting \n");
- return NULL;
+ return 0;
}
- /* create new context data */
- p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data");
-
/* pass on current scene and window */
p->scene= CTX_data_scene(C);
p->win= CTX_wm_window(C);
@@ -946,7 +1006,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable \n");
- return p;
+ return 0;
}
#if 0 // XXX will this sort of antiquated stuff be restored?
@@ -955,7 +1015,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: In active view, Grease Pencil not shown \n");
- return p;
+ return 0;
}
#endif
}
@@ -976,7 +1036,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: In active view, Grease Pencil not shown \n");
- return;
+ return 0;
}
#endif
}
@@ -996,13 +1056,13 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil \n");
- return;
+ return 0;
}
if ((sseq->flag & SEQ_DRAW_GPENCIL)==0) {
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: In active view, Grease Pencil not shown \n");
- return;
+ return 0;
}
}
break;
@@ -1023,7 +1083,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: In active view, Grease Pencil not shown \n");
- return p;
+ return 0;
}
#endif
}
@@ -1044,7 +1104,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: In active view, Grease Pencil not shown \n");
- return p;
+ return 0;
}
#endif
}
@@ -1056,7 +1116,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: Active view not appropriate for Grease Pencil drawing \n");
- return p;
+ return 0;
}
break;
}
@@ -1067,7 +1127,7 @@
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
printf("Error: Current context doesn't allow for any Grease Pencil data \n");
- return p;
+ return 0;
}
else {
/* if no existing GPencil block exists, add one */
@@ -1092,7 +1152,20 @@
p->im2d_settings.sizex= 1;
p->im2d_settings.sizey= 1;
#endif
+
+ return 1;
+}
+
+/* init new painting session */
+static tGPsdata *gp_session_initpaint (bContext *C)
+{
+ tGPsdata *p = NULL;
+ /* create new context data */
+ p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data");
+
+ gp_session_initdata(C, p);
+
/* return context data for running paint operator */
return p;
}
@@ -1663,17 +1736,14 @@
p->status= GP_STATUS_ERROR;
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list