diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-14 21:48:22 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-14 21:56:57 +0300 |
commit | 26d2652d6d4287801d56dc8d41b1037750af701a (patch) | |
tree | e6d71dcc75782c28859d06d7eb39d7929c412b7b /source/blender/blenloader | |
parent | 987c6da6c0dd7b4f8c64561c030d4c381f2725c5 (diff) |
Armature: implement universal hash table lookup of Bone objects by name.
Since drivers on Bone properties are really supposed to be stored
in Armature data and access bones via its bones[] collection, this
lookup path should work efficiently.
Mass lookup of bones by name was already done through hashes,
but they were built temporarily every time that was needed. This
simply replaces it with a common hash table computed immediately
after file load, copy, or Edit to Object mode switch.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 400070f12fc..f0e70f1be27 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3763,9 +3763,6 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) } } - /* avoid string */ - GHash *bone_hash = BKE_armature_bone_from_name_map(arm); - if (ob->proxy) { /* sync proxy layer */ if (pose->proxy_layer) { @@ -3774,7 +3771,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) /* sync proxy active bone */ if (pose->proxy_act_bone[0]) { - Bone *bone = BLI_ghash_lookup(bone_hash, pose->proxy_act_bone); + Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone); if (bone) { arm->act_bone = bone; } @@ -3784,7 +3781,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { lib_link_constraints(fd, (ID *)ob, &pchan->constraints); - pchan->bone = BLI_ghash_lookup(bone_hash, pchan->name); + pchan->bone = BKE_armature_find_bone_name(arm, pchan->name); IDP_LibLinkProperty(pchan->prop, fd); @@ -3799,8 +3796,6 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) } } - BLI_ghash_free(bone_hash, NULL, NULL); - if (rebuild) { DEG_id_tag_update_ex( bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); @@ -3858,6 +3853,7 @@ static void direct_link_armature(FileData *fd, bArmature *arm) Bone *bone; link_list(fd, &arm->bonebase); + arm->bonehash = NULL; arm->edbo = NULL; arm->adt = newdataadr(fd, arm->adt); @@ -3869,6 +3865,8 @@ static void direct_link_armature(FileData *fd, bArmature *arm) arm->act_bone = newdataadr(fd, arm->act_bone); arm->act_edbone = NULL; + + BKE_armature_bone_hash_make(arm); } /** \} */ |