40 #define STATE_INTERN_GET(state) \
41 (SnapStateIntern *)((char *)state - offsetof(SnapStateIntern, snap_state))
63 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
68 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
82 .color_point = {255, 255, 255, 255},
83 .color_line = {255, 255, 255, 128},
84 .color_box = {255, 255, 255, 128},
85 .box_dimensions = {1.0f, 1.0f, 1.0f},
98 const float obmat[4][4],
107 for (
int i = 1; i < 3; i++) {
109 if (dot_test > dot_best) {
144 if (co_relative !=
NULL) {
148 co[0] = roundf(co[0]);
149 co[1] = roundf(co[1]);
150 co[2] = roundf(co[2]);
152 if (co_relative !=
NULL) {
164 float dot_best = -1.0f;
165 int axis_found = axis_align;
166 for (
int i = 0; i < 3; i++) {
168 if (dot_test > dot_best) {
174 if (axis_align != axis_found) {
177 const int offset =
mod_i(axis_found - axis_align, 3);
178 for (
int i = 0; i < 3; i++) {
192 const float scale_fade,
193 const float matrix[4][4],
194 const int plane_axis,
195 const float color[4])
198 const int resolution_min = resolution - 1;
200 const float *
center = matrix[3];
212 const size_t coords_len = resolution * resolution;
215 const int axis_x = (plane_axis + 0) % 3;
216 const int axis_y = (plane_axis + 1) % 3;
217 const int axis_z = (plane_axis + 2) % 3;
220 const float resolution_div = (
float)1.0f / (
float)resolution;
222 for (
int x = 0;
x < resolution;
x++) {
223 const float x_fl = (
x * resolution_div) - 0.5f;
224 for (
int y = 0;
y < resolution;
y++) {
225 const float y_fl = (
y * resolution_div) - 0.5f;
226 coords[i][axis_x] = 0.0f;
227 coords[i][axis_y] = x_fl * scale;
228 coords[i][axis_z] = y_fl * scale;
236 for (
int x = 0;
x < resolution_min;
x++) {
237 for (
int y = 0;
y < resolution_min;
y++) {
241 max_ff(0.0f, (1.0f - square_f(((len_v3v3(v, center) / scale_fade) + resolution_div) * 2.0f)))
243 const float *v0 = coords[(resolution *
x) +
y];
244 const float *
v1 = coords[(resolution * (
x + 1)) +
y];
245 const float *
v2 = coords[(resolution *
x) + (
y + 1)];
247 const float f0 =
FADE(v0);
248 const float f1 =
FADE(
v1);
249 const float f2 =
FADE(
v2);
251 if (f0 > 0.0f || f1 > 0.0f) {
252 color_fade[3] =
color[3] * f0;
255 color_fade[3] =
color[3] * f1;
259 if (f0 > 0.0f || f2 > 0.0f) {
260 color_fade[3] =
color[3] * f0;
264 color_fade[3] =
color[3] * f2;
286 const int plane_axis,
287 const float matrix[4][4])
301 if (pixel_size > FLT_EPSILON) {
304 float color_alpha = 0.75f;
309 if (relative_pixel_scale < 1.0f) {
316 float view_vector[3];
318 float view_dot =
fabsf(
dot_v3v3(matrix[plane_axis], view_vector));
322 const float scale_mod =
U.gizmo_size * 2 *
U.dpi_fac /
U.pixelsize;
324 float final_scale = (scale_mod * pixel_size);
326 const int lines_subdiv = 10;
327 int lines = lines_subdiv;
329 float final_scale_fade = final_scale;
332 float fac = final_scale_fade / final_scale;
334 float color[4] = {1, 1, 1, color_alpha};
336 if (
color[3] > 0.0f) {
338 lines * lines_subdiv, final_scale, final_scale_fade, matrix, plane_axis,
color);
341 color[3] = color_alpha;
345 final_scale = final_scale_fade;
370 const float loc_prev[3],
371 const float loc_curr[3],
373 const uchar color_line[4],
374 const uchar color_point[4],
377 if (!loc_prev && !loc_curr) {
381 float view_inv[4][4];
409 float vx[3], vy[3],
v1[3],
v2[3], v3[3], v4[4];
442 float viewport_size[4];
444 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
477 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
497 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
523 const int snap_on = data_intern->
snap_on;
531 if (kmi->propvalue == snap_on) {
553 if (!snap_elements) {
556 return snap_elements;
576 if (
state->snap_state.draw_plane ||
state->snap_state.draw_box) {
600 float co[3], no[3], face_nor[3], obmat[4][4], omat[3][3];
603 int snap_elem_index[3] = {-1, -1, -1};
606 const float mval_fl[2] = {
x,
y};
611 if (use_surface_nor || use_surface_co) {
621 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
628 if (!calc_plane_omat) {
638 float prev_co[3] = {0.0f};
639 if (
state->prevpoint) {
655 float dist_px = 12.0f *
U.pixelsize;
664 .snap_target_select = SCE_SNAP_TARGET_ALL,
665 .edit_mode_type = edit_mode_type,
666 .use_occlusion_test = use_occlusion_test,
680 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
686 if (calc_plane_omat) {
689 if (orient_surface) {
698 scene, view_layer, v3d, rv3d, ob,
NULL, orient_index, pivot_point, omat);
700 if (
state->use_plane_axis_auto) {
711 if (orient_surface) {
717 "Use of variable `co` without it being computed");
725 if (
dot_v3v3(ray_dir, face_nor) >= 0.0f) {
733 face_nor[
state->plane_axis] = 1.0f;
739 if (!use_surface_co) {
747 const float *plane_normal = omat[
state->plane_axis];
752 if (do_plane_isect) {
758 if (!do_plane_isect) {
767 snap_elem_index[0] = index;
771 snap_elem_index[1] = index;
774 snap_elem_index[2] = index;
828 if (
state->gzgrp_type) {
858 const bool draw_plane =
state->draw_plane ||
state->draw_box;
894 if (
state->draw_box) {
918 if (!data_intern->
handle) {
923 #ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
941 if (data_intern->
handle) {
969 if (!data_intern->
handle) {
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
General operations, lookup, etc. for blender objects.
int BKE_scene_orientation_get_index(struct Scene *scene, int slot_index)
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
#define BLI_assert_msg(a, msg)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE int mod_i(int i, int n)
MINLINE float square_f(float a)
float ceil_power_of_10(float f)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void unit_m3(float m[3][3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void orthogonalize_m3(float R[3][3], int axis)
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void normalize_m3(float R[3][3]) ATTR_NONNULL()
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])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
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 bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3_int(int r[3], const int a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
struct Depsgraph Depsgraph
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
Object is a sort of wrapper for general info.
#define OBACT(_view_layer)
@ SCE_SNAP_MODE_EDGE_MIDPOINT
@ SCE_SNAP_MODE_INCREMENT
@ SCE_SNAP_MODE_FACE_RAYCAST
@ SCE_SNAP_MODE_EDGE_PERPENDICULAR
bool ED_region_overlap_isect_xy(const ARegion *region, const int event_xy[2])
SnapObjectContext * ED_transform_snap_object_context_create(struct Scene *scene, int flag)
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
eSnapMode ED_transform_snap_object_project_view3d_ex(struct SnapObjectContext *sctx, struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const eSnapMode snap_to, const struct 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], int *r_index, struct Object **r_ob, float r_obmat[4][4], float r_face_nor[3])
@ V3D_PLACE_ORIENT_SURFACE
bool ED_view3d_win_to_3d_on_plane(const struct ARegion *region, const float plane[4], const float mval[2], bool do_clip, float r_out[3])
float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3])
@ V3D_SNAPCURSOR_SNAP_EDIT_GEOM_FINAL
@ V3D_SNAPCURSOR_TOGGLE_ALWAYS_TRUE
@ V3D_SNAPCURSOR_OCCLUSION_ALWAYS_TRUE
@ V3D_SNAPCURSOR_SNAP_EDIT_GEOM_CAGE
void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3])
float ED_view3d_grid_view_scale(struct Scene *scene, struct View3D *v3d, struct ARegion *region, const char **r_grid_unit)
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])
@ V3D_PLACE_DEPTH_CURSOR_VIEW
@ V3D_PLACE_DEPTH_SURFACE
NSNotificationCenter * center
_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 y
_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
#define GPU_matrix_set(x)
#define GPU_matrix_mul(x)
#define GPU_matrix_projection_set(x)
@ GPU_SHADER_3D_SMOOTH_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
void GPU_viewport_size_get_f(float coords[4])
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
float UI_GetThemeValuef(int colorid)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
IconTextureDrawCall normal
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
static CursorSnapshot cursor_snap
bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value)
struct wmGizmoMap * gizmo_map
struct ToolSettings * toolsettings
V3DSnapCursorState state_default
struct wmPaintCursor * handle
V3DSnapCursorData snap_data
struct SnapObjectContext * snap_context_v3d
eSnapMode snap_elem_hidden
struct SnapCursorDataIntern::@560 last_eventstate
struct SnapStateIntern * prev
V3DSnapCursorState snap_state
struct SnapStateIntern * next
struct wmGizmoGroupType * gzgrp_type
eSnapMode snap_elem_force
struct wmWindow * winactive
struct wmEvent * eventstate
static bool v3d_cursor_snap_calc_incremental(Scene *scene, View3D *v3d, ARegion *region, const float co_relative[3], float co[3])
void ED_view3d_cursor_snap_data_update(V3DSnapCursorState *state, const bContext *C, const int x, const int y)
static void v3d_cursor_eventstate_save_xy(SnapCursorDataIntern *cursor_snap, const int x, const int y)
void ED_view3d_cursor_snap_state_default_set(V3DSnapCursorState *state)
void ED_view3d_cursor_snap_prevpoint_set(V3DSnapCursorState *state, const float prev_point[3])
static void v3d_cursor_eventstate_save_modifier(SnapCursorDataIntern *data_intern, const wmWindowManager *wm)
struct SnapStateIntern SnapStateIntern
static void v3d_cursor_snap_activate(void)
static const float eps_view_align
static bool v3d_cursor_snap_calc_plane(void)
static void cursor_box_draw(const float dimensions[3], uchar color[4])
static void v3d_cursor_snap_update(V3DSnapCursorState *state, const bContext *C, wmWindowManager *wm, Depsgraph *depsgraph, Scene *scene, ARegion *region, View3D *v3d, int x, int y)
static void v3d_cursor_poject_surface_normal(const float normal[3], const float obmat[4][4], float r_mat[3][3])
static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(customdata))
#define STATE_INTERN_GET(state)
static void v3d_cursor_plane_draw(const RegionView3D *rv3d, const int plane_axis, const float matrix[4][4])
static bool v3d_cursor_eventstate_has_changed(SnapCursorDataIntern *data_intern, V3DSnapCursorState *state, const wmWindowManager *wm, const int x, const int y)
static SnapCursorDataIntern g_data_intern
struct SnapCursorDataIntern SnapCursorDataIntern
static bool mat3_align_axis_to_v3(float mat[3][3], const int axis_align, const float v[3])
static eSnapMode v3d_cursor_snap_elements(V3DSnapCursorState *snap_state, Scene *scene)
static bool v3d_cursor_snap_poll_fn(bContext *C)
static void v3d_cursor_snap_context_ensure(Scene *scene)
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)
static void v3d_cursor_snap_free(void)
V3DSnapCursorData * ED_view3d_cursor_snap_data_get()
void ED_view3d_cursor_snap_deactive(V3DSnapCursorState *state)
V3DSnapCursorState * ED_view3d_cursor_snap_active(void)
static void v3d_cursor_plane_draw_grid(const int resolution, const float scale, const float scale_fade, const float matrix[4][4], const int plane_axis, const float color[4])
V3DSnapCursorState * ED_view3d_cursor_snap_state_get(void)
static bool v3d_cursor_is_snap_invert(SnapCursorDataIntern *data_intern, const wmWindowManager *wm)
struct SnapObjectContext * ED_view3d_cursor_snap_context_ensure(Scene *scene)
wmGizmoGroup * WM_gizmomap_group_find_ptr(struct wmGizmoMap *gzmap, const struct wmGizmoGroupType *gzgt)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
wmKeyMap * WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
bool WM_paint_cursor_end(wmPaintCursor *handle)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)
void wmViewport(const rcti *winrct)
void wmWindowViewport(wmWindow *win)