Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c31
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c11
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c30
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c26
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c8
-rw-r--r--source/blender/editors/io/io_usd.c4
-rw-r--r--source/blender/editors/object/object_transform.cc4
-rw-r--r--source/blender/editors/space_image/image_ops.c9
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display_libraries.cc2
9 files changed, 55 insertions, 70 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 8506e90191f..a8fb344f366 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3924,31 +3924,36 @@ static void gpencil_smooth_stroke(bContext *C, wmOperator *op)
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
if (gps->flag & GP_STROKE_SELECT) {
- for (int r = 0; r < repeat; r++) {
+ /* TODO use `BKE_gpencil_stroke_smooth` when the weights are better used. */
+ bGPDstroke gps_old = *gps;
+ gps_old.points = (bGPDspoint *)MEM_dupallocN(gps->points);
+ /* Here the iteration needs to be done outside the smooth functions,
+ * as there are points that don't get smoothed. */
+ for (int n = 0; n < repeat; n++) {
for (int i = 0; i < gps->totpoints; i++) {
- bGPDspoint *pt = &gps->points[i];
- if ((only_selected) && ((pt->flag & GP_SPOINT_SELECT) == 0)) {
+ if (only_selected && (gps->points[i].flag & GP_SPOINT_SELECT) == 0) {
continue;
}
- /* perform smoothing */
+ /* Perform smoothing. */
if (smooth_position) {
- BKE_gpencil_stroke_smooth_point(gps, i, factor, false);
+ BKE_gpencil_stroke_smooth_point(&gps_old, i, factor, 1, false, false, gps);
}
if (smooth_strength) {
- BKE_gpencil_stroke_smooth_strength(gps, i, factor);
+ BKE_gpencil_stroke_smooth_strength(&gps_old, i, factor, 1, gps);
}
if (smooth_thickness) {
- /* thickness need to repeat process several times */
- for (int r2 = 0; r2 < repeat * 2; r2++) {
- BKE_gpencil_stroke_smooth_thickness(gps, i, 1.0f - factor);
- }
+ BKE_gpencil_stroke_smooth_thickness(&gps_old, i, 1.0f - factor, 1, gps);
}
if (smooth_uv) {
- BKE_gpencil_stroke_smooth_uv(gps, i, factor);
+ BKE_gpencil_stroke_smooth_uv(&gps_old, i, factor, 1, gps);
}
}
+ if (n < repeat - 1) {
+ memcpy(gps_old.points, gps->points, sizeof(bGPDspoint) * gps->totpoints);
+ }
}
+ MEM_freeN(gps_old.points);
}
}
GP_EDITABLE_STROKES_END(gpstroke_iter);
@@ -4926,10 +4931,10 @@ void GPENCIL_OT_stroke_smooth(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- prop = RNA_def_int(ot->srna, "repeat", 1, 1, 50, "Repeat", "", 1, 20);
+ prop = RNA_def_int(ot->srna, "repeat", 2, 1, 1000, "Repeat", "", 1, 1000);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 2.0f, "Factor", "", 0.0f, 2.0f);
+ RNA_def_float(ot->srna, "factor", 1.0f, 0.0f, 2.0f, "Factor", "", 0.0f, 1.0f);
RNA_def_boolean(ot->srna,
"only_selected",
true,
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 45a2247c65e..8fc300412d9 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1638,14 +1638,9 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
}
}
- /* smooth stroke */
- float reduce = 0.0f;
- float smoothfac = 1.0f;
- for (int r = 0; r < 1; r++) {
- for (int i = 0; i < gps->totpoints; i++) {
- BKE_gpencil_stroke_smooth_point(gps, i, smoothfac - reduce, false);
- }
- reduce += 0.25f; /* reduce the factor */
+ /* Smooth stroke. No copy of the stroke since there only a minor improvement here. */
+ for (int i = 0; i < gps->totpoints; i++) {
+ BKE_gpencil_stroke_smooth_point(gps, i, 1.0f, 2, false, true, gps);
}
/* if axis locked, reproject to plane locked */
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 65060e1bab5..8630b7f23d4 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -310,23 +310,6 @@ static void gpencil_stroke_pair_table(bContext *C,
}
}
-static void gpencil_interpolate_smooth_stroke(bGPDstroke *gps,
- float smooth_factor,
- int smooth_steps)
-{
- if (smooth_factor == 0.0f) {
- return;
- }
-
- float reduce = 0.0f;
- for (int r = 0; r < smooth_steps; r++) {
- for (int i = 0; i < gps->totpoints - 1; i++) {
- BKE_gpencil_stroke_smooth_point(gps, i, smooth_factor - reduce, false);
- BKE_gpencil_stroke_smooth_strength(gps, i, smooth_factor);
- }
- reduce += 0.25f; /* reduce the factor */
- }
-}
/* Perform interpolation */
static void gpencil_interpolate_update_points(const bGPDstroke *gps_from,
const bGPDstroke *gps_to,
@@ -553,7 +536,15 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi)
/* Update points position. */
gpencil_interpolate_update_points(gps_from, gps_to, new_stroke, tgpil->factor);
- gpencil_interpolate_smooth_stroke(new_stroke, tgpi->smooth_factor, tgpi->smooth_steps);
+ BKE_gpencil_stroke_smooth(new_stroke,
+ tgpi->smooth_factor,
+ tgpi->smooth_steps,
+ true,
+ true,
+ false,
+ false,
+ true,
+ NULL);
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
@@ -1385,7 +1376,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
/* Update points position. */
gpencil_interpolate_update_points(gps_from, gps_to, new_stroke, factor);
- gpencil_interpolate_smooth_stroke(new_stroke, smooth_factor, smooth_steps);
+ BKE_gpencil_stroke_smooth(
+ new_stroke, smooth_factor, smooth_steps, true, true, false, false, true, NULL);
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gpd, new_stroke);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 18dc8d4bc72..93a4a784674 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1197,29 +1197,21 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
gpencil_subdivide_stroke(gpd, gps, subdivide);
}
- /* Smooth stroke after subdiv - only if there's something to do for each iteration,
- * the factor is reduced to get a better smoothing
- * without changing too much the original stroke. */
- if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
- (brush->gpencil_settings->draw_smoothfac > 0.0f)) {
- float reduce = 0.0f;
- for (int r = 0; r < brush->gpencil_settings->draw_smoothlvl; r++) {
- for (i = 0; i < gps->totpoints - 1; i++) {
- BKE_gpencil_stroke_smooth_point(
- gps, i, brush->gpencil_settings->draw_smoothfac - reduce, false);
- BKE_gpencil_stroke_smooth_strength(gps, i, brush->gpencil_settings->draw_smoothfac);
- }
- reduce += 0.25f; /* reduce the factor */
- }
+ /* Smooth stroke after subdiv - only if there's something to do for each iteration.
+ * Keep the original stroke shape as much as possible. */
+ const float smoothfac = brush->gpencil_settings->draw_smoothfac;
+ const int iterations = brush->gpencil_settings->draw_smoothlvl;
+ if (brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) {
+ BKE_gpencil_stroke_smooth(gps, smoothfac, iterations, true, true, false, false, true, NULL);
}
/* If reproject the stroke using Stroke mode, need to apply a smooth because
* the reprojection creates small jitter. */
if (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) {
float ifac = (float)brush->gpencil_settings->input_samples / 10.0f;
float sfac = interpf(1.0f, 0.2f, ifac);
- for (i = 0; i < gps->totpoints - 1; i++) {
- BKE_gpencil_stroke_smooth_point(gps, i, sfac, false);
- BKE_gpencil_stroke_smooth_strength(gps, i, sfac);
+ for (i = 0; i < gps->totpoints; i++) {
+ BKE_gpencil_stroke_smooth_point(gps, i, sfac, 2, false, true, gps);
+ BKE_gpencil_stroke_smooth_strength(gps, i, sfac, 2, gps);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 216971e514b..1e7159392e2 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -329,16 +329,16 @@ static bool gpencil_brush_smooth_apply(tGP_BrushEditData *gso,
/* perform smoothing */
if (gso->brush->gpencil_settings->sculpt_mode_flag & GP_SCULPT_FLAGMODE_APPLY_POSITION) {
- BKE_gpencil_stroke_smooth_point(gps, pt_index, inf, false);
+ BKE_gpencil_stroke_smooth_point(gps, pt_index, inf, 2, false, false, gps);
}
if (gso->brush->gpencil_settings->sculpt_mode_flag & GP_SCULPT_FLAGMODE_APPLY_STRENGTH) {
- BKE_gpencil_stroke_smooth_strength(gps, pt_index, inf);
+ BKE_gpencil_stroke_smooth_strength(gps, pt_index, inf, 2, gps);
}
if (gso->brush->gpencil_settings->sculpt_mode_flag & GP_SCULPT_FLAGMODE_APPLY_THICKNESS) {
- BKE_gpencil_stroke_smooth_thickness(gps, pt_index, inf);
+ BKE_gpencil_stroke_smooth_thickness(gps, pt_index, inf, 2, gps);
}
if (gso->brush->gpencil_settings->sculpt_mode_flag & GP_SCULPT_FLAGMODE_APPLY_UV) {
- BKE_gpencil_stroke_smooth_uv(gps, pt_index, inf);
+ BKE_gpencil_stroke_smooth_uv(gps, pt_index, inf, 2, gps);
}
return true;
diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index c4f1ae88d28..cf28c88edf0 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -201,6 +201,8 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
ot->poll = WM_operator_winactive;
ot->ui = wm_usd_export_draw;
+ ot->flag = OPTYPE_REGISTER; /* No UNDO possible. */
+
WM_operator_properties_filesel(ot,
FILE_TYPE_FOLDER | FILE_TYPE_USD,
FILE_BLENDER,
@@ -459,6 +461,8 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
ot->poll = WM_operator_winactive;
ot->ui = wm_usd_import_draw;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
WM_operator_properties_filesel(ot,
FILE_TYPE_FOLDER | FILE_TYPE_USD,
FILE_BLENDER,
diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc
index 24425b5a991..afd2c048379 100644
--- a/source/blender/editors/object/object_transform.cc
+++ b/source/blender/editors/object/object_transform.cc
@@ -1695,13 +1695,13 @@ static void object_apply_rotation(Object *ob, const float rmat[3][3])
static void object_apply_location(Object *ob, const float loc[3])
{
/* quick but weak */
- Object ob_prev = *ob;
+ Object ob_prev = blender::dna::shallow_copy(*ob);
float mat[4][4];
copy_m4_m4(mat, ob->obmat);
copy_v3_v3(mat[3], loc);
BKE_object_apply_mat4(ob, mat, true, true);
copy_v3_v3(mat[3], ob->loc);
- *ob = ob_prev;
+ *ob = blender::dna::shallow_copy(ob_prev);
copy_v3_v3(ob->loc, mat[3]);
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 1c4a1d7e8c9..aa77aab2283 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2790,8 +2790,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
ED_image_undo_push_end();
- /* force GPU re-upload, all image is invalid. */
- BKE_image_free_gputextures(ima);
+ BKE_image_partial_update_mark_full_update(ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@@ -2910,8 +2909,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
ED_image_undo_push_end();
- /* Force GPU re-upload, all image is invalid. */
- BKE_image_free_gputextures(ima);
+ BKE_image_partial_update_mark_full_update(ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@@ -3001,8 +2999,7 @@ static int image_scale_exec(bContext *C, wmOperator *op)
ED_image_undo_push_end();
- /* Force GPU re-upload, all image is invalid. */
- BKE_image_free_gputextures(ima);
+ BKE_image_partial_update_mark_full_update(ima);
DEG_id_tag_update(&ima->id, 0);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
diff --git a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
index 0023b7c7b62..476bbdb63ae 100644
--- a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
+++ b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc
@@ -150,7 +150,7 @@ TreeElement *TreeDisplayLibraries::add_library_contents(Main &mainvar, ListBase
}
else {
ten = outliner_add_element(
- &space_outliner_, &tenlib->subtree, lbarray[a], nullptr, TSE_ID_BASE, 0);
+ &space_outliner_, &tenlib->subtree, lib, nullptr, TSE_ID_BASE, a);
ten->directdata = lbarray[a];
ten->name = outliner_idcode_to_plural(GS(id->name));
}