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>2009-11-30 04:13:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-30 04:13:46 +0300
commitdc1af66d8a971ce5855ba5ceae1052e001acfae6 (patch)
tree2397dacb44bc1b2bfc08b14dae4f5299cd973a3f /source/blender
parent3d1f2974899308b5a58d28493da6f9eab966564c (diff)
- grease pencil drawing on the surface of objects (only when enable face snap & projection, a bit hidden I know)
- retopo operator to convert grease pencil drawn topology into geometry, not in the convert menu yet since its not quite finished, use the operator search menu for retopo. will test this week and see what needs fixing.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c62
-rw-r--r--source/blender/editors/include/ED_view3d.h5
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c46
4 files changed, 96 insertions, 19 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index c2b9a1a4bb9..2f41d90b37c 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -531,7 +531,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
}
/* restore old active object */
- BASACT= base;
+ // BASACT= base; // removing since this is expected new objects are active.
}
/* --- */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 4229c66353c..dce49cc4845 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -151,6 +151,21 @@ static int gpencil_draw_poll (bContext *C)
return (gpencil_data_get_pointers(C, NULL) != NULL);
}
+static int gpencil_project_check(tGPsdata *p)
+{
+ bGPdata *gpd= p->gpd;
+
+ /* in 3d-space - pt->x/y/z are 3 side-by-side floats */
+ if( (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) &&
+ (p->scene->toolsettings->snap_mode==SCE_SNAP_MODE_FACE) &&
+ (p->scene->toolsettings->snap_flag & SCE_SNAP_PROJECT) )
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
/* ******************************************* */
/* Calculations/Conversions */
@@ -211,24 +226,29 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[])
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) {
- const short mx=mval[0], my=mval[1];
- float rvec[3], dvec[3];
-
- /* Current method just converts each point in screen-coordinates to
- * 3D-coordinates using the 3D-cursor as reference. In general, this
- * works OK, but it could of course be improved.
- *
- * TODO:
- * - investigate using nearest point(s) on a previous stroke as
- * reference point instead or as offset, for easier stroke matching
- * - investigate projection onto geometry (ala retopo)
- */
- gp_get_3d_reference(p, rvec);
-
- /* method taken from editview.c - mouse_cursor() */
- project_short_noclip(p->ar, rvec, mval);
- window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my);
- sub_v3_v3v3(out, rvec, dvec);
+ if(gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out))) {
+ /* pass */
+ }
+ else {
+ const short mx=mval[0], my=mval[1];
+ float rvec[3], dvec[3];
+
+ /* Current method just converts each point in screen-coordinates to
+ * 3D-coordinates using the 3D-cursor as reference. In general, this
+ * works OK, but it could of course be improved.
+ *
+ * TODO:
+ * - investigate using nearest point(s) on a previous stroke as
+ * reference point instead or as offset, for easier stroke matching
+ */
+
+ gp_get_3d_reference(p, rvec);
+
+ /* method taken from editview.c - mouse_cursor() */
+ project_short_noclip(p->ar, rvec, mval);
+ window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my);
+ sub_v3_v3v3(out, rvec, dvec);
+ }
}
/* 2d - on 'canvas' (assume that p->v2d is set) */
@@ -1114,6 +1134,12 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op)
}
/* cleanup */
+ if(gpencil_project_check(p)) {
+ View3D *v3d= p->sa->spacedata.first;
+ view3d_operator_needs_opengl(C);
+ view_autodist_init(p->scene, p->ar, v3d);
+ }
+
gp_paint_cleanup(p);
gp_session_cleanup(p);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index ecd2d69b7fb..38a1d5ef9eb 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -117,8 +117,13 @@ unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, short mval[2], i
void *handle, unsigned int (*indextest)(void *handle, unsigned int index));
unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
+/* draws and does a 4x4 sample */
int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, short *mval, float mouse_worldloc[3]);
+/* only draw so view_autodist_simple can be called many times after */
+int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d);
+int view_autodist_simple(struct ARegion *ar, short *mval, float mouse_worldloc[3]);
+
/* select */
#define MAXPICKBUF 10000
short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 2444c461bd0..9737e0cb167 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2205,7 +2205,53 @@ int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, short *mval, float mou
return 1;
}
+int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d) //, float *autodist )
+{
+ RegionView3D *rv3d= ar->regiondata;
+
+ /* Get Z Depths, needed for perspective, nice for ortho */
+ draw_depth(scene, ar, v3d, NULL);
+
+ /* force updating */
+ if (rv3d->depths) {
+ rv3d->depths->damaged = 1;
+ }
+
+ view3d_update_depths(ar, v3d);
+ return 1;
+}
+
+// no 4x4 sampling, run view_autodist_init first
+int view_autodist_simple(ARegion *ar, short *mval, float mouse_worldloc[3] ) //, float *autodist )
+{
+ RegionView3D *rv3d= ar->regiondata;
+ bglMats mats; /* ZBuffer depth vars, could cache? */
+ float depth;
+ double cent[2], p[3];
+
+ if (mval[0] < 0) return 0;
+ if (mval[1] < 0) return 0;
+ if (mval[0] >= rv3d->depths->w) return 0;
+ if (mval[1] >= rv3d->depths->h) return 0;
+
+ /* Get Z Depths, needed for perspective, nice for ortho */
+ bgl_get_mats(&mats);
+ depth= rv3d->depths->depths[mval[1]*rv3d->depths->w+mval[0]];
+ if (depth==MAXFLOAT)
+ return 0;
+
+ cent[0] = (double)mval[0];
+ cent[1] = (double)mval[1];
+
+ if (!gluUnProject(cent[0], cent[1], depth, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
+ return 0;
+
+ mouse_worldloc[0] = (float)p[0];
+ mouse_worldloc[1] = (float)p[1];
+ mouse_worldloc[2] = (float)p[2];
+ return 1;
+}
/* ********************* NDOF ************************ */
/* note: this code is confusing and unclear... (ton) */