main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
Showing only changes of commit b79ad1f93f - Show all commits

View File

@ -1295,7 +1295,6 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
{ {
ARegion *region = CTX_wm_region(C); ARegion *region = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C); View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = region->regiondata;
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) {
BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view"); BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view");
@ -1304,7 +1303,6 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
wmGizmoMap *gzmap = region->gizmo_map; wmGizmoMap *gzmap = region->gizmo_map;
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
const bool use_depth = (v3d->shading.type >= OB_SOLID);
if (!gizmo_ruler_check_for_operator(gzgroup)) { if (!gizmo_ruler_check_for_operator(gzgroup)) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
@ -1324,31 +1322,23 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
OPERATOR_RUNNING_MODAL) { OPERATOR_RUNNING_MODAL) {
RulerInfo *ruler_info = gzgroup->customdata; RulerInfo *ruler_info = gzgroup->customdata;
RulerInteraction *inter = ruler_item->gz.interaction_data; RulerInteraction *inter = ruler_item->gz.interaction_data;
if (use_depth) { struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); inter->co_index = 0;
/* snap the first point added, not essential but handy */ view3d_ruler_item_mousemove(C,
inter->co_index = 0; depsgraph,
view3d_ruler_item_mousemove(C, ruler_info,
depsgraph, ruler_item,
ruler_info, mval,
ruler_item, false
mval,
false
#ifndef USE_SNAP_DETECT_FROM_KEYMAP_HACK #ifndef USE_SNAP_DETECT_FROM_KEYMAP_HACK
, ,
true true
#endif #endif
); );
copy_v3_v3(inter->drag_start_co, ruler_item->co[inter->co_index]); copy_v3_v3(inter->drag_start_co, ruler_item->co[inter->co_index]);
RNA_property_float_set_array(ruler_info->snap_data.gizmo->ptr, RNA_property_float_set_array(ruler_info->snap_data.gizmo->ptr,
ruler_info->snap_data.prop_prevpoint, ruler_info->snap_data.prop_prevpoint,
inter->drag_start_co); inter->drag_start_co);
}
else {
negate_v3_v3(inter->drag_start_co, rv3d->ofs);
copy_v3_v3(ruler_item->co[0], inter->drag_start_co);
view3d_ruler_item_project(ruler_info, ruler_item->co[0], mval);
}
copy_v3_v3(ruler_item->co[2], ruler_item->co[0]); copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
ruler_item->gz.highlight_part = inter->co_index = 2; ruler_item->gz.highlight_part = inter->co_index = 2;