Blender
V3.3
|
Snap cursor. More...
#include "DNA_object_types.h"
#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "MEM_guardedalloc.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "ED_screen.h"
#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
#include "ED_view3d.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "DEG_depsgraph_query.h"
#include "WM_api.h"
Go to the source code of this file.
Classes | |
struct | SnapStateIntern |
struct | SnapCursorDataIntern |
Macros | |
#define | STATE_INTERN_GET(state) (SnapStateIntern *)((char *)state - offsetof(SnapStateIntern, snap_state)) |
#define | FADE(v) max_ff(0.0f, (1.0f - square_f(((len_v3v3(v, center) / scale_fade) + resolution_div) * 2.0f))) |
Typedefs | |
typedef struct SnapStateIntern | SnapStateIntern |
typedef struct SnapCursorDataIntern | SnapCursorDataIntern |
Variables | |
static SnapCursorDataIntern | g_data_intern |
static const float | eps_view_align = 1e-2f |
Snap cursor.
Definition in file view3d_cursor_snap.c.
#define FADE | ( | v | ) | max_ff(0.0f, (1.0f - square_f(((len_v3v3(v, center) / scale_fade) + resolution_div) * 2.0f))) |
#define STATE_INTERN_GET | ( | state | ) | (SnapStateIntern *)((char *)state - offsetof(SnapStateIntern, snap_state)) |
Definition at line 40 of file view3d_cursor_snap.c.
typedef struct SnapCursorDataIntern SnapCursorDataIntern |
typedef struct SnapStateIntern SnapStateIntern |
Definition at line 351 of file view3d_cursor_snap.c.
References color, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_line_width(), GPU_SHADER_3D_UNIFORM_COLOR, GPU_vertformat_attr_add(), imm_draw_cube_corners_3d(), immBindBuiltinProgram(), immUnbindProgram(), immUniformColor4ubv(), and immVertexFormat().
Referenced by v3d_cursor_snap_draw_fn().
V3DSnapCursorState* ED_view3d_cursor_snap_active | ( | void | ) |
Definition at line 966 of file view3d_cursor_snap.c.
References BLI_addtail(), g_data_intern, SnapCursorDataIntern::handle, MEM_mallocN, SnapStateIntern::snap_state, SnapCursorDataIntern::state_default, SnapCursorDataIntern::state_intern, and v3d_cursor_snap_activate().
Referenced by snap_gizmo_setup(), view3d_interactive_add_begin(), view3d_ob_drop_draw_activate(), and WIDGETGROUP_placement_setup().
struct SnapObjectContext* ED_view3d_cursor_snap_context_ensure | ( | Scene * | scene | ) |
Definition at line 1037 of file view3d_cursor_snap.c.
References g_data_intern, scene, SnapCursorDataIntern::snap_context_v3d, and v3d_cursor_snap_context_ensure().
Referenced by ED_gizmotypes_snap_3d_context_ensure().
V3DSnapCursorData* ED_view3d_cursor_snap_data_get | ( | void | ) |
Definition at line 1031 of file view3d_cursor_snap.c.
References g_data_intern, and SnapCursorDataIntern::snap_data.
Referenced by ED_gizmotypes_snap_3d_data_get(), ED_gizmotypes_snap_3d_invert_snap_get(), ED_gizmotypes_snap_3d_is_enabled(), gizmo_snap_rna_location_get_fn(), gizmo_snap_rna_location_set_fn(), gizmo_snap_rna_normal_get_fn(), gizmo_snap_rna_snap_elem_index_get_fn(), snap_gizmo_test_select(), view3d_interactive_add_calc_snap(), and view3d_ob_drop_matrix_from_snap().
void ED_view3d_cursor_snap_data_update | ( | V3DSnapCursorState * | state, |
const bContext * | C, | ||
const int | x, | ||
const int | y | ||
) |
Definition at line 1010 of file view3d_cursor_snap.c.
References blender::compositor::area(), BKE_area_find_region_type(), C, CTX_data_ensure_evaluated_depsgraph(), CTX_wm_area(), CTX_wm_manager(), CTX_wm_view3d(), DEG_get_input_scene(), depsgraph, ED_view3d_cursor_snap_state_get(), g_data_intern, RGN_TYPE_WINDOW, scene, state, v3d_cursor_eventstate_has_changed(), v3d_cursor_snap_update(), x, and y.
void ED_view3d_cursor_snap_deactive | ( | V3DSnapCursorState * | state | ) |
Definition at line 980 of file view3d_cursor_snap.c.
References BLI_listbase_is_empty(), BLI_remlink(), g_data_intern, MEM_freeN, state, SnapCursorDataIntern::state_intern, STATE_INTERN_GET, and v3d_cursor_snap_free().
Referenced by preview_plane_free_fn(), snap_gizmo_free(), view3d_interactive_add_exit(), and view3d_ob_drop_draw_deactivate().
void ED_view3d_cursor_snap_draw_util | ( | RegionView3D * | rv3d, |
const float | loc_prev[3], | ||
const float | loc_curr[3], | ||
const float | normal[3], | ||
const uchar | color_line[4], | ||
const uchar | color_point[4], | ||
const eSnapMode | snap_elem_type | ||
) |
Definition at line 369 of file view3d_cursor_snap.c.
References add_v3_v3(), add_v3_v3v3(), copy_m4_m4(), ED_view3d_pixel_size(), GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_PRIM_LINES, GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR, GPU_SHADER_3D_UNIFORM_COLOR, GPU_vertformat_attr_add(), GPU_viewport_size_get_f(), imm_drawcircball(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immUniform1f(), immUniform2f(), immUniformColor4ubv(), immVertex3f(), immVertex3fv(), immVertexFormat(), mul_v3_v3fl(), negate_v3_v3(), normal, pos, SCE_SNAP_MODE_EDGE_PERPENDICULAR, sub_v3_v3v3(), TH_VERTEX_SIZE, UI_GetThemeValuef(), v1, v2, and RegionView3D::viewinv.
Referenced by drawSnapping(), and v3d_cursor_snap_draw_fn().
void ED_view3d_cursor_snap_prevpoint_set | ( | V3DSnapCursorState * | state, |
const float | prev_point[3] | ||
) |
Definition at line 995 of file view3d_cursor_snap.c.
References copy_v3_v3(), ED_view3d_cursor_snap_state_get(), g_data_intern, NULL, SnapCursorDataIntern::prevpoint_stack, and state.
Referenced by gizmo_snap_rna_prevpoint_set_fn(), view3d_interactive_add_begin(), and view3d_interactive_add_modal().
void ED_view3d_cursor_snap_state_default_set | ( | V3DSnapCursorState * | state | ) |
Definition at line 953 of file view3d_cursor_snap.c.
References V3DSnapCursorState::draw_box, V3DSnapCursorState::draw_plane, g_data_intern, V3DSnapCursorState::gzgrp_type, NULL, V3DSnapCursorState::prevpoint, state, and SnapCursorDataIntern::state_default.
Referenced by idp_rna_plane_axis_set_fn(), idp_rna_plane_depth_set_fn(), idp_rna_plane_orient_set_fn(), idp_rna_snap_target_set_fn(), and idp_rna_use_plane_axis_auto_set_fn().
V3DSnapCursorState* ED_view3d_cursor_snap_state_get | ( | void | ) |
Definition at line 905 of file view3d_cursor_snap.c.
References BLI_listbase_is_empty(), g_data_intern, ListBase::last, SnapCursorDataIntern::state_default, and SnapCursorDataIntern::state_intern.
Referenced by ED_view3d_cursor_snap_data_update(), ED_view3d_cursor_snap_prevpoint_set(), gizmo_snap_state_from_rna_get(), idp_rna_plane_axis_get_fn(), idp_rna_plane_axis_set_fn(), idp_rna_plane_depth_get_fn(), idp_rna_plane_depth_set_fn(), idp_rna_plane_orient_get_fn(), idp_rna_plane_orient_set_fn(), idp_rna_snap_target_get_fn(), idp_rna_snap_target_set_fn(), idp_rna_use_plane_axis_auto_get_fn(), idp_rna_use_plane_axis_auto_set_fn(), v3d_cursor_snap_draw_fn(), v3d_cursor_snap_poll_fn(), view3d_interactive_add_begin(), and view3d_ob_drop_copy_local_id().
|
static |
Re-order mat so axis_align uses its own axis which is closest to v.
Definition at line 162 of file view3d_cursor_snap.c.
References copy_m3_m3(), copy_v3_v3(), dot_v3v3(), fabsf, mod_i(), offset, and v.
Referenced by v3d_cursor_snap_update().
|
static |
Definition at line 466 of file view3d_cursor_snap.c.
References wmWindow::eventstate, SnapCursorDataIntern::last_eventstate, SnapCursorDataIntern::modifier, state, V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE, wmWindowManager::winactive, x, SnapCursorDataIntern::x, SnapCursorDataIntern::y, and y.
Referenced by ED_view3d_cursor_snap_data_update(), and v3d_cursor_snap_draw_fn().
|
static |
Definition at line 498 of file view3d_cursor_snap.c.
References wmWindow::eventstate, SnapCursorDataIntern::last_eventstate, SnapCursorDataIntern::modifier, and wmWindowManager::winactive.
Referenced by v3d_cursor_snap_update().
|
static |
Definition at line 489 of file view3d_cursor_snap.c.
References cursor_snap, x, and y.
Referenced by v3d_cursor_snap_update().
|
static |
Definition at line 508 of file view3d_cursor_snap.c.
References ELEM, wmWindow::eventstate, EVT_LEFTALTKEY, EVT_LEFTCTRLKEY, EVT_LEFTSHIFTKEY, EVT_OSKEY, EVT_RIGHTALTKEY, EVT_RIGHTCTRLKEY, EVT_RIGHTSHIFTKEY, ListBase::first, V3DSnapCursorData::is_snap_invert, wmKeyMap::items, SnapCursorDataIntern::keymap, KM_ALT, KM_CTRL, KM_OSKEY, KM_SHIFT, KMI_INACTIVE, SnapCursorDataIntern::last_eventstate, SnapCursorDataIntern::modifier, SnapCursorDataIntern::snap_data, SnapCursorDataIntern::snap_on, wmWindowManager::winactive, and WM_keymap_active().
Referenced by v3d_cursor_snap_update().
|
static |
Definition at line 285 of file view3d_cursor_snap.c.
References ceil_power_of_10(), center, color, dot_v3v3(), ED_view3d_global_to_vector(), ED_view3d_pixel_size(), fabsf, RegionView3D::is_persp, max_ff(), negate_v3_v3(), RegionView3D::ofs, square_f(), and v3d_cursor_plane_draw_grid().
Referenced by v3d_cursor_snap_draw_fn().
|
static |
Definition at line 190 of file view3d_cursor_snap.c.
References BLI_assert, center, color, FADE, float(), GPU_blend(), GPU_BLEND_ADDITIVE, GPU_BLEND_NONE, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_line_width(), GPU_PRIM_LINES, GPU_SHADER_3D_SMOOTH_COLOR, GPU_vertformat_attr_add(), immAttr4fv(), immBeginAtMost(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immVertex3fv(), immVertexFormat(), MEM_freeN, MEM_mallocN, mul_m4_v3(), UNPACK4, v1, v2, x, and y.
Referenced by v3d_cursor_plane_draw().
|
static |
Calculate a 3x3 orientation matrix from the surface under the cursor.
Definition at line 97 of file view3d_cursor_snap.c.
References copy_m3_m4(), copy_v3_v3(), dot_v3v3(), fabsf, negate_v3(), normal, normalize_m3(), and orthogonalize_m3().
Referenced by v3d_cursor_snap_update().
Definition at line 914 of file view3d_cursor_snap.c.
References G, g_data_intern, SnapCursorDataIntern::handle, SnapCursorDataIntern::is_initiated, SnapCursorDataIntern::keymap, wmKeyMap::modal_items, NULL, RGN_TYPE_WINDOW, RNA_enum_value_from_id(), SnapCursorDataIntern::snap_on, SPACE_VIEW3D, v3d_cursor_snap_draw_fn(), v3d_cursor_snap_poll_fn(), WM_modalkeymap_find(), and WM_paint_cursor_activate().
Referenced by ED_view3d_cursor_snap_active().
|
static |
Calculate 3D view incremental (grid) snapping.
Definition at line 132 of file view3d_cursor_snap.c.
References add_v3_v3(), ED_view3d_grid_view_scale(), mul_v3_fl(), NULL, SCE_SNAP_ABS_GRID, scene, ToolSettings::snap_flag, sub_v3_v3(), Scene::toolsettings, and UNLIKELY.
Referenced by v3d_cursor_snap_update().
Definition at line 572 of file view3d_cursor_snap.c.
References g_data_intern, LISTBASE_FOREACH, state, and SnapCursorDataIntern::state_intern.
Referenced by v3d_cursor_snap_update().
Definition at line 559 of file view3d_cursor_snap.c.
References ED_transform_snap_object_context_create(), ED_transform_snap_object_context_destroy(), g_data_intern, NULL, scene, SnapCursorDataIntern::scene, and SnapCursorDataIntern::snap_context_v3d.
Referenced by ED_view3d_cursor_snap_context_ensure(), and v3d_cursor_snap_update().
Definition at line 840 of file view3d_cursor_snap.c.
References blender::compositor::area(), BKE_area_find_region_type(), C, copy_m4_m3(), copy_v3_v3(), CTX_data_ensure_evaluated_depsgraph(), CTX_wm_area(), CTX_wm_manager(), CTX_wm_view3d(), CTX_wm_window(), cursor_box_draw(), DEG_get_input_scene(), depsgraph, ED_view3d_cursor_snap_draw_util(), ED_view3d_cursor_snap_state_get(), g_data_intern, GPU_line_smooth(), GPU_line_width(), GPU_matrix_mul, GPU_matrix_projection_set, GPU_matrix_set, V3DSnapCursorData::loc, NULL, V3DSnapCursorData::plane_omat, ARegion::regiondata, RGN_TYPE_WINDOW, SCE_SNAP_MODE_EDGE_PERPENDICULAR, SCE_SNAP_MODE_NONE, scene, SnapCursorDataIntern::snap_data, V3DSnapCursorData::snap_elem, state, v3d_cursor_eventstate_has_changed(), v3d_cursor_plane_draw(), v3d_cursor_snap_update(), RegionView3D::viewmat, RegionView3D::winmat, ARegion::winrct, wmViewport(), wmWindowViewport(), x, rcti::xmin, y, and rcti::ymin.
Referenced by v3d_cursor_snap_activate().
|
static |
Definition at line 550 of file view3d_cursor_snap.c.
References scene, V3DSnapCursorState::snap_elem_force, ToolSettings::snap_mode, and Scene::toolsettings.
Referenced by v3d_cursor_snap_update().
Definition at line 938 of file view3d_cursor_snap.c.
References ED_transform_snap_object_context_destroy(), g_data_intern, G_MAIN, SnapCursorDataIntern::handle, NULL, SnapCursorDataIntern::snap_context_v3d, and WM_paint_cursor_end().
Referenced by ED_view3d_cursor_snap_deactive().
Definition at line 794 of file view3d_cursor_snap.c.
References blender::compositor::area(), BKE_area_find_region_type(), C, CTX_wm_area(), CTX_wm_manager(), CTX_wm_region(), ED_region_overlap_isect_xy(), ED_view3d_cursor_snap_state_get(), wmWindow::eventstate, G, ARegion::gizmo_map, NULL, ARegion::overlap, ARegion::regiondata, ARegion::regiontype, RegionView3D::rflag, RGN_TYPE_WINDOW, RV3D_NAVIGATING, SPACE_VIEW3D, state, wmWindowManager::winactive, and WM_gizmomap_group_find_ptr().
Referenced by v3d_cursor_snap_activate().
|
static |
Definition at line 583 of file view3d_cursor_snap.c.
References BKE_scene_orientation_get_index(), BLI_assert_msg, C, copy_m3_m3(), copy_m3_m4(), copy_m4_m4(), copy_v3_v3(), copy_v3_v3_int(), CTX_data_view_layer(), Scene::cursor, depsgraph, dot_v3v3(), ED_transform_calc_orientation_from_type_ex(), ED_transform_snap_object_project_view3d_ex(), ED_view3d_win_to_3d(), ED_view3d_win_to_3d_on_plane(), V3DSnapCursorData::elem_index, eps_view_align, fabsf, g_data_intern, if(), V3DSnapCursorData::is_enabled, RegionView3D::is_persp, V3DSnapCursorData::is_snap_invert, is_zero_v3(), V3DSnapCursorData::loc, View3DCursor::location, mat3_align_axis_to_v3(), negate_v3(), negate_v3_v3(), V3DSnapCursorData::nor, NULL, OBACT, V3DSnapCursorData::obmat, orthogonalize_m3(), plane_from_point_normal_v3(), V3DSnapCursorData::plane_omat, ARegion::regiondata, SCE_ORIENT_DEFAULT, SCE_SNAP, SCE_SNAP_MODE_EDGE, SCE_SNAP_MODE_EDGE_MIDPOINT, SCE_SNAP_MODE_EDGE_PERPENDICULAR, SCE_SNAP_MODE_FACE_RAYCAST, SCE_SNAP_MODE_GEOM, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_NONE, SCE_SNAP_MODE_VERTEX, scene, SnapCursorDataIntern::snap_context_v3d, SnapCursorDataIntern::snap_data, V3DSnapCursorData::snap_elem, SnapCursorDataIntern::snap_elem_hidden, ToolSettings::snap_flag, SNAP_GEOM_CAGE, SNAP_GEOM_EDIT, SNAP_GEOM_FINAL, state, sub_v3_v3v3(), Scene::toolsettings, ToolSettings::transform_pivot_point, unit_m3(), v3d_cursor_eventstate_save_modifier(), v3d_cursor_eventstate_save_xy(), v3d_cursor_is_snap_invert(), v3d_cursor_poject_surface_normal(), v3d_cursor_snap_calc_incremental(), v3d_cursor_snap_calc_plane(), v3d_cursor_snap_context_ensure(), v3d_cursor_snap_elements(), V3D_PLACE_DEPTH_CURSOR_VIEW, V3D_PLACE_DEPTH_SURFACE, V3D_PLACE_ORIENT_SURFACE, V3D_SNAPCURSOR_OCCLUSION_ALWAYS_TRUE, V3D_SNAPCURSOR_SNAP_EDIT_GEOM_CAGE, V3D_SNAPCURSOR_SNAP_EDIT_GEOM_FINAL, V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE, RegionView3D::viewinv, x, y, and zero_v3().
Referenced by ED_view3d_cursor_snap_data_update(), and v3d_cursor_snap_draw_fn().
Dot products below this will be considered view aligned. In this case we can't usefully project the mouse cursor onto the plane.
Definition at line 92 of file view3d_cursor_snap.c.
Referenced by v3d_cursor_snap_update().
|
static |
Definition at line 78 of file view3d_cursor_snap.c.
Referenced by ED_view3d_cursor_snap_active(), ED_view3d_cursor_snap_context_ensure(), ED_view3d_cursor_snap_data_get(), ED_view3d_cursor_snap_data_update(), ED_view3d_cursor_snap_deactive(), ED_view3d_cursor_snap_prevpoint_set(), ED_view3d_cursor_snap_state_default_set(), ED_view3d_cursor_snap_state_get(), v3d_cursor_snap_activate(), v3d_cursor_snap_calc_plane(), v3d_cursor_snap_context_ensure(), v3d_cursor_snap_draw_fn(), v3d_cursor_snap_free(), and v3d_cursor_snap_update().