58 #include "../gizmo_geometry.h"
59 #include "../gizmo_library_intern.h"
74 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
127 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
143 const int snap_on = snap_gizmo->
snap_on;
151 if (kmi->propvalue == snap_on) {
155 ((kmi->type ==
EVT_OSKEY) && event->oskey)) {
174 return (
ushort)snap_elements;
182 const float loc_prev[3],
183 const float loc_curr[3],
185 const uchar color_line[4],
186 const uchar color_point[4],
187 const short snap_elem_type)
189 if (!loc_prev && !loc_curr) {
193 float view_inv[4][4];
221 float vx[3], vy[3],
v1[3],
v2[3], v3[3], v4[4];
254 float viewport_size[4];
256 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
279 scene, 0, region, v3d);
287 snap_gizmo->
flag |= flag;
293 snap_gizmo->
flag &= ~flag;
299 return (snap_gizmo->
flag & flag) != 0;
304 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
323 const float mval_fl[2])
330 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
332 bool invert_snap_toggle =
invert_snap(snap_gizmo, wm);
333 if (invert_snap_toggle != snap_gizmo->
invert_snap) {
353 int snap_elem_index[3] = {-1, -1, -1};
359 float prev_co[3] = {0.0f};
367 float dist_px = 12.0f *
U.pixelsize;
374 .snap_select = SNAP_ALL,
375 .use_object_edit_cage = true,
376 .use_occlusion_test = true,
388 if (snap_elem == 0) {
394 snap_elem_index[0] = index;
398 snap_elem_index[1] = index;
401 snap_elem_index[2] = index;
413 wmGizmo *gz,
float r_loc[3],
float r_nor[3],
int r_elem_index[3],
int *r_snap_elem)
441 for (
bScreen *screen =
G_MAIN->screens.first; screen; screen = screen->id.next) {
451 if (gz->properties == properties) {
559 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
562 "Generic Gizmo Tweak Modal Map");
589 uchar color_line[4], color_point[4];
605 rv3d, prev_point, snap_gizmo->
loc,
NULL, color_line, color_point, snap_gizmo->
snap_elem);
630 const float mval_fl[2] = {
UNPACK2(mval)};
669 gzt->
idname =
"GIZMO_GT_snap_3d";
697 "snap_elements_force",
715 "Point that defines the location of the perpendicular snap",
730 "Snap Point Location",
757 "Array index of face, edge and vert snapped",
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
void * CTX_wm_region_data(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
void BLI_kdtree_nd_() free(KDTree *tree)
#define LISTBASE_FOREACH(type, var, list)
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_v3_int(int r[3], const int a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE bool equals_v2v2_int(const int v1[2], const int v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3(float r[3], const float a[3])
struct Depsgraph Depsgraph
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
#define SCE_SNAP_MODE_FACE
#define SCE_SNAP_MODE_EDGE_PERPENDICULAR
#define SCE_SNAP_MODE_EDGE_MIDPOINT
#define SCE_SNAP_MODE_VERTEX
#define SCE_SNAP_MODE_EDGE
@ ED_SNAPGIZMO_TOGGLE_ALWAYS_TRUE
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
SnapObjectContext * ED_transform_snap_object_context_create_view3d(struct Scene *scene, int flag, const struct ARegion *region, const struct View3D *v3d)
short ED_transform_snap_object_project_view3d_ex(struct SnapObjectContext *sctx, struct Depsgraph *depsgraph, const unsigned short snap_to, const struct SnapObjectParams *params, const float mval[2], const float prev_co[3], float *dist_px, float r_loc[3], float r_no[3], int *r_index, struct Object **r_ob, float r_obmat[4][4])
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3])
void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned int pos)
void ED_view3d_win_to_3d(const struct View3D *v3d, const struct ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
void GPU_viewport_size_get_f(float coords[4])
StructRNA RNA_ToolSettings
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
float UI_GetThemeValuef(int colorid)
eWM_GizmoFlagTweak
Gizmo tweak flag. Bitflag passed to gizmo while tweaking.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
const Depsgraph * depsgraph
IconTextureDrawCall normal
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
void RNA_def_property_enum_funcs_runtime(PropertyRNA *prop, EnumPropertyGetFunc getfunc, EnumPropertySetFunc setfunc, EnumPropertyItemFunc itemfunc)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
PropertyRNA * RNA_def_float_translation(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
void RNA_def_property_int_array_funcs_runtime(PropertyRNA *prop, IntArrayPropertyGetFunc getfunc, IntArrayPropertySetFunc setfunc, IntPropertyRangeFunc rangefunc)
void RNA_def_property_float_array_funcs_runtime(PropertyRNA *prop, FloatArrayPropertyGetFunc getfunc, FloatArrayPropertySetFunc setfunc, FloatPropertyRangeFunc rangefunc)
PropertyRNA * RNA_def_float_vector_xyz(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
const EnumPropertyItem rna_enum_snap_element_items[]
short ED_gizmotypes_snap_3d_update(wmGizmo *gz, struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const wmWindowManager *wm, const float mval_fl[2])
bool ED_gizmotypes_snap_3d_flag_test(struct wmGizmo *gz, eSnapGizmo flag)
static void gizmo_snap_rna_snap_elements_force_set_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), int value)
static struct SnapGizmo3D * gizmo_snap_rna_find_operator(PointerRNA *ptr)
static void gizmo_snap_rna_normal_get_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), float *values)
bool ED_gizmotypes_snap_3d_invert_snap_get(struct wmGizmo *gz)
void ED_gizmotypes_snap_3d_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 short snap_elem_type)
static int gizmo_snap_rna_snap_elements_force_get_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop))
static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2])
void ED_gizmotypes_snap_3d_data_get(wmGizmo *gz, float r_loc[3], float r_nor[3], int r_elem_index[3], int *r_snap_elem)
static int snap_gizmo_invoke(bContext *UNUSED(C), wmGizmo *UNUSED(gz), const wmEvent *UNUSED(event))
static int snap_gizmo_modal(bContext *UNUSED(C), wmGizmo *UNUSED(gz), const wmEvent *UNUSED(event), eWM_GizmoFlagTweak UNUSED(tweak_flag))
void ED_gizmotypes_snap_3d_flag_clear(struct wmGizmo *gz, eSnapGizmo flag)
static void snap_gizmo_free(wmGizmo *gz)
struct SnapGizmo3D SnapGizmo3D
static void gizmo_snap_rna_prevpoint_set_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), const float *values)
void ED_gizmotypes_snap_3d(void)
static void eventstate_save(SnapGizmo3D *snap_gizmo, const wmWindowManager *wm)
bool ED_gizmotypes_snap_3d_is_enabled(wmGizmo *gz)
static bool eventstate_has_changed(SnapGizmo3D *snap_gizmo, const wmWindowManager *wm)
static void snap_gizmo_setup(wmGizmo *gz)
SnapObjectContext * ED_gizmotypes_snap_3d_context_ensure(Scene *scene, const ARegion *region, const View3D *v3d, wmGizmo *gz)
static void gizmo_snap_rna_location_set_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), const float *values)
static void gizmo_snap_rna_location_get_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), float *values)
void ED_gizmotypes_snap_3d_flag_set(struct wmGizmo *gz, eSnapGizmo flag)
static short snap_gizmo_snap_elements(SnapGizmo3D *snap_gizmo)
static bool invert_snap(SnapGizmo3D *snap_gizmo, const wmWindowManager *wm)
static void gizmo_snap_rna_snap_elem_index_get_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), int *values)
static void snap_gizmo_draw(const bContext *C, wmGizmo *gz)
static void gizmo_snap_rna_prevpoint_get_fn(struct PointerRNA *ptr, struct PropertyRNA *UNUSED(prop), float *values)
static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
struct ToolSettings * toolsettings
struct SnapGizmo3D::@325 last_eventstate
SnapObjectContext * snap_context_v3d
struct wmKeyConfig * keyconf
struct wmGizmoGroupType * type
wmGizmoFnTestSelect test_select
struct wmGizmoGroup * parent_gzgroup
struct wmWindow * winactive
struct wmEvent * eventstate
const ListBase * WM_gizmomap_group_list(wmGizmoMap *gzmap)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
wmKeyMap * WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)