[Bf-blender-cvs] [65b374087ab] custom-manipulators: Remove face-map DNA from pose-channels
Campbell Barton
noreply at git.blender.org
Tue May 30 07:53:00 CEST 2017
Commit: 65b374087abfbc7cdb40b5259d2ee7e3c4534397
Author: Campbell Barton
Date: Tue May 30 15:46:20 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB65b374087abfbc7cdb40b5259d2ee7e3c4534397
Remove face-map DNA from pose-channels
Manually setting up links per bone to an object & facemap is tedious.
It's also going to cause quiet a bit of book-keeping internally to
ensure its always valid (linking, adding removing objects proxies).
Instead match the face-maps names to bones (as with vertex groups).
The DNA members have been moved into runtime cache.
This also adds an option for bones to use facemaps,
to avoid excessive searching on heavy armatures that might use very few
(if any) face-maps.
===================================================================
M release/scripts/startup/bl_ui/properties_data_bone.py
M source/blender/blenkernel/BKE_armature.h
M source/blender/blenkernel/intern/action.c
M source/blender/blenkernel/intern/armature.c
M source/blender/blenkernel/intern/library_query.c
M source/blender/blenkernel/intern/object.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/armature/pose_edit.c
M source/blender/editors/armature/pose_select.c
M source/blender/editors/include/ED_armature.h
M source/blender/editors/space_view3d/drawarmature.c
M source/blender/editors/space_view3d/view3d_widgets.c
M source/blender/makesdna/DNA_action_types.h
M source/blender/makesdna/DNA_armature_types.h
M source/blender/makesrna/intern/rna_armature.c
M source/blender/makesrna/intern/rna_pose.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index 14b9913e52d..b4fe03bd652 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -268,33 +268,6 @@ class BONE_PT_relations(BoneButtonsPanel, Panel):
sub.prop(bone, "use_local_location")
-class BONE_PT_facemaps(BoneButtonsPanel, Panel):
- bl_label = "Face Maps"
-
- @classmethod
- def poll(cls, context):
- return context.object and context.bone
-
- def draw(self, context):
- layout = self.layout
-
- ob = context.object
- bone = context.bone
- pchan = ob.pose.bones[bone.name]
-
- col = layout.column()
- col.prop(pchan, "facemap_object", text="Object")
-
- col = layout.column()
- if pchan.facemap_object:
- col.prop_search(pchan, "facemap", pchan.facemap_object, "face_maps")
- else:
- # ugly, used to add inactive search field since prop_search
- # doesn't support passing pchan.facemap_object if it's unset
- col.enabled = False
- col.prop(pchan, "facemap")
-
-
class BONE_PT_display(BoneButtonsPanel, Panel):
bl_label = "Display"
@@ -322,8 +295,9 @@ class BONE_PT_display(BoneButtonsPanel, Panel):
col = split.column()
col.prop(bone, "hide", text="Hide")
sub = col.column()
- sub.active = bool(pchan and pchan.facemap)
- sub.prop(bone, "fmap_only")
+ sub.prop(bone, "show_fmap")
+ sub.active = bone.show_fmap
+ sub.prop(bone, "show_only_fmap")
sub = col.column()
sub.active = bool(pchan and pchan.custom_shape)
sub.prop(bone, "show_wire", text="Wireframe")
@@ -486,7 +460,6 @@ classes = (
BONE_PT_transform_locks,
BONE_PT_curved,
BONE_PT_relations,
- BONE_PT_facemaps,
BONE_PT_display,
BONE_PT_inverse_kinematics,
BONE_PT_deform,
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index a68f1e763fd..79e1ed2a231 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -33,7 +33,10 @@
* \author nzc
*/
+struct bPose;
+struct Base;
struct Bone;
+struct Depsgraph;
struct GHash;
struct Main;
struct bArmature;
@@ -101,6 +104,8 @@ void BKE_pose_where_is(struct Scene *scene, struct Object *ob);
void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
+void BKE_pose_fmap_cache_update(struct Depsgraph *graph, struct Object *ob);
+
/* get_objectspace_bone_matrix has to be removed still */
void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[4][4], int root, int posed);
void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3]);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 545e4bf150f..9c950479512 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -581,6 +581,7 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints)
}
pchan->draw_data = NULL; /* Drawing cache, no need to copy. */
+ pchan->fmap_data = NULL; /* Face-Map cache, no need to copy. */
}
/* for now, duplicate Bone Groups too when doing this */
@@ -751,14 +752,6 @@ void BKE_pose_channels_remove(
*/
void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
{
- if (pchan->fmap_object) {
- if (do_id_user) {
- id_us_min(&pchan->fmap_object->id);
- }
- pchan->fmap_object = NULL;
- }
- pchan->fmap = NULL;
-
if (pchan->custom) {
if (do_id_user) {
id_us_min(&pchan->custom->id);
@@ -780,6 +773,7 @@ void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
/* Cached data, for new draw manager rendering code. */
MEM_SAFE_FREE(pchan->draw_data);
+ MEM_SAFE_FREE(pchan->fmap_data);
}
void BKE_pose_channel_free(bPoseChannel *pchan)
@@ -926,13 +920,6 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
pchan->prop = IDP_CopyProperty(pchan_from->prop);
}
- /* face map */
- pchan->fmap_object = pchan_from->fmap_object;
- pchan->fmap = pchan_from->fmap;
- if (pchan->fmap_object) {
- id_us_plus(&pchan->fmap_object->id);
- }
-
/* custom shape */
pchan->custom = pchan_from->custom;
if (pchan->custom) {
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 5d87c606d8a..f940916532f 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -38,6 +38,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
+#include "BLI_iterator.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
@@ -70,9 +71,13 @@
#include "BKE_library_remap.h"
#include "BKE_lattice.h"
#include "BKE_main.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
#include "BIK_api.h"
#include "BKE_sketch.h"
@@ -1867,19 +1872,8 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
/* copy data in temp back over to the cleaned-out (but still allocated) original channel */
*pchan = pchanw;
- if (pchan->fmap_object) {
- id_us_plus(&pchan->fmap_object->id);
- }
- if (pchan->custom) {
- id_us_plus(&pchan->custom->id);
- }
}
else {
- pchan->fmap_object = pchanp->fmap_object;
- pchan->fmap = pchanp->fmap;
- if (pchan->fmap_object) {
- id_us_plus(&pchan->fmap_object->id);
- }
/* always copy custom shape */
pchan->custom = pchanp->custom;
if (pchan->custom) {
@@ -2446,3 +2440,66 @@ bPoseChannel *BKE_armature_splineik_solver_find_root(
}
return rootchan;
}
+
+void BKE_pose_fmap_cache_update(Depsgraph *graph, Object *ob_pose)
+{
+ if (ELEM(NULL, ob_pose, ob_pose->pose)) {
+ return;
+ }
+
+ bool has_fmap = false;
+ for (bPoseChannel *pchan = ob_pose->pose->chanbase.first; pchan; pchan = pchan->next) {
+ MEM_SAFE_FREE(pchan->fmap_data);
+ if (pchan->bone->flag & BONE_DRAW_FMAP) {
+ has_fmap = true;
+ }
+ }
+
+ if (has_fmap == false) {
+ return;
+ }
+
+ BKE_pose_channels_hash_make(ob_pose->pose);
+
+ Scene *scene = DEG_get_scene(graph);
+
+ VirtualModifierData virtualModifierData;
+
+ DEG_OBJECT_ITER(graph, ob)
+ {
+ if ((ob->type == OB_MESH) && !BLI_listbase_is_empty(&ob->fmaps)) {
+ bool use_ob_fmap = false;
+ ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+ for (; md; md = md->next) {
+ if (modifier_isEnabled(scene, md, eModifierMode_Realtime) && md->type == eModifierType_Armature) {
+ ArmatureModifierData *amd = (ArmatureModifierData *)md;
+ if (amd->object && (amd->deformflag & ARM_DEF_FACEMAPS)) {
+ if (amd->object == ob_pose) {
+ use_ob_fmap = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (use_ob_fmap) {
+ /* We know that 'ob' is a mesh that is deformed by 'ob_act'. */
+ for (bFaceMap *fmap = ob->fmaps.first; fmap; fmap = fmap->next) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob_pose->pose, fmap->name);
+ if (pchan->bone->flag & BONE_DRAW_FMAP) {
+ if (pchan->fmap_data != NULL) {
+ /* XXX, we could support multiple meshes per bone,
+ * it's a corner-case so only add if users end up needing it. */
+ continue;
+ }
+
+ pchan->fmap_data = MEM_mallocN(sizeof(*pchan->fmap_data), __func__);
+ pchan->fmap_data->object = ob;
+ pchan->fmap_data->fmap = fmap;
+ }
+ }
+ }
+ }
+ }
+ DEG_OBJECT_ITER_END
+}
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 653b376a108..0c89a5bea42 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -586,7 +586,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
data.cb_flag |= proxy_cb_flag;
for (pchan = object->pose->chanbase.first; pchan; pchan = pchan->next) {
library_foreach_idproperty_ID_link(&data, pchan->prop, IDWALK_CB_USER);
- CALLBACK_INVOKE(pchan->fmap_object, IDWALK_CB_USER);
CALLBACK_INVOKE(pchan->custom, IDWALK_CB_USER);
BKE_constraints_id_loop(&pchan->constraints, library_foreach_constraintObjectLooper, &data);
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 0bd5dd60573..490ce605a9e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1283,7 +1283,6 @@ static void armature_set_id_extern(Object *ob)
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (!(pchan->bone->layer & lay)) {
- id_lib_extern((ID *)pchan->fmap_object);
id_lib_extern((ID *)pchan->custom);
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 1e48a40ae27..436c75eae1c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3327,14 +3327,6 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
IDP_LibLinkProperty(pchan->prop, fd);
- pchan->fmap_object = newlibadr_us(fd, arm->id.lib, pchan->fmap_object);
- if (pchan->fmap_object) {
- bFaceMap *fmap = fmap_find_name(pchan->fmap_object, pchan->fmap->name);
- /* fix fmap pointer now that we've got updated fmap_object */
- MEM_freeN(pchan->fmap);
- pchan->fmap = fmap;
- }
-
pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom);
if (UNLIKELY(pchan->bone == NULL)) {
rebuild = true;
@@ -5006,7 +4998,6 @@ static void direct_link_pose(FileData *fd, bPose *pose)
pchan->bone = NULL;
pchan->parent = newdataadr(fd, pchan->parent);
pchan->child = newdataadr(fd, pchan-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list