Fix T48697: Brush curve-stroke snaps strangely

Support Snapping screen-space 2d curves, (was applying world-space coords in screen-space).
Also show snap settings in header.
This commit is contained in:
Campbell Barton 2016-06-21 16:17:05 +10:00
parent 7cbd1285a5
commit 1abf7dd835
Notes: blender-bot 2023-02-14 10:11:54 +01:00
Referenced by issue #48697, Texture paint Curve stroke method snaps strangely to other bezier curves in the scene
2 changed files with 22 additions and 1 deletions

View File

@ -81,7 +81,20 @@ class VIEW3D_HT_header(Header):
row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
# Snap
if not obj or mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
show_snap = False
if obj is None:
show_snap = True
else:
if mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
show_snap = True
else:
paint_settings = UnifiedPaintPanel.paint_settings(context)
if paint_settings:
brush = paint_settings.brush
if brush and brush.stroke_method == 'CURVE':
show_snap = True
if show_snap:
snap_element = toolsettings.snap_element
row = layout.row(align=True)
row.prop(toolsettings, "use_snap", text="")

View File

@ -842,6 +842,14 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
vec[1] = point[1] - t->tsnap.snapTarget[1];
}
else {
if (t->spacetype == SPACE_VIEW3D) {
if (t->options & CTX_PAINT_CURVE) {
if (ED_view3d_project_float_global(t->ar, point, point, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) {
zero_v3(point); /* no good answer here... */
}
}
}
sub_v3_v3v3(vec, point, t->tsnap.snapTarget);
}
}