[Bf-blender-cvs] [a1a61547dba] custom-manipulators: Ensure pose-mode cache exists
Campbell Barton
noreply at git.blender.org
Wed May 31 08:40:16 CEST 2017
Commit: a1a61547dbac70e45f9ec574f8b804954607d262
Author: Campbell Barton
Date: Wed May 31 16:10:21 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBa1a61547dbac70e45f9ec574f8b804954607d262
Ensure pose-mode cache exists
Files that were saved in pose-mode or selecting pose bones,
would have invalid cache.
===================================================================
M source/blender/depsgraph/intern/depsgraph_query.cc
M source/blender/editors/armature/pose_edit.c
M source/blender/editors/util/ed_util.c
M source/blender/windowmanager/intern/wm_event_system.c
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index b6c71524eca..8411393e812 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -137,7 +137,8 @@ void DEG_objects_iterator_next(BLI_Iterator *iter)
/* Make sure we have the base collection settings is already populated.
* This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
* Which usually means a missing call to DAG_id_tag_update(). */
- BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
+ BLI_assert((base->collection_properties == NULL) ||
+ !BLI_listbase_is_empty(&base->collection_properties->data.group));
/* Flushing depsgraph data. */
ob->base_flag = (base->flag | BASE_FROM_SET) & data->flag;
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index f3260c4653b..53507af00c7 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -85,7 +85,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
{
ReportList *reports = CTX_wm_reports(C);
Object *ob = base->object;
-
+
if (ID_IS_LINKED_DATABLOCK(ob)) {
BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
return;
@@ -93,15 +93,23 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
switch (ob->type) {
case OB_ARMATURE:
- ob->restore_mode = ob->mode;
- ob->mode |= OB_MODE_POSE;
+ {
+ /* incase we're already in pose-mode */
+ const bool changed = (ob->mode & OB_MODE_POSE) == 0;
+
+ if (changed) {
+ ob->restore_mode = ob->mode;
+ ob->mode |= OB_MODE_POSE;
+ }
struct Depsgraph *graph = CTX_data_depsgraph(C);
BKE_pose_fmap_cache_update(graph, ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
-
+ if (changed) {
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
+ }
break;
+ }
default:
return;
}
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 490683e9360..6ae1de3fead 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -104,12 +104,15 @@ void ED_editors_init(bContext *C)
for (ob = bmain->object.first; ob; ob = ob->id.next) {
int mode = ob->mode;
- if (!ELEM(mode, OB_MODE_OBJECT, OB_MODE_POSE)) {
- ob->mode = OB_MODE_OBJECT;
+ if (mode == OB_MODE_OBJECT) {
+ /* pass */
+ }
+ else {
data = ob->data;
-
- if (ob == obact && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data)))
+ ob->mode = OB_MODE_OBJECT;
+ if ((ob == obact) && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data))) {
ED_object_toggle_modes(C, mode);
+ }
}
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 5752b411b64..4bbf8f5a786 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -36,6 +36,7 @@
#include <string.h>
#include "DNA_listBase.h"
+#include "DNA_object_types.h"
#include "DNA_manipulator_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
@@ -51,6 +52,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
@@ -323,7 +325,20 @@ void wm_event_do_notifiers(bContext *C)
ED_info_stats_clear(sl);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
}
+ if (note->category == NC_SCENE) {
+ if (note->data == ND_OB_ACTIVE) {
+ SceneLayer *sl = BKE_scene_layer_context_active(win->screen->scene);
+ if (sl->basact) {
+ Object *ob = sl->basact->object;
+ if (ob->type == OB_ARMATURE) {
+ struct Depsgraph *graph = CTX_data_depsgraph(C);
+ BKE_pose_fmap_cache_update(graph, ob);
+ }
+ }
+ }
+ }
}
+
if (do_anim) {
/* XXX, quick frame changes can cause a crash if framechange and rendering
More information about the Bf-blender-cvs
mailing list