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>2011-02-02 06:32:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-02 06:32:58 +0300
commit691f2abad1f2d22fd6dec7430d6266366ecc1b21 (patch)
tree58d821c8aad2d4463e9d2d8a2124b65f89522bb6 /source/blender/editors/space_view3d/view3d_edit.c
parentb04bccd44e45dcb759de55c08d2913400853ee82 (diff)
fix [#25684] Grease pencil strokes with "Surface" option attach erratically to curves.
added new functions - view_autodist_depth_segment() - plot_line_v2v2i(), which takes a callback and plots x/y points.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index bbb52826de6..6df0793f2fe 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2622,7 +2622,7 @@ void VIEW3D_OT_enable_manipulator(wmOperatorType *ot)
/* ************************* below the line! *********************** */
-static float view_autodist_depth_margin(ARegion *ar, short *mval, int margin)
+static float view_autodist_depth_margin(ARegion *ar, short mval[2], int margin)
{
ViewDepths depth_temp= {0};
rcti rect;
@@ -2721,12 +2721,51 @@ int view_autodist_simple(ARegion *ar, short *mval, float mouse_worldloc[3], int
return 1;
}
-int view_autodist_depth(struct ARegion *ar, short *mval, int margin, float *depth)
+int view_autodist_depth(struct ARegion *ar, short mval[2], int margin, float *depth)
{
*depth= view_autodist_depth_margin(ar, mval, margin);
return (*depth==FLT_MAX) ? 0:1;
+}
+
+static int depth_segment_cb(int x, int y, void *userData)
+{
+ struct { struct ARegion *ar; int margin; float depth; } *data = userData;
+ short mval[2];
+ float depth;
+
+ mval[0]= (short)x;
+ mval[1]= (short)y;
+
+ depth= view_autodist_depth_margin(data->ar, mval, data->margin);
+
+ if(depth != FLT_MAX) {
+ data->depth= depth;
return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+int view_autodist_depth_segment(struct ARegion *ar, short mval_sta[2], short mval_end[2], int margin, float *depth)
+{
+ struct { struct ARegion *ar; int margin; float depth; } data = {0};
+ int p1[2];
+ int p2[2];
+
+ data.ar= ar;
+ data.margin= margin;
+ data.depth= FLT_MAX;
+
+ VECCOPY2D(p1, mval_sta);
+ VECCOPY2D(p2, mval_end);
+
+ plot_line_v2v2i(p1, p2, depth_segment_cb, &data);
+
+ *depth= data.depth;
+
+ return (*depth==FLT_MAX) ? 0:1;
}
/* ********************* NDOF ************************ */