[Bf-blender-cvs] [3990a9632f9] greasepencil-object: Correctly encode the first full copy in the chain
Falk David
noreply at git.blender.org
Mon Feb 7 18:35:15 CET 2022
Commit: 3990a9632f931b4a7cb44bd43df4e0e73e2d0842
Author: Falk David
Date: Fri Feb 4 15:40:48 2022 +0100
Branches: greasepencil-object
https://developer.blender.org/rB3990a9632f931b4a7cb44bd43df4e0e73e2d0842
Correctly encode the first full copy in the chain
Co-authored-by: @yann-lty
===================================================================
M source/blender/editors/gpencil/gpencil_undo.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 55e7e860a03..9427e3111f3 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -423,16 +423,17 @@ static bool gpencil_undosys_step_encode(struct bContext *C,
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = (bGPdata *)ob->data;
- bool only_frame_changed = false;
-
/* TODO: We might need to check if ID_RECALC_ALL is set on the gpd here to test if we need to
* clear the cache. It might be bad to "start" with some cache and add new update nodes on top.
*/
+ bool only_frame_changed = false;
+
/* In case the step we are about to encode would be the first in the gpencil undo system, ensure
- * that we do a full-copy. */
- if (undo_stack->step_active == NULL ||
- undo_stack->step_active->type != BKE_UNDOSYS_TYPE_GPENCIL) {
+ * that we do a full copy. */
+ const bool force_full_update = undo_stack->step_active == NULL ||
+ undo_stack->step_active->type != BKE_UNDOSYS_TYPE_GPENCIL;
+ if (force_full_update) {
BKE_gpencil_tag_full_update(gpd, NULL, NULL, NULL);
}
/* If the ID of the grease pencil object was not tagged or the update cache is empty, we assume
@@ -475,6 +476,14 @@ static bool gpencil_undosys_step_encode(struct bContext *C,
/* Because the encoding of a gpencil undo step uses the update cache on the gpencil data, we can
* tag it after the encode so that the update-on-write knows that it can be safely disposed. */
gpd->flag |= GP_DATA_UPDATE_CACHE_DISPOSABLE;
+
+ /* In case we forced a full update, we want to make sure that the gpd.runtime does not contain a
+ * cache since the eval object already contains the correct data and we don't want to go through
+ * an update-on-write. */
+ if (force_full_update) {
+ BKE_gpencil_free_update_cache(gpd);
+ }
+
return true;
}
More information about the Bf-blender-cvs
mailing list