23#include "RNA_prototypes.hh"
65 TransInfo *t,
const float mval[2],
float *dist_px,
float r_loc[3],
float r_no[3]);
77int BIF_snappingSupported(
Object *obedit)
82 if (obedit ==
nullptr ||
202 uchar col[4], selectedCol[4], activeCol[4];
211 if (!(draw_source || draw_target)) {
224 selectedCol[3] = 128;
231 const float *source_loc =
nullptr;
232 const float *target_loc =
nullptr;
241 float view_inv[4][4];
298 const float snap_point[2] = {
361 region->v2d.cur.ymax,
363 region->v2d.cur.ymin);
367 region->v2d.cur.xmin,
369 region->v2d.cur.xmax,
376 region->v2d.cur.ymax,
378 region->v2d.cur.ymin);
391 if (BIF_snappingSupported(t->obedit) && (event->
type ==
EVT_TABKEY) &&
409 float iloc[3], loc[3], no[3];
458 const float *original_normal;
462 original_normal = td->
axismtx[2];
477 float snap_loc[3], snap_no[3];
487 copy_v3_v3(init_loc, td->
ob->object_to_world().location());
494 snap_object_params.use_backface_culling =
false;
541 for (
int i = 0; i < tc->data_len; i++, td++) {
662 }
while ((l_iter = l_iter->
next) != l_first);
673 *r_prop = &rna_ToolSettings_use_snap;
678 *r_prop = &rna_ToolSettings_use_snap_node;
683 *r_prop = &rna_ToolSettings_use_snap_uv;
688 *r_prop = &rna_ToolSettings_use_snap_sequencer;
695 *r_prop = &rna_ToolSettings_use_snap_anim;
772 if (obedit_type != -1) {
863 r_snap[0] = r_snap[1] = 1.0f;
865 *r_snap_precision = 0.1f;
887 *r_snap_precision = 0.5f;
890 r_snap[0] = r_snap[1] = 0.125f;
891 *r_snap_precision = 0.5f;
1061 if (is_uv_editor && has_edit_object) {
1131 float screen_loc[2];
1144 if (dist_sq < dist_min_sq) {
1146 dist_min_sq = dist_sq;
1185 vec[0] = vec[1] = vec[2] = 0;
1232 for (
int i = 0; i < 2; i++) {
1233 const float iter_fac = grid_dist[i];
1234 r_out[i] = iter_fac * roundf((in[i] + center_global[i]) / iter_fac);
1285 if (found ==
true) {
1395 for (i = 0; i < tc->data_len && td->flag &
TD_SELECTED; i++, td++) {
1406 if (tc->use_local_mat) {
1422 bNode *node =
static_cast<bNode *
>(td->extra);
1499 float dist_closest = 0.0f;
1507 for (td = tc->data, i = 0; i < tc->data_len && td->flag &
TD_SELECTED; i++, td++) {
1508 std::optional<blender::Bounds<blender::float3>> bounds;
1520 for (j = 0; j < 8; j++) {
1530 (closest ==
nullptr ||
fabsf(dist) <
fabsf(dist_closest)))
1534 dist_closest = dist;
1548 (closest ==
nullptr ||
fabsf(dist) <
fabsf(dist_closest)))
1561 for (i = 0; i < tc->data_len && td->flag &
TD_SELECTED; i++, td++) {
1567 if (tc->use_local_mat) {
1574 (closest ==
nullptr ||
fabsf(dist) <
fabsf(dist_closest)))
1578 dist_closest = dist;
1598 TransInfo *t,
const float mval[2],
float *dist_px,
float r_loc[3],
float r_no[3])
1610 float *grid_co =
nullptr, grid_co_stack[3];
1613 grid_co = grid_co_stack;
1625 &snap_object_params,
1641 const float mval[2],
1642 const bool use_peel_object,
1657 &snap_object_params,
1667 if (iter->depth < hit_min->
depth) {
1673 if (use_peel_object) {
1677 if ((iter->depth > hit_max->
depth) && (iter->ob_uuid == hit_min->
ob_uuid)) {
1685 if ((iter != hit_min) && (iter->ob_uuid == hit_min->
ob_uuid)) {
1686 if (hit_max ==
nullptr) {
1689 else if (iter->depth < hit_max->
depth) {
1695 if (hit_max ==
nullptr) {
1703 *r_thickness = hit_max->
depth - hit_min->
depth;
1728 (node->runtime->totr.xmin < v2d->
cur.
xmax && node->runtime->totr.xmax > v2d->
cur.
xmin &&
1729 node->runtime->totr.ymin < v2d->
cur.
ymax && node->runtime->totr.ymax > v2d->
cur.
ymin);
1751 char *r_node_border)
1753 View2D *v2d = ®ion->v2d;
1755 bool retval =
false;
1762 new_dist =
abs(totr.
xmin - mval[0]);
1763 if (new_dist < *r_dist_px) {
1765 *r_dist_px = new_dist;
1772 new_dist =
abs(totr.
xmax - mval[0]);
1773 if (new_dist < *r_dist_px) {
1775 *r_dist_px = new_dist;
1782 new_dist =
abs(totr.
ymin - mval[1]);
1783 if (new_dist < *r_dist_px) {
1785 *r_dist_px = new_dist;
1792 new_dist =
abs(totr.
ymax - mval[1]);
1793 if (new_dist < *r_dist_px) {
1795 *r_dist_px = new_dist;
1811 char *r_node_border)
1814 bool retval =
false;
1819 if (
snapNodeTest(®ion->v2d, node, snap_target_select)) {
1820 retval |=
snapNode(ts, snode, region, node, mval, r_loc, r_dist_px, r_node_border);
1828 TransInfo *t,
const float2 &mval,
float r_loc[2],
float *r_dist_px,
char *r_node_border)
1847 const int max_index,
1848 const float increment_val,
1849 const float aspect[3],
1854 for (
int i = 0; i <= max_index; i++) {
1855 const float iter_fac = increment_val * aspect[i];
1856 r_out[i] = iter_fac * roundf(loc[i] / iter_fac);
1861 const int max_index,
1862 const float increment_dist,
1869 if (increment_dist == 0.0f) {
1873 float asp_local[3] = {1, 1, 1};
1875 const float *asp = use_aspect ? t->
aspect : asp_local;
1909 if (use_local_space) {
1916 if (use_local_space) {
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
General operations, lookup, etc. for blender objects.
bool BKE_object_is_in_editmode(const Object *ob)
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_eval_cached_get(const Object *ob)
void BKE_boundbox_init_from_minmax(BoundBox *bb, const float min[3], const float max[3])
void BKE_object_eval_transform_all(Depsgraph *depsgraph, Scene *scene, Object *object)
bool BKE_scene_uses_blender_workbench(const Scene *scene)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
MINLINE float square_f(float a)
void mul_m3_v3(const float M[3][3], float r[3])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3])
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE bool is_zero_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Platform independent time functions.
double BLI_time_now_seconds(void)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define POINTER_FROM_UINT(i)
#define SCE_SNAP_TO_VERTEX
@ SCE_SNAP_TO_INCLUDE_EDITED
@ SCE_SNAP_TO_INCLUDE_NONEDITED
@ SCE_SNAP_BACKFACE_CULLING
@ SCE_SNAP_KEEP_ON_SAME_OBJECT
@ SCE_SNAP_TO_ONLY_SELECTABLE
@ SCE_SNAP_TRANSFORM_MODE_SCALE
@ SCE_SNAP_TRANSFORM_MODE_ROTATE
@ SCE_SNAP_TRANSFORM_MODE_TRANSLATE
@ SCE_SNAP_SOURCE_CLOSEST
@ SCE_SNAP_TARGET_NOT_ACTIVE
@ SCE_SNAP_TARGET_NOT_NONEDITED
@ SCE_SNAP_TARGET_ONLY_SELECTABLE
@ SCE_SNAP_TARGET_NOT_SELECTED
@ SCE_SNAP_TARGET_NOT_EDITED
@ SCE_SNAP_INDIVIDUAL_NEAREST
@ SCE_SNAP_INDIVIDUAL_PROJECT
@ SCE_SNAP_TO_EDGE_ENDPOINT
@ SCE_SNAP_TO_EDGE_MIDPOINT
@ SCE_SNAP_TO_EDGE_PERPENDICULAR
#define SI_GRID_STEPS_LEN
@ V3D_SHADING_BACKFACE_CULLING
float ED_space_image_zoom_level(const View2D *v2d, int grid_dimension)
float ED_space_image_increment_snap_value(int grid_dimensions, const float grid_steps[SI_GRID_STEPS_LEN], float zoom_factor)
void ED_space_image_grid_steps(SpaceImage *sima, float grid_steps_x[SI_GRID_STEPS_LEN], float grid_steps_y[SI_GRID_STEPS_LEN], int grid_dimension)
void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned int pos)
float ED_node_grid_size()
void ED_transform_snap_object_context_set_editmesh_callbacks(SnapObjectContext *sctx, bool(*test_vert_fn)(BMVert *, void *user_data), bool(*test_edge_fn)(BMEdge *, void *user_data), bool(*test_face_fn)(BMFace *, void *user_data), void *user_data)
bool ED_transform_snap_object_project_all_view3d_ex(SnapObjectContext *sctx, Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const SnapObjectParams *params, const float mval[2], float ray_depth, bool sort, ListBase *r_hit_list)
#define ED_transform_snap_object_time_average_print()
SnapObjectContext * ED_transform_snap_object_context_create(Scene *scene, int flag)
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
eSnapMode ED_transform_snap_object_project_view3d(SnapObjectContext *sctx, Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const eSnapMode snap_to, const SnapObjectParams *params, const float init_co[3], const float mval[2], const float prev_co[3], float *dist_px, float r_loc[3], float r_no[3])
bool ED_uvedit_nearest_uv_multi(const View2D *v2d, const Scene *scene, blender::Span< Object * > objects, const float mval_fl[2], const bool ignore_selected, float *dist_sq, float r_uv[2])
float ED_view3d_grid_view_scale(const Scene *scene, const View3D *v3d, const ARegion *region, const char **r_grid_unit)
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d, const float source_loc[3], const float target_loc[3], const eSnapMode source_type, const eSnapMode target_type, const uchar source_color[4], const uchar target_color[4])
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void GPU_matrix_push_projection()
void GPU_matrix_pop_projection()
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_depth_test(eGPUDepthTest test)
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
float UI_GetThemeValuef(int colorid)
float UI_view2d_grid_resolution_x__frames_or_seconds(const View2D *v2d, const Scene *scene, bool display_seconds)
void UI_view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
float UI_view2d_grid_resolution_y__values(const View2D *v2d)
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst) ATTR_NONNULL()
bool BM_elem_cb_check_hflag_disabled(BMElem *ele, void *user_data)
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_flag_test(ele, hflag)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
short SEQ_tool_settings_snap_mode_get(Scene *scene)
struct SceneDisplay display
SnapObjectHitDepth * next
eSnapTargetOP snap_target_select
struct bNodeTree * edittree
float snap_spatial_precision
TransModeInfo * mode_info
TransConvertTypeInfo * data_type
float(* snap_distance_fn)(TransInfo *t, const float p1[3], const float p2[3])
void(* snap_apply_fn)(TransInfo *, float *)
TransSeqSnapData * seq_context
void(* snap_target_fn)(TransInfo *, float *)
TransSnapPoint * selectedPoint
SnapObjectContext * object_context
eSnapSourceOP source_operation
void(* snap_source_fn)(TransInfo *)
eSnapTargetOP target_operation
ccl_device_inline int abs(int x)
void wmOrtho2_region_pixelspace(const ARegion *region)