WIP: Visualize snapping type by showing different symbols #107054
|
@ -27,7 +27,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 7
|
||||
#define BLENDER_FILE_SUBVERSION 8
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
|
|
@ -4472,7 +4472,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
if (!MAIN_VERSION_ATLEAST(bmain, 306, 10)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
/* Set default values for new members. */
|
||||
scene->toolsettings->snap_mode_tools = SCE_SNAP_TO_GEOM;
|
||||
short snap_mode_geom = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 4) | (1 << 5);
|
||||
scene->toolsettings->snap_mode_tools = snap_mode_geom;
|
||||
scene->toolsettings->plane_axis = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "DNA_defaults.h"
|
||||
#include "DNA_lightprobe_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_movieclip_types.h"
|
||||
|
@ -256,6 +257,50 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 400, 8)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
auto versioning_snap_to = [](short snap_to_old, bool is_node = false) {
|
||||
short snap_to_new = SCE_SNAP_TO_NONE;
|
||||
if (snap_to_old & (1 << 0)) {
|
||||
snap_to_new |= is_node ? SCE_SNAP_TO_NODE_X : SCE_SNAP_TO_VERTEX;
|
||||
}
|
||||
if (snap_to_old & (1 << 1)) {
|
||||
snap_to_new |= is_node ? SCE_SNAP_TO_NODE_Y : SCE_SNAP_TO_EDGE;
|
||||
}
|
||||
if (snap_to_old & (1 << 2)) {
|
||||
snap_to_new |= SCE_SNAP_TO_FACE;
|
||||
}
|
||||
if (snap_to_old & (1 << 3)) {
|
||||
snap_to_new |= SCE_SNAP_TO_VOLUME;
|
||||
}
|
||||
if (snap_to_old & (1 << 4)) {
|
||||
snap_to_new |= SCE_SNAP_TO_EDGE_MIDPOINT;
|
||||
}
|
||||
if (snap_to_old & (1 << 5)) {
|
||||
snap_to_new |= SCE_SNAP_TO_EDGE_PERPENDICULAR;
|
||||
}
|
||||
if (snap_to_old & (1 << 6)) {
|
||||
snap_to_new |= SCE_SNAP_TO_INCREMENT;
|
||||
}
|
||||
if (snap_to_old & (1 << 7)) {
|
||||
snap_to_new |= SCE_SNAP_TO_GRID;
|
||||
}
|
||||
if (snap_to_old & (1 << 8)) {
|
||||
snap_to_new |= SCE_SNAP_INDIVIDUAL_PROJECT;
|
||||
}
|
||||
if (snap_to_old & (1 << 9)) {
|
||||
snap_to_new |= SCE_SNAP_INDIVIDUAL_NEAREST;
|
||||
}
|
||||
return snap_to_new;
|
||||
};
|
||||
|
||||
ts->snap_mode = versioning_snap_to(ts->snap_mode);
|
||||
ts->snap_uv_mode = versioning_snap_to(ts->snap_uv_mode);
|
||||
ts->snap_node_mode = versioning_snap_to(ts->snap_node_mode, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
|
|
@ -96,7 +96,7 @@ void ED_gizmotypes_snap_3d_data_get(const bContext *C,
|
|||
copy_v3_v3_int(r_elem_index, snap_data->elem_index);
|
||||
}
|
||||
if (r_snap_elem) {
|
||||
*r_snap_elem = snap_data->snap_elem;
|
||||
*r_snap_elem = snap_data->type_target;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +171,21 @@ static void gizmo_snap_rna_snap_elem_index_get_fn(PointerRNA *UNUSED(ptr),
|
|||
copy_v3_v3_int(values, snap_data->elem_index);
|
||||
}
|
||||
|
||||
static int gizmo_snap_rna_snap_srouce_type_get_fn(PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorData *snap_data = ED_view3d_cursor_snap_data_get();
|
||||
return (int)snap_data->type_source;
|
||||
}
|
||||
|
||||
static void gizmo_snap_rna_snap_srouce_type_set_fn(PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
const int value)
|
||||
{
|
||||
V3DSnapCursorData *snap_data = ED_view3d_cursor_snap_data_get();
|
||||
snap_data->type_source = (eSnapMode)value;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -266,7 +281,7 @@ static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
|||
ED_view3d_cursor_snap_data_update(snap_gizmo->snap_state, C, x, y);
|
||||
V3DSnapCursorData *snap_data = ED_view3d_cursor_snap_data_get();
|
||||
|
||||
if (snap_data->snap_elem != SCE_SNAP_TO_NONE) {
|
||||
if (snap_data->type_target != SCE_SNAP_TO_NONE) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
|
@ -373,6 +388,15 @@ static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
|
|||
INT_MAX);
|
||||
RNA_def_property_int_array_funcs_runtime(
|
||||
prop, gizmo_snap_rna_snap_elem_index_get_fn, NULL, NULL);
|
||||
|
||||
prop = RNA_def_enum(gzt->srna,
|
||||
"snap_source_type",
|
||||
rna_enum_snap_element_items,
|
||||
SCE_SNAP_TO_NONE,
|
||||
"Snap Source Type",
|
||||
"Snap Source type (influences drawing)");
|
||||
RNA_def_property_enum_funcs_runtime(
|
||||
prop, gizmo_snap_rna_snap_srouce_type_get_fn, gizmo_snap_rna_snap_srouce_type_set_fn, NULL);
|
||||
}
|
||||
|
||||
void ED_gizmotypes_snap_3d(void)
|
||||
|
|
|
@ -307,7 +307,8 @@ typedef enum {
|
|||
} eV3DSnapCursor;
|
||||
|
||||
typedef struct V3DSnapCursorData {
|
||||
eSnapMode snap_elem;
|
||||
eSnapMode type_source;
|
||||
eSnapMode type_target;
|
||||
float loc[3];
|
||||
float nor[3];
|
||||
float obmat[4][4];
|
||||
|
@ -352,9 +353,10 @@ void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d,
|
|||
const float source_loc[3],
|
||||
const float target_loc[3],
|
||||
const float target_normal[3],
|
||||
const eSnapMode source_type,
|
||||
const eSnapMode target_type,
|
||||
const uchar source_color[4],
|
||||
const uchar target_color[4],
|
||||
const eSnapMode target_type);
|
||||
const uchar target_color[4]);
|
||||
|
||||
/* view3d_iterators.cc */
|
||||
|
||||
|
|
|
@ -25,12 +25,14 @@
|
|||
|
||||
#include "GPU_immediate.h"
|
||||
#include "GPU_matrix.h"
|
||||
#include "GPU_state.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_transform.h"
|
||||
#include "ED_transform_snap_object_context.h"
|
||||
#include "ED_view3d.h"
|
||||
|
||||
#include "UI_interface_icons.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
@ -366,33 +368,110 @@ static void cursor_box_draw(const float dimensions[3], uchar color[4])
|
|||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
|
||||
static void cursor_point_draw(
|
||||
uint attr_pos, const float loc[3], const float size, eSnapMode snap_type, const uchar color[4])
|
||||
{
|
||||
immUniformColor4ubv(color);
|
||||
|
||||
GPU_matrix_push();
|
||||
|
||||
float model_view_new[4][4];
|
||||
GPU_matrix_model_view_get(model_view_new);
|
||||
translate_m4(model_view_new, UNPACK3(loc));
|
||||
copy_v3_fl3(model_view_new[0], size, 0.0f, 0.0f);
|
||||
copy_v3_fl3(model_view_new[1], 0.0f, size, 0.0f);
|
||||
copy_v3_fl3(model_view_new[2], 0.0f, 0.0f, size);
|
||||
GPU_matrix_set(model_view_new);
|
||||
|
||||
float size_b = 1.0f;
|
||||
switch (snap_type) {
|
||||
case SCE_SNAP_TO_POINT:
|
||||
imm_draw_circle_wire_3d(attr_pos, 0.0f, 0.0f, 1.0f, 24);
|
||||
|
||||
immBegin(GPU_PRIM_LINES, 4);
|
||||
immVertex3f(attr_pos, -size_b, -size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, -size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, -size_b, 0.0f);
|
||||
immEnd();
|
||||
break;
|
||||
case SCE_SNAP_TO_EDGE_ENDPOINT:
|
||||
immBegin(GPU_PRIM_LINE_LOOP, 4);
|
||||
immVertex3f(attr_pos, -size_b, -size_b, 0.0f);
|
||||
immVertex3f(attr_pos, -size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, -size_b, 0.0f);
|
||||
immEnd();
|
||||
break;
|
||||
case SCE_SNAP_TO_EDGE_MIDPOINT:
|
||||
immBegin(GPU_PRIM_LINE_LOOP, 3);
|
||||
immVertex3f(attr_pos, -size_b, -size_b, 0.0f);
|
||||
immVertex3f(attr_pos, 0.0f, 0.866f * size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, -size_b, 0.0f);
|
||||
immEnd();
|
||||
break;
|
||||
case SCE_SNAP_TO_EDGE_PERPENDICULAR:
|
||||
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
||||
immVertex3f(attr_pos, -size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, -size_b, -size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, -size_b, 0.0f);
|
||||
immEnd();
|
||||
|
||||
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
||||
immVertex3f(attr_pos, -size_b, 0.0f, 0.0f);
|
||||
immVertex3f(attr_pos, 0.0f, 0.0f, 0.0f);
|
||||
immVertex3f(attr_pos, 0.0f, -size_b, 0.0f);
|
||||
immEnd();
|
||||
break;
|
||||
case SCE_SNAP_TO_EDGE:
|
||||
immBegin(GPU_PRIM_LINE_LOOP, 4);
|
||||
immVertex3f(attr_pos, -size_b, -size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, -size_b, +size_b, 0.0f);
|
||||
immVertex3f(attr_pos, +size_b, -size_b, 0.0f);
|
||||
immEnd();
|
||||
break;
|
||||
case SCE_SNAP_TO_FACE:
|
||||
default:
|
||||
imm_draw_circle_wire_3d(attr_pos, 0.0f, 0.0f, 1.0f, 24);
|
||||
break;
|
||||
}
|
||||
|
||||
GPU_matrix_pop();
|
||||
}
|
||||
|
||||
void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d,
|
||||
const float source_loc[3],
|
||||
const float target_loc[3],
|
||||
const float target_normal[3],
|
||||
const eSnapMode source_type,
|
||||
const eSnapMode target_type,
|
||||
const uchar source_color[4],
|
||||
const uchar target_color[4],
|
||||
const eSnapMode target_type)
|
||||
const uchar target_color[4])
|
||||
{
|
||||
if (!source_loc && !target_loc) {
|
||||
return;
|
||||
}
|
||||
|
||||
float view_inv[4][4];
|
||||
copy_m4_m4(view_inv, rv3d->viewinv);
|
||||
|
||||
/* The size of the circle is larger than the vertex size.
|
||||
* This prevents a drawing overlaps the other. */
|
||||
/* The size of the symbol is larger than the vertex size.
|
||||
* This prevents overlaps. */
|
||||
float radius = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
GPU_line_smooth(true);
|
||||
GPU_line_width(1.5f);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
if (target_loc) {
|
||||
immUniformColor4ubv(target_color);
|
||||
imm_drawcircball(target_loc, ED_view3d_pixel_size(rv3d, target_loc) * radius, view_inv, pos);
|
||||
|
||||
/* draw normal if needed */
|
||||
cursor_point_draw(pos,
|
||||
target_loc,
|
||||
radius * ED_view3d_pixel_size(rv3d, target_loc),
|
||||
target_type,
|
||||
target_color);
|
||||
|
||||
/* Draw normal if needed. */
|
||||
if (target_normal) {
|
||||
immBegin(GPU_PRIM_LINES, 2);
|
||||
immVertex3fv(pos, target_loc);
|
||||
|
@ -405,37 +484,11 @@ void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d,
|
|||
}
|
||||
|
||||
if (source_loc) {
|
||||
/* Draw an "X" indicating where the previous snap point is.
|
||||
* This is useful for indicating perpendicular snap. */
|
||||
|
||||
/* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */
|
||||
float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4];
|
||||
|
||||
/* Multiply by 0.75f so that the final size of the "X" is close to that of
|
||||
* the circle.
|
||||
* (A closer value is 0.7071f, but we don't need to be exact here). */
|
||||
float x_size = 0.75f * radius * ED_view3d_pixel_size(rv3d, source_loc);
|
||||
|
||||
mul_v3_v3fl(vx, view_inv[0], x_size);
|
||||
mul_v3_v3fl(vy, view_inv[1], x_size);
|
||||
|
||||
add_v3_v3v3(v1, vx, vy);
|
||||
sub_v3_v3v3(v2, vx, vy);
|
||||
negate_v3_v3(v3, v1);
|
||||
negate_v3_v3(v4, v2);
|
||||
|
||||
add_v3_v3(v1, source_loc);
|
||||
add_v3_v3(v2, source_loc);
|
||||
add_v3_v3(v3, source_loc);
|
||||
add_v3_v3(v4, source_loc);
|
||||
|
||||
immUniformColor4ubv(source_color);
|
||||
immBegin(GPU_PRIM_LINES, 4);
|
||||
immVertex3fv(pos, v3);
|
||||
immVertex3fv(pos, v1);
|
||||
immVertex3fv(pos, v4);
|
||||
immVertex3fv(pos, v2);
|
||||
immEnd();
|
||||
cursor_point_draw(pos,
|
||||
source_loc,
|
||||
radius * ED_view3d_pixel_size(rv3d, source_loc),
|
||||
source_type,
|
||||
source_color);
|
||||
|
||||
if (target_loc && (target_type & SCE_SNAP_TO_EDGE_PERPENDICULAR)) {
|
||||
/* Dashed line. */
|
||||
|
@ -456,6 +509,8 @@ void ED_view3d_cursor_snap_draw_util(RegionView3D *rv3d,
|
|||
}
|
||||
}
|
||||
|
||||
GPU_line_smooth(false);
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
@ -553,8 +608,11 @@ static bool v3d_cursor_is_snap_invert(SnapCursorDataIntern *data_intern, const w
|
|||
|
||||
static eSnapMode v3d_cursor_snap_elements(ToolSettings *tool_settings)
|
||||
{
|
||||
return tool_settings->snap_mode_tools == SCE_SNAP_TO_NONE ? tool_settings->snap_mode :
|
||||
tool_settings->snap_mode_tools;
|
||||
eSnapMode snap_mode = tool_settings->snap_mode & SCE_SNAP_TO_GEOM;
|
||||
if (snap_mode == SCE_SNAP_TO_NONE) {
|
||||
snap_mode = SCE_SNAP_TO_GEOM;
|
||||
}
|
||||
return snap_mode;
|
||||
}
|
||||
|
||||
static void v3d_cursor_snap_context_ensure(Scene *scene)
|
||||
|
@ -628,7 +686,7 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
|||
if (snap_data->is_snap_invert != !(ts->snap_flag & SCE_SNAP)) {
|
||||
snap_data->is_enabled = false;
|
||||
if (!calc_plane_omat) {
|
||||
snap_data->snap_elem = SCE_SNAP_TO_NONE;
|
||||
snap_data->type_target = SCE_SNAP_TO_NONE;
|
||||
return;
|
||||
}
|
||||
snap_elements = data_intern->snap_elem_hidden = SCE_SNAP_TO_FACE;
|
||||
|
@ -766,7 +824,7 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
|||
v3d_cursor_snap_calc_incremental(scene, v3d, region, state->prevpoint, co);
|
||||
}
|
||||
}
|
||||
else if (snap_elem == SCE_SNAP_TO_VERTEX) {
|
||||
else if (snap_elem & SCE_SNAP_TO_VERTEX) {
|
||||
snap_elem_index[0] = index;
|
||||
}
|
||||
else if (snap_elem &
|
||||
|
@ -778,7 +836,7 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
|||
snap_elem_index[2] = index;
|
||||
}
|
||||
|
||||
snap_data->snap_elem = snap_elem;
|
||||
snap_data->type_target = snap_elem;
|
||||
copy_v3_v3(snap_data->loc, co);
|
||||
copy_v3_v3(snap_data->nor, no);
|
||||
copy_m4_m4(snap_data->obmat, obmat);
|
||||
|
@ -856,7 +914,7 @@ static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(cust
|
|||
}
|
||||
|
||||
const bool draw_plane = state->draw_plane || state->draw_box;
|
||||
if (snap_data->snap_elem == SCE_SNAP_TO_NONE && !draw_plane) {
|
||||
if (snap_data->type_target == SCE_SNAP_TO_NONE && !draw_plane) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -874,21 +932,19 @@ static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(cust
|
|||
v3d_cursor_plane_draw(rv3d, scene->toolsettings->plane_axis, matrix);
|
||||
}
|
||||
|
||||
if (snap_data->snap_elem != SCE_SNAP_TO_NONE && (state->draw_point || state->draw_box)) {
|
||||
const float *prev_point = (snap_data->snap_elem & SCE_SNAP_TO_EDGE_PERPENDICULAR) ?
|
||||
if (snap_data->type_target != SCE_SNAP_TO_NONE && (state->draw_point || state->draw_box)) {
|
||||
const float *source_loc = (snap_data->type_target & SCE_SNAP_TO_EDGE_PERPENDICULAR) ?
|
||||
state->prevpoint :
|
||||
NULL;
|
||||
|
||||
GPU_line_smooth(false);
|
||||
GPU_line_width(1.0f);
|
||||
|
||||
ED_view3d_cursor_snap_draw_util(rv3d,
|
||||
prev_point,
|
||||
source_loc,
|
||||
snap_data->loc,
|
||||
NULL,
|
||||
snap_data->type_source,
|
||||
snap_data->type_target,
|
||||
state->source_color,
|
||||
state->target_color,
|
||||
snap_data->snap_elem);
|
||||
state->target_color);
|
||||
}
|
||||
|
||||
if (state->draw_box) {
|
||||
|
|
|
@ -154,6 +154,7 @@ struct RulerInfo {
|
|||
struct {
|
||||
wmGizmo *gizmo;
|
||||
PropertyRNA *prop_prevpoint;
|
||||
PropertyRNA *prop_snap_source_type;
|
||||
} snap_data;
|
||||
};
|
||||
|
||||
|
@ -165,6 +166,7 @@ struct RulerItem {
|
|||
|
||||
/** World-space coords, middle being optional. */
|
||||
float3x3 co;
|
||||
eSnapMode snap_type[3];
|
||||
|
||||
int flag;
|
||||
int raycast_dir; /* RULER_DIRECTION_* */
|
||||
|
@ -356,6 +358,7 @@ static bool view3d_ruler_item_mousemove(const bContext *C,
|
|||
if (ruler_item) {
|
||||
RulerInteraction *inter = static_cast<RulerInteraction *>(ruler_item->gz.interaction_data);
|
||||
float3 &co = ruler_item->co[inter->co_index];
|
||||
eSnapMode *snap_source_type = &ruler_item->snap_type[inter->co_index];
|
||||
/* restore the initial depth */
|
||||
co = inter->drag_start_co;
|
||||
view3d_ruler_item_project(ruler_info, co, mval);
|
||||
|
@ -402,25 +405,31 @@ static bool view3d_ruler_item_mousemove(const bContext *C,
|
|||
View3D *v3d = static_cast<View3D *>(ruler_info->area->spacedata.first);
|
||||
if (do_snap) {
|
||||
float3 *prev_point = nullptr;
|
||||
eSnapMode snap_type;
|
||||
BLI_assert(ED_gizmotypes_snap_3d_is_enabled(snap_gizmo));
|
||||
|
||||
if (inter->co_index != 1) {
|
||||
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
|
||||
prev_point = &ruler_item->co[1];
|
||||
snap_type = ruler_item->snap_type[1];
|
||||
}
|
||||
else if (inter->co_index == 0) {
|
||||
prev_point = &ruler_item->co[2];
|
||||
snap_type = ruler_item->snap_type[2];
|
||||
}
|
||||
else {
|
||||
prev_point = &ruler_item->co[0];
|
||||
snap_type = ruler_item->snap_type[0];
|
||||
}
|
||||
}
|
||||
if (prev_point != nullptr) {
|
||||
RNA_property_float_set_array(
|
||||
snap_gizmo->ptr, ruler_info->snap_data.prop_prevpoint, *prev_point);
|
||||
RNA_property_enum_set(
|
||||
snap_gizmo->ptr, ruler_info->snap_data.prop_snap_source_type, snap_type);
|
||||
}
|
||||
|
||||
ED_gizmotypes_snap_3d_data_get(C, snap_gizmo, co, nullptr, nullptr, nullptr);
|
||||
ED_gizmotypes_snap_3d_data_get(C, snap_gizmo, co, nullptr, nullptr, snap_source_type);
|
||||
}
|
||||
|
||||
#ifdef USE_AXIS_CONSTRAINTS
|
||||
|
@ -1154,19 +1163,26 @@ static int gizmo_ruler_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
|
|||
{
|
||||
/* Set Snap prev point. */
|
||||
float3 *prev_point;
|
||||
eSnapMode snap_type;
|
||||
if (ruler_item_pick->flag & RULERITEM_USE_ANGLE) {
|
||||
prev_point = (inter->co_index != 1) ? &ruler_item_pick->co[1] : nullptr;
|
||||
snap_type = (inter->co_index != 1) ? ruler_item_pick->snap_type[1] : SCE_SNAP_TO_VERTEX;
|
||||
}
|
||||
else if (inter->co_index == 0) {
|
||||
prev_point = &ruler_item_pick->co[2];
|
||||
snap_type = ruler_item_pick->snap_type[2];
|
||||
}
|
||||
else {
|
||||
prev_point = &ruler_item_pick->co[0];
|
||||
snap_type = ruler_item_pick->snap_type[2];
|
||||
}
|
||||
|
||||
if (prev_point) {
|
||||
RNA_property_float_set_array(
|
||||
ruler_info->snap_data.gizmo->ptr, ruler_info->snap_data.prop_prevpoint, *prev_point);
|
||||
RNA_property_enum_set(ruler_info->snap_data.gizmo->ptr,
|
||||
ruler_info->snap_data.prop_snap_source_type,
|
||||
snap_type);
|
||||
}
|
||||
else {
|
||||
RNA_property_unset(ruler_info->snap_data.gizmo->ptr, ruler_info->snap_data.prop_prevpoint);
|
||||
|
@ -1260,6 +1276,8 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup)
|
|||
ruler_info->region = region;
|
||||
ruler_info->snap_data.gizmo = gizmo;
|
||||
ruler_info->snap_data.prop_prevpoint = RNA_struct_find_property(gizmo->ptr, "prev_point");
|
||||
ruler_info->snap_data.prop_snap_source_type = RNA_struct_find_property(gizmo->ptr,
|
||||
"snap_source_type");
|
||||
|
||||
gzgroup->customdata = ruler_info;
|
||||
}
|
||||
|
@ -1342,6 +1360,9 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
|||
RNA_property_float_set_array(ruler_info->snap_data.gizmo->ptr,
|
||||
ruler_info->snap_data.prop_prevpoint,
|
||||
inter->drag_start_co);
|
||||
RNA_property_enum_set(ruler_info->snap_data.gizmo->ptr,
|
||||
ruler_info->snap_data.prop_snap_source_type,
|
||||
ruler_item->snap_type[inter->co_index]);
|
||||
|
||||
copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
|
||||
ruler_item->gz.highlight_part = inter->co_index = 2;
|
||||
|
|
|
@ -690,7 +690,7 @@ static bool view3d_interactive_add_calc_snap(bContext *UNUSED(C),
|
|||
if (r_is_snap_invert) {
|
||||
*r_is_snap_invert = snap_data->is_snap_invert;
|
||||
}
|
||||
return snap_data->snap_elem != SCE_SNAP_TO_NONE;
|
||||
return snap_data->type_target != SCE_SNAP_TO_NONE;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -302,6 +302,7 @@ typedef struct TransSnap {
|
|||
short face_nearest_steps;
|
||||
eTSnap status;
|
||||
/* Snapped Element Type (currently for objects only). */
|
||||
eSnapMode source_type;
|
||||
eSnapMode target_type;
|
||||
/** snapping from this point (in global-space). */
|
||||
float snap_source[3];
|
||||
|
|
|
@ -74,6 +74,7 @@ static void snapsource_confirm(TransInfo *t)
|
|||
BLI_assert(t->modifiers & MOD_EDIT_SNAP_SOURCE);
|
||||
getSnapPoint(t, t->tsnap.snap_source);
|
||||
t->tsnap.snap_source_fn = NULL;
|
||||
t->tsnap.source_type = t->tsnap.target_type;
|
||||
t->tsnap.status |= SNAP_SOURCE_FOUND;
|
||||
|
||||
struct SnapSouceCustomData *customdata = t->custom.mode.data;
|
||||
|
|
|
@ -245,8 +245,14 @@ void drawSnapping(const bContext *C, TransInfo *t)
|
|||
target_loc = t->tsnap.snap_target;
|
||||
}
|
||||
|
||||
ED_view3d_cursor_snap_draw_util(
|
||||
rv3d, source_loc, target_loc, target_normal, col, activeCol, t->tsnap.target_type);
|
||||
ED_view3d_cursor_snap_draw_util(rv3d,
|
||||
source_loc,
|
||||
target_loc,
|
||||
target_normal,
|
||||
t->tsnap.source_type,
|
||||
t->tsnap.target_type,
|
||||
col,
|
||||
activeCol);
|
||||
|
||||
GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
|
||||
}
|
||||
|
@ -544,6 +550,7 @@ void transform_snap_mixed_apply(TransInfo *t, float *vec)
|
|||
void resetSnapping(TransInfo *t)
|
||||
{
|
||||
t->tsnap.status = SNAP_RESETTED;
|
||||
t->tsnap.source_type = SCE_SNAP_TO_NONE;
|
||||
t->tsnap.target_type = SCE_SNAP_TO_NONE;
|
||||
t->tsnap.mode = SCE_SNAP_TO_NONE;
|
||||
t->tsnap.target_operation = SCE_SNAP_TARGET_ALL;
|
||||
|
@ -1259,6 +1266,7 @@ static void snap_source_center_fn(TransInfo *t)
|
|||
TargetSnapOffset(t, nullptr);
|
||||
|
||||
t->tsnap.status |= SNAP_SOURCE_FOUND;
|
||||
t->tsnap.source_type = SCE_SNAP_TO_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1277,7 @@ static void snap_source_active_fn(TransInfo *t)
|
|||
if (calculateCenterActive(t, true, t->tsnap.snap_source)) {
|
||||
TargetSnapOffset(t, nullptr);
|
||||
t->tsnap.status |= SNAP_SOURCE_FOUND;
|
||||
t->tsnap.source_type = SCE_SNAP_TO_NONE;
|
||||
}
|
||||
else {
|
||||
/* No active, default to median, */
|
||||
|
@ -1285,6 +1294,7 @@ static void snap_source_median_fn(TransInfo *t)
|
|||
if ((t->tsnap.status & SNAP_SOURCE_FOUND) == 0) {
|
||||
tranform_snap_target_median_calc(t, t->tsnap.snap_source);
|
||||
t->tsnap.status |= SNAP_SOURCE_FOUND;
|
||||
t->tsnap.source_type = SCE_SNAP_TO_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1375,6 +1385,7 @@ static void snap_source_closest_fn(TransInfo *t)
|
|||
TargetSnapOffset(t, closest);
|
||||
|
||||
t->tsnap.status |= SNAP_SOURCE_FOUND;
|
||||
t->tsnap.source_type = SCE_SNAP_TO_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -864,7 +864,7 @@ eSnapMode snap_object_center(SnapObjectContext *sctx,
|
|||
|
||||
if (nearest2d.snap_point(float3(0.0f))) {
|
||||
nearest2d.register_result(sctx, ob_eval, static_cast<const ID *>(ob_eval->data));
|
||||
return SCE_SNAP_TO_VERTEX;
|
||||
return SCE_SNAP_TO_POINT;
|
||||
}
|
||||
|
||||
return SCE_SNAP_TO_NONE;
|
||||
|
|
|
@ -108,7 +108,7 @@ eSnapMode snapCurve(SnapObjectContext *sctx, Object *ob_eval, const float obmat[
|
|||
}
|
||||
if (has_snap) {
|
||||
nearest2d.register_result(sctx, ob_eval, &cu->id);
|
||||
return SCE_SNAP_TO_VERTEX;
|
||||
return SCE_SNAP_TO_POINT;
|
||||
}
|
||||
return SCE_SNAP_TO_NONE;
|
||||
}
|
||||
|
|
|
@ -2306,20 +2306,18 @@ typedef enum eSnapMode {
|
|||
|
||||
/** #ToolSettings.snap_mode and #ToolSettings.snap_node_mode and #ToolSettings.snap_uv_mode */
|
||||
SCE_SNAP_TO_POINT = (1 << 0),
|
||||
/* Even with the same value, there is a distinction between point and endpoint in the snap code.
|
||||
* Therefore, use different enums for better code readability. */
|
||||
SCE_SNAP_TO_EDGE_ENDPOINT = (1 << 0),
|
||||
SCE_SNAP_TO_EDGE = (1 << 1),
|
||||
SCE_SNAP_TO_FACE = (1 << 2),
|
||||
SCE_SNAP_TO_VOLUME = (1 << 3),
|
||||
SCE_SNAP_TO_EDGE_MIDPOINT = (1 << 4),
|
||||
SCE_SNAP_TO_EDGE_PERPENDICULAR = (1 << 5),
|
||||
SCE_SNAP_TO_INCREMENT = (1 << 6),
|
||||
SCE_SNAP_TO_EDGE_MIDPOINT = (1 << 1),
|
||||
SCE_SNAP_TO_EDGE_ENDPOINT = (1 << 2),
|
||||
SCE_SNAP_TO_EDGE_PERPENDICULAR = (1 << 3),
|
||||
SCE_SNAP_TO_EDGE = (1 << 4),
|
||||
SCE_SNAP_TO_FACE = (1 << 5),
|
||||
SCE_SNAP_TO_VOLUME = (1 << 6),
|
||||
SCE_SNAP_TO_GRID = (1 << 7),
|
||||
SCE_SNAP_TO_INCREMENT = (1 << 8),
|
||||
|
||||
/** For snap individual elements. */
|
||||
SCE_SNAP_INDIVIDUAL_NEAREST = (1 << 8),
|
||||
SCE_SNAP_INDIVIDUAL_PROJECT = (1 << 9),
|
||||
SCE_SNAP_INDIVIDUAL_NEAREST = (1 << 9),
|
||||
SCE_SNAP_INDIVIDUAL_PROJECT = (1 << 10),
|
||||
} eSnapMode;
|
||||
/* Due to dependency conflicts with Cycles, header cannot directly include `BLI_utildefines.h`. */
|
||||
/* TODO: move this macro to a more general place. */
|
||||
|
@ -2330,8 +2328,8 @@ ENUM_OPERATORS(eSnapMode, SCE_SNAP_INDIVIDUAL_PROJECT)
|
|||
#define SCE_SNAP_TO_VERTEX (SCE_SNAP_TO_POINT | SCE_SNAP_TO_EDGE_ENDPOINT)
|
||||
|
||||
#define SCE_SNAP_TO_GEOM \
|
||||
(SCE_SNAP_TO_VERTEX | SCE_SNAP_TO_EDGE | SCE_SNAP_TO_FACE | SCE_SNAP_TO_EDGE_PERPENDICULAR | \
|
||||
SCE_SNAP_TO_EDGE_MIDPOINT)
|
||||
(SCE_SNAP_TO_VERTEX | SCE_SNAP_TO_EDGE | SCE_SNAP_TO_FACE | SCE_SNAP_TO_EDGE_MIDPOINT | \
|
||||
SCE_SNAP_TO_EDGE_PERPENDICULAR)
|
||||
|
||||
/** #SequencerToolSettings.snap_mode */
|
||||
#define SEQ_SNAP_TO_STRIPS (1 << 0)
|
||||
|
|
Loading…
Reference in New Issue