Merge branch 'blender-v4.3-release'
This commit is contained in:
@@ -7486,6 +7486,9 @@ class VIEW3D_PT_snapping(Panel):
|
||||
|
||||
col.separator()
|
||||
|
||||
if 'INCREMENT' in tool_settings.snap_elements:
|
||||
col.prop(tool_settings, "use_snap_grid_absolute")
|
||||
|
||||
if 'VOLUME' in tool_settings.snap_elements:
|
||||
col.prop(tool_settings, "use_snap_peel_object")
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ struct TranslateCustomData {
|
||||
struct {
|
||||
enum eTranslateRotateMode rotate_mode;
|
||||
} prev;
|
||||
|
||||
float3 snap_target_grid;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -379,6 +381,49 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
|
||||
sub_v3_v3v3(vec, point, t->tsnap.snap_source);
|
||||
}
|
||||
}
|
||||
static void translate_snap_increment_init(const TransInfo *t)
|
||||
{
|
||||
if ((!t->tsnap.flag & SCE_SNAP_ABS_GRID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TranslateCustomData *custom_data = static_cast<TranslateCustomData *>(t->custom.mode.data);
|
||||
if (t->data_type == &TransConvertType_Cursor3D) {
|
||||
/* Use a fallback when transforming the cursor.
|
||||
* In this case the center is _not_ derived from the cursor which is being transformed. */
|
||||
custom_data->snap_target_grid = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->data->iloc;
|
||||
}
|
||||
else if (t->around == V3D_AROUND_CURSOR) {
|
||||
/* Use a fallback for cursor selection,
|
||||
* this isn't useful as a global center for absolute grid snapping
|
||||
* since its not based on the position of the selection. */
|
||||
tranform_snap_target_median_calc(t, custom_data->snap_target_grid);
|
||||
}
|
||||
else {
|
||||
custom_data->snap_target_grid = t->center_global;
|
||||
}
|
||||
}
|
||||
|
||||
static bool translate_snap_increment(const TransInfo *t, float *r_val)
|
||||
{
|
||||
if (!transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, r_val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t->tsnap.flag & SCE_SNAP_ABS_GRID) {
|
||||
TranslateCustomData *custom_data = static_cast<TranslateCustomData *>(t->custom.mode.data);
|
||||
|
||||
float3 absolute_grid_snap_offset = custom_data->snap_target_grid;
|
||||
transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, absolute_grid_snap_offset);
|
||||
absolute_grid_snap_offset -= custom_data->snap_target_grid;
|
||||
add_v3_v3(r_val, absolute_grid_snap_offset);
|
||||
|
||||
if (t->con.mode & CON_APPLY) {
|
||||
t->con.applyVec(t, nullptr, nullptr, r_val, r_val);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -536,9 +581,7 @@ static void applyTranslation(TransInfo *t)
|
||||
|
||||
float incr_dir[3];
|
||||
copy_v3_v3(incr_dir, global_dir);
|
||||
if (!(transform_snap_is_active(t) && validSnap(t)) &&
|
||||
transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, incr_dir))
|
||||
{
|
||||
if (!(transform_snap_is_active(t) && validSnap(t)) && translate_snap_increment(t, incr_dir)) {
|
||||
|
||||
/* Test for mixed snap with grid. */
|
||||
float snap_dist_sq = FLT_MAX;
|
||||
@@ -622,6 +665,8 @@ static void initTranslation(TransInfo *t, wmOperator * /*op*/)
|
||||
custom_data->prev.rotate_mode = TRANSLATE_ROTATE_OFF;
|
||||
t->custom.mode.data = custom_data;
|
||||
t->custom.mode.use_free = true;
|
||||
|
||||
translate_snap_increment_init(t);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -2408,7 +2408,7 @@ typedef enum eSnapFlag {
|
||||
// SCE_SNAP_PROJECT = (1 << 3), /* DEPRECATED, see #SCE_SNAP_INDIVIDUAL_PROJECT. */
|
||||
/** Was `SCE_SNAP_NO_SELF`, but self should be active. */
|
||||
SCE_SNAP_NOT_TO_ACTIVE = (1 << 4),
|
||||
/* SCE_SNAP_ABS_GRID = (1 << 5), */ /* UNUSED */
|
||||
SCE_SNAP_ABS_GRID = (1 << 5),
|
||||
/* Same value with different name to make it easier to understand in time based code. */
|
||||
SCE_SNAP_ABS_TIME_STEP = (1 << 5),
|
||||
SCE_SNAP_BACKFACE_CULLING = (1 << 6),
|
||||
|
||||
@@ -3543,6 +3543,15 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
prop, "Align Rotation to Target", "Align rotation with the snapping target");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
|
||||
|
||||
prop = RNA_def_property(srna, "use_snap_grid_absolute", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "snap_flag", SCE_SNAP_ABS_GRID);
|
||||
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Absolute Increment Snap",
|
||||
"Absolute grid alignment while translating (based on the pivot center)");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
|
||||
|
||||
prop = RNA_def_property(srna, "snap_angle_increment_2d", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "snap_angle_increment_2d");
|
||||
RNA_def_property_ui_text(
|
||||
|
||||
Reference in New Issue
Block a user