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
parent08ee31990eae2c837ea30f1542ddbee63815e1a6 (diff)
bugfix [#20579] Context pinning error (pose mode)
-rw-r--r--release/scripts/ui/properties_object_constraint.py8
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c45
2 files changed, 45 insertions, 8 deletions
diff --git a/release/scripts/ui/properties_object_constraint.py b/release/scripts/ui/properties_object_constraint.py
index 21afadfa425..372c67211c5 100644
--- a/release/scripts/ui/properties_object_constraint.py
+++ b/release/scripts/ui/properties_object_constraint.py
@@ -744,18 +744,14 @@ class BONE_PT_constraints(ConstraintButtonsPanel):
bl_context = "bone_constraint"
def poll(self, context):
- ob = context.object
- return (ob and ob.type == 'ARMATURE' and context.bone)
+ return (context.pose_bone)
def draw(self, context):
layout = self.layout
- ob = context.object
- pchan = ob.pose.bones[context.bone.name]
-
layout.operator_menu_enum("pose.constraint_add", "type")
- for con in pchan.constraints:
+ for con in context.pose_bone.constraints:
self.draw_constraint(context, con)
bpy.types.register(OBJECT_PT_constraints)
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;