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>2010-01-31 02:48:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-31 02:48:49 +0300
commitebbd1e0b20abcb0a985649ea417e4a5becaa3d0e (patch)
tree837cb2a45c9f5ac5fe3784dd1c9b29a4d7a4d9d6 /source/blender/editors/space_buttons/buttons_context.c
parent08ee31990eae2c837ea30f1542ddbee63815e1a6 (diff)
bugfix [#20579] Context pinning error (pose mode)
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_context.c')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index fcfd8b907eb..ba73182d129 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -48,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_action.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_paint.h"
@@ -274,6 +275,40 @@ static int buttons_context_path_bone(ButsContextPath *path)
return 0;
}
+static int buttons_context_path_pose_bone(ButsContextPath *path)
+{
+ PointerRNA *ptr= &path->ptr[path->len-1];
+
+ /* if we already have a (pinned) PoseBone, we're done */
+ if(RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
+ return 1;
+ }
+
+ /* if we have an armature, get the active bone */
+ if(buttons_context_path_object(path)) {
+ Object *ob= path->ptr[path->len-1].data;
+ bArmature *arm= ob->data; /* path->ptr[path->len-1].data - works too */
+
+ if(ob->type != OB_ARMATURE || arm->edbo) {
+ return 0;
+ }
+ else {
+ if(arm->act_bone) {
+ bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name);
+ if(pchan) {
+ RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]);
+ path->len++;
+ return 1;
+ }
+ }
+ }
+ }
+
+ /* no path to a bone possible */
+ return 0;
+}
+
+
static int buttons_context_path_particle(ButsContextPath *path)
{
Object *ob;
@@ -461,11 +496,13 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
found= buttons_context_path_texture(C, path);
break;
case BCONTEXT_BONE:
- case BCONTEXT_BONE_CONSTRAINT:
found= buttons_context_path_bone(path);
if(!found)
found= buttons_context_path_data(path, OB_ARMATURE);
break;
+ case BCONTEXT_BONE_CONSTRAINT:
+ found= buttons_context_path_pose_bone(path);
+ break;
default:
found= 0;
break;
@@ -586,7 +623,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
static const char *dir[] = {
"world", "object", "mesh", "armature", "lattice", "curve",
"meta_ball", "lamp", "camera", "material", "material_slot",
- "texture", "texture_slot", "bone", "edit_bone", "particle_system", "particle_system_editable",
+ "texture", "texture_slot", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable",
"cloth", "soft_body", "fluid", "smoke", "collision", "brush", NULL};
CTX_data_dir_set(result, dir);
@@ -704,6 +741,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
set_pointer_type(path, result, &RNA_EditBone);
return 1;
}
+ else if(CTX_data_equals(member, "pose_bone")) {
+ set_pointer_type(path, result, &RNA_PoseBone);
+ return 1;
+ }
else if(CTX_data_equals(member, "particle_system")) {
set_pointer_type(path, result, &RNA_ParticleSystem);
return 1;