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:
authorCampbell Barton <ideasman42@gmail.com>2019-11-07 08:52:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-11-07 08:56:21 +0300
commit79b703bb635ea719bbe31c1ece9884d2d298eaef (patch)
tree7ee7e896e8e66233f85dd425708a595f66607f48 /source/blender/blenkernel
parent85637311c28f49b55286d3287d4c7cefbcbca18a (diff)
Fix T69822: Switching sculpt objects breaks undo
This introduces object mode tagging for data which hasn't yet been written back to the ID data. Now when selecting other sculpt objects, the original objects data is flushed back to the ID before writing a memfile undo step.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h7
-rw-r--r--source/blender/blenkernel/BKE_font.h6
-rw-r--r--source/blender/blenkernel/BKE_main.h5
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h7
-rw-r--r--source/blender/blenkernel/intern/object.c49
6 files changed, 76 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 47c8f31ead3..1b9e318146e 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -79,6 +79,13 @@ typedef struct BMEditMesh {
/*temp variables for x-mirror editing*/
int mirror_cdlayer; /* -1 is invalid */
+
+ /**
+ * ID data is older than edit-mode data.
+ * Set #Main.is_memfile_undo_flush_needed when enabling.
+ */
+ char needs_flush_to_id;
+
} BMEditMesh;
/* editmesh.c */
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index e440d617f7a..3dd2a551a93 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -61,6 +61,12 @@ typedef struct EditFont {
int len, pos;
int selstart, selend;
+ /**
+ * ID data is older than edit-mode data.
+ * Set #Main.is_memfile_undo_flush_needed when enabling.
+ */
+ char needs_flush_to_id;
+
} EditFont;
bool BKE_vfont_is_builtin(struct VFont *vfont);
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 1b2e8bcbf42..c48a9cad443 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -80,6 +80,11 @@ typedef struct Main {
char recovered; /* indicate the main->name (file) is the recovered one */
/** All current ID's exist in the last memfile undo step. */
char is_memfile_undo_written;
+ /**
+ * An ID needs it's data to be flushed back.
+ * use "needs_flush_to_id" in edit data to flag data which needs updating.
+ */
+ char is_memfile_undo_flush_needed;
BlendThumbnail *blen_thumb;
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index ffdcb9cd2c0..d76c55f0815 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -99,6 +99,8 @@ bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode)
bool BKE_object_data_is_in_editmode(const struct ID *id);
+char *BKE_object_data_editmode_flush_ptr_get(struct ID *id);
+
void BKE_object_update_select_id(struct Main *bmain);
typedef enum eObjectVisibilityResult {
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 4413ad2a70f..48f9e1fd95e 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -306,6 +306,13 @@ typedef struct SculptSession {
/* This flag prevents PBVH from being freed when creating the vp_handle for texture paint. */
bool building_vp_handle;
+
+ /**
+ * ID data is older than sculpt-mode data.
+ * Set #Main.is_memfile_undo_flush_needed when enabling.
+ */
+ char needs_flush_to_id;
+
} SculptSession;
void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 773e2d19b22..b50e152527e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -81,6 +81,7 @@
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_effect.h"
+#include "BKE_font.h"
#include "BKE_fcurve.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_icons.h"
@@ -629,6 +630,54 @@ bool BKE_object_data_is_in_editmode(const ID *id)
}
}
+char *BKE_object_data_editmode_flush_ptr_get(struct ID *id)
+{
+ const short type = GS(id->name);
+ switch (type) {
+ case ID_ME: {
+ BMEditMesh *em = ((Mesh *)id)->edit_mesh;
+ if (em != NULL) {
+ return &em->needs_flush_to_id;
+ }
+ break;
+ }
+ case ID_CU: {
+ if (((Curve *)id)->vfont != NULL) {
+ EditFont *ef = ((Curve *)id)->editfont;
+ if (ef != NULL) {
+ return &ef->needs_flush_to_id;
+ }
+ }
+ else {
+ EditNurb *editnurb = ((Curve *)id)->editnurb;
+ if (editnurb) {
+ return &editnurb->needs_flush_to_id;
+ }
+ }
+ break;
+ }
+ case ID_MB: {
+ MetaBall *mb = (MetaBall *)id;
+ return &mb->needs_flush_to_id;
+ }
+ case ID_LT: {
+ EditLatt *editlatt = ((Lattice *)id)->editlatt;
+ if (editlatt) {
+ return &editlatt->needs_flush_to_id;
+ }
+ break;
+ }
+ case ID_AR: {
+ bArmature *arm = (bArmature *)id;
+ return &arm->needs_flush_to_id;
+ }
+ default:
+ BLI_assert(0);
+ return NULL;
+ }
+ return NULL;
+}
+
bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
{
if (ob->type == OB_MESH) {