27#include "RNA_prototypes.hh"
68 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 ||
208 uchar col[4], selectedCol[4], activeCol[4];
217 if (!(draw_source || draw_target)) {
230 selectedCol[3] = 128;
237 const float *source_loc =
nullptr;
238 const float *target_loc =
nullptr;
247 float view_inv[4][4];
326 const float snap_point[2] = {
350 auto draw_vline = [&](
float ymin,
float ymax,
uchar alpha) {
352 immRectf(pos, target_x - pixelx, ymin, target_x + pixelx, ymax);
355 auto draw_hline = [&](
float xmin,
float xmax,
uchar alpha) {
357 immRectf(pos, xmin, target_y - pixelx, xmax, target_y + pixelx);
376 draw_vline(target_y - 0.5, target_y + 1.5, col[3]);
392 if (BIF_snappingSupported(t->obedit) && (event->
type ==
EVT_TABKEY) &&
417 float iloc[3], loc[3], no[3];
427 copy_v3_v3(iloc, ob->object_to_world().location());
467 const float *original_normal;
471 original_normal = td->
axismtx[2];
486 float snap_loc[3], snap_no[3];
497 copy_v3_v3(init_loc, ob->object_to_world().location());
552 for (
int i = 0; i < tc->data_len; i++, td++) {
659 *r_prop = &rna_ToolSettings_use_snap;
664 *r_prop = &rna_ToolSettings_use_snap_node;
669 *r_prop = &rna_ToolSettings_use_snap_uv;
674 *r_prop = &rna_ToolSettings_use_snap_sequencer;
680 *r_prop = &rna_ToolSettings_use_snap_anim;
685 switch (graph_editor->
mode) {
693 *r_prop = &rna_ToolSettings_use_snap_anim;
749 switch (graph_editor->
mode) {
788 else if (obedit_type != -1) {
832 return target_operation;
840 t->
tsnap.object_context,
876 r_snap[0] = r_snap[1] = 1.0f;
878 *r_snap_precision = 0.1f;
902 *r_snap_precision = 0.5f;
906 r_snap[0] = r_snap[1] = 0.125f;
907 *r_snap_precision = 0.5f;
1021 if (t->
tsnap.object_context ==
nullptr) {
1028 if (t->
tsnap.seq_context ==
nullptr) {
1042 t->
tsnap.seq_context =
nullptr;
1044 else if (t->
tsnap.object_context) {
1046 t->
tsnap.object_context =
nullptr;
1058 float increment_precision;
1069 if (increment != 0.0f) {
1093 if (is_uv_editor && has_edit_object) {
1162 float screen_loc[2];
1188 if (dist_sq < dist_min_sq) {
1190 dist_min_sq = dist_sq;
1229 vec[0] = vec[1] = vec[2] = 0;
1276 for (
int i = 0; i < 2; i++) {
1277 const float iter_fac = grid_dist[i];
1278 r_out[i] = iter_fac *
roundf((
in[i] + center_global[i]) / iter_fac);
1329 if (found ==
true) {
1417 int num_selected = 0;
1418 tc->foreach_index_selected([&](
const int i) {
1423 if (num_selected == 0) {
1430 if (tc->use_local_mat) {
1498 float dist_closest = 0.0f;
1504 tc->foreach_index_selected([&](
const int i) {
1507 std::optional<Bounds<float3>>
bounds;
1520 for (j = 0; j < 8; j++) {
1534 dist_closest = dist;
1559 tc->foreach_index_selected([&](
const int i) {
1567 if (tc->use_local_mat) {
1578 dist_closest = dist;
1595 TransInfo *t,
const float mval[2],
float *dist_px,
float r_loc[3],
float r_no[3])
1607 float *grid_co =
nullptr, grid_co_stack[3];
1610 grid_co = grid_co_stack;
1622 &snap_object_params,
1638 const float mval[2],
1639 const bool use_peel_object,
1649 ListBaseT<SnapObjectHitDepth> depths_peel = {
nullptr};
1654 &snap_object_params,
1660 if (!depths_peel.is_empty()) {
1664 if (iter->depth < hit_min->
depth) {
1670 if (use_peel_object) {
1674 if ((iter.depth > hit_max->
depth) && (iter.ob_uuid == hit_min->
ob_uuid)) {
1682 if ((&iter != hit_min) && (iter.ob_uuid == hit_min->
ob_uuid)) {
1683 if (hit_max ==
nullptr) {
1686 else if (iter.depth < hit_max->
depth) {
1692 if (hit_max ==
nullptr) {
1700 *r_thickness = hit_max->
depth - hit_min->
depth;
1727 for (
int i = 0; i <= t->
idx_max; i++) {
1730 if (iter_fac != 0.0f) {
1731 r_out[i] = iter_fac *
roundf(loc[i] / iter_fac);
1752 if (use_local_space) {
1758 if (use_local_space) {
General operations, lookup, etc. for blender objects.
Platform independent time functions.
#define SCE_SNAP_TO_VERTEX
#define SI_GRID_STEPS_LEN
#define ED_transform_snap_object_time_average_print()
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
bool closest(btVector3 &v)
std::array< VecBase< T, 3 >, 8 > corners(const Bounds< VecBase< T, 3 > > &bounds)
short tool_settings_snap_flag_get(Scene *scene)
short tool_settings_snap_mode_get(Scene *scene)
float get_value_f(int colorid)
void get_color_3ubv(int colorid, unsigned char col[3])
void view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
float view2d_pixel_size_get_x(const View2D *v2d)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mul_m3_v3(const float M[3][3], float r[3])
void wmOrtho2_region_pixelspace(const ARegion *region)
MINLINE bool is_zero_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
MINLINE void mul_v2_fl(float r[2], float f)
@ SCE_SNAP_SOURCE_CLOSEST
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
GPUVertFormat * immVertexFormat()
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
void immBegin(GPUPrimType, uint vertex_len)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
MINLINE int max_ii(int a, int b)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void imm_drawcircball(const float cent[3], float radius, const float tmat[4][4], uint pos)
@ V3D_SHADING_BACKFACE_CULLING
MINLINE void mul_v3_fl(float r[3], float f)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
void mul_m4_v3(const float M[4][4], float r[3])
@ 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
VecBase< float, 2 > float2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
float ED_space_image_zoom_level(const View2D *v2d, int grid_dimension)
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])
@ GPU_SHADER_3D_UNIFORM_COLOR
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
@ SCE_SNAP_TO_EDGE_MIDPOINT
@ SCE_SNAP_TO_EDGE_PERPENDICULAR
@ SCE_SNAP_TO_FACE_MIDPOINT
@ SCE_SNAP_INDIVIDUAL_NEAREST
@ SCE_SNAP_INDIVIDUAL_PROJECT
@ SCE_SNAP_TO_EDGE_ENDPOINT
float ED_view3d_grid_view_scale(const Scene *scene, const View3D *v3d, const ARegion *region, const char **r_grid_unit)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b)
MINLINE void zero_v3(float r[3])
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
@ SEQ_SNAP_TO_ALL_CHANNEL_STRIPS
bool BKE_object_is_in_editmode(const Object *ob)
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
void immVertex3fv(uint attr_id, const float data[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool BKE_scene_uses_blender_workbench(const Scene *scene)
void GPU_matrix_pop_projection()
std::optional< Bounds< float3 > > BKE_object_boundbox_eval_cached_get(const Object *ob)
@ SCE_SNAP_TRANSFORM_MODE_TRANSLATE
@ SCE_SNAP_TRANSFORM_MODE_SCALE
@ SCE_SNAP_TRANSFORM_MODE_ROTATE
MINLINE float square_f(float a)
double BLI_time_now_seconds()
void immVertex3f(uint attr_id, float x, float y, float z)
MINLINE void mul_v2_v2v2(float r[2], const float a[2], const float b[2])
float ED_space_image_increment_snap_value(int grid_dimensions, const float grid_steps[SI_GRID_STEPS_LEN], float zoom_factor)
@ SCE_SNAP_BACKFACE_CULLING
@ SCE_SNAP_TO_INCLUDE_EDITED
@ SCE_SNAP_KEEP_ON_SAME_OBJECT
@ SCE_SNAP_TO_INCLUDE_NONEDITED
@ SCE_SNAP_TO_ONLY_SELECTABLE
void GPU_blend(GPUBlend blend)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
VecBase< float, 3 > float3
Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void immUniformColor4ubv(const unsigned char rgba[4])
void GPU_matrix_push_projection()
void GPU_depth_test(GPUDepthTest test)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3])
void BKE_object_eval_transform_all(Depsgraph *depsgraph, Scene *scene, Object *object)
bool ED_uvedit_nearest_uv_multi(const View2D *v2d, const Scene *scene, Span< Object * > objects, const float mval_fl[2], const bool ignore_selected, float *dist_sq, float r_uv[2])
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
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)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct SceneDisplay display
ListBaseT< SpaceLink > spacedata
wmEventModifierFlag modifier