This commit is contained in:
Campbell Barton 2011-09-14 01:54:04 +00:00
commit c3a718702f
12 changed files with 76 additions and 86 deletions

@ -108,6 +108,7 @@ void object_to_mat4(struct Object *ob, float mat[][4]);
void object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent);
void set_no_parent_ipo(int val);
struct Object *object_pose_armature_get(struct Object *ob);
void where_is_object_time(struct Scene *scene, struct Object *ob, float ctime);
void where_is_object(struct Scene *scene, struct Object *ob);

@ -1310,6 +1310,37 @@ static void copy_object_pose(Object *obn, Object *ob)
}
}
static int object_pose_context(Object *ob)
{
if( (ob) &&
(ob->type == OB_ARMATURE) &&
(ob->pose) &&
(ob->mode & OB_MODE_POSE)
) {
return 1;
}
else {
return 0;
}
}
//Object *object_pose_armature_get(Object *ob)
Object *object_pose_armature_get(struct Object *ob)
{
if(ob==NULL)
return NULL;
if(object_pose_context(ob))
return ob;
ob= modifiers_isDeformedByArmature(ob);
if(object_pose_context(ob))
return ob;
return NULL;
}
static void copy_object_transform(Object *ob_tar, Object *ob_src)
{
copy_v3_v3(ob_tar->loc, ob_src->loc);

@ -643,7 +643,7 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob)
static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); // must be active object, not edit-object
Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
bArmature *arm= get_armature(ob);
bPose *pose;
bPoseChannel *pchan;
@ -745,7 +745,7 @@ void POSE_OT_armature_apply (wmOperatorType *ot)
/* set the current pose as the restpose */
static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); // must be active object, not edit-object
Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
/* don't check if editmode (should be done by caller) */
if (ob->type!=OB_ARMATURE)
@ -4927,7 +4927,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(bPoseChannel*), const char default_ksName[])
{
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
short autokey = 0;
/* sanity checks */
@ -5163,7 +5163,7 @@ void POSE_OT_select_all(wmOperatorType *ot)
static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bPoseChannel *pchan,*parent;
/* Determine if there is an active bone */
@ -5239,7 +5239,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr
/* active object is armature in posemode, poll checked */
static int pose_hide_exec(bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm= ob->data;
if(RNA_boolean_get(op->ptr, "unselected"))
@ -5288,7 +5288,7 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
/* active object is armature in posemode, poll checked */
static int pose_reveal_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm= ob->data;
bone_looper(ob, arm->bonebase.first, NULL, show_pose_bone_cb);

@ -51,6 +51,7 @@
#include "BKE_fcurve.h"
#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "RNA_access.h"
@ -129,7 +130,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode)
/* get info from context */
pso->scene= CTX_data_scene(C);
pso->ob= ED_object_pose_armature(CTX_data_active_object(C));
pso->ob= object_pose_armature_get(CTX_data_active_object(C));
pso->arm= (pso->ob)? pso->ob->data : NULL;
pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */
pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */
@ -1164,7 +1165,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu,
static int pose_propagate_exec (bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bAction *act= (ob && ob->adt)? ob->adt->action : NULL;
ListBase pflinks = {NULL, NULL};

@ -54,6 +54,7 @@
#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_report.h"
@ -170,7 +171,7 @@ static Object *get_poselib_object (bContext *C)
if (sa && (sa->spacetype == SPACE_BUTS))
return CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
return ED_object_pose_armature(CTX_data_active_object(C));
return object_pose_armature_get(CTX_data_active_object(C));
}
/* Poll callback for operators that require existing PoseLib data (with poses) to work */
@ -632,7 +633,7 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt)
static int poselib_rename_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bAction *act= (ob) ? ob->poselib : NULL;
TimeMarker *marker;
char newname[64];

@ -58,6 +58,7 @@
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_report.h"
@ -78,36 +79,6 @@
#include "armature_intern.h"
static int object_pose_context(Object *ob)
{
if( (ob) &&
(ob->type == OB_ARMATURE) &&
(ob->pose) &&
(ob->mode & OB_MODE_POSE)
) {
return 1;
}
else {
return 0;
}
}
Object *ED_object_pose_armature(Object *ob)
{
if(ob==NULL)
return NULL;
if(object_pose_context(ob))
return ob;
ob= modifiers_isDeformedByArmature(ob);
if(object_pose_context(ob))
return ob;
return NULL;
}
/* This function is used to process the necessary updates for */
void ED_armature_enter_posemode(bContext *C, Base *base)
{
@ -238,7 +209,7 @@ static int pose_calculate_paths_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@ -314,7 +285,7 @@ static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object */
if ELEM(NULL, ob, ob->pose)
@ -348,7 +319,7 @@ void POSE_OT_paths_clear (wmOperatorType *ot)
static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bConstraint *con;
int found= 0;
@ -408,7 +379,7 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot)
static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm= ob->data;
Bone *curbone, *pabone, *chbone;
int direction = RNA_enum_get(op->ptr, "direction");
@ -646,7 +617,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend)
static int pose_select_grouped_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
short extend= RNA_boolean_get(op->ptr, "extend");
short changed = 0;
@ -713,7 +684,7 @@ void POSE_OT_select_grouped (wmOperatorType *ot)
static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op))
{
Object *ob_act= CTX_data_active_object(C);
Object *ob= ED_object_pose_armature(ob_act);
Object *ob= object_pose_armature_get(ob_act);
if(ob && (ob->mode & OB_MODE_POSE)) {
bArmature *arm= ob->data;
@ -1135,7 +1106,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
static int pose_copy_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
/* sanity checking */
if ELEM(NULL, ob, ob->pose) {
@ -1173,7 +1144,7 @@ void POSE_OT_copy (wmOperatorType *ot)
static int pose_paste_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
Scene *scene= CTX_data_scene(C);
bPoseChannel *chan;
int flip= RNA_boolean_get(op->ptr, "flipped");
@ -1272,7 +1243,7 @@ static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object */
if (ob == NULL)
@ -1312,7 +1283,7 @@ static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object */
if (ob == NULL)
@ -1360,7 +1331,7 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@ -1409,7 +1380,7 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op)
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@ -1472,7 +1443,7 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@ -1707,7 +1678,7 @@ static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@ -1745,7 +1716,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op))
if (sa->spacetype == SPACE_BUTS)
ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
else
ob= ED_object_pose_armature(CTX_data_active_object(C));
ob= object_pose_armature_get(CTX_data_active_object(C));
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
@ -1778,7 +1749,7 @@ void POSE_OT_group_deselect (wmOperatorType *ot)
static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm;
/* paranoia checks */
@ -1823,7 +1794,7 @@ void POSE_OT_flip_names (wmOperatorType *ot)
static int pose_autoside_names_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm;
char newname[32];
short axis= RNA_enum_get(op->ptr, "axis");
@ -1927,7 +1898,7 @@ static int pose_armature_layers_showall_poll (bContext *C)
static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm = (ob)? ob->data : NULL;
PointerRNA ptr;
int maxLayers = (RNA_boolean_get(op->ptr, "all"))? 32 : 16;
@ -1979,7 +1950,7 @@ void ARMATURE_OT_layers_show_all (wmOperatorType *ot)
/* Present a popup to get the layers that should be used */
static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm= (ob)? ob->data : NULL;
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
@ -2000,7 +1971,7 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
/* Set the visible layers for the active armature (edit and pose modes) */
static int pose_armature_layers_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
@ -2090,7 +2061,7 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
/* Set the visible layers for the active armature (edit and pose modes) */
static int pose_bone_layers_exec (bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
@ -2213,7 +2184,7 @@ void ARMATURE_OT_bone_layers (wmOperatorType *ot)
static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
/* loop through all selected pchans, flipping and keying (as needed) */

@ -148,7 +148,6 @@ void ED_armature_bone_rename(struct bArmature *arm, char *oldnamep, char *newnam
void undo_push_armature(struct bContext *C, const char *name);
/* poseobject.c */
struct Object *ED_object_pose_armature(struct Object *ob);
void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);

@ -588,20 +588,6 @@ static void shadecolors4(char *coltop, char *coldown, const char *color, short s
coldown[3]= color[3];
}
static void round_box_shade_col4(const char col1[4], const char col2[4], const float fac)
{
unsigned char col[4];
const int faci= FTOCHAR(fac);
const int facm= 255-faci;
col[0]= (faci*col1[0] + facm*col2[0])>>8;
col[1]= (faci*col1[1] + facm*col2[1])>>8;
col[2]= (faci*col1[2] + facm*col2[2])>>8;
col[3]= (faci*col1[3] + facm*col2[3])>>8;
glColor4ubv(col);
}
static void round_box_shade_col4_r(unsigned char col_r[4], const char col1[4], const char col2[4], const float fac)
{
const int faci= FTOCHAR(fac);

@ -987,7 +987,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
/* free constraints for all selected bones */
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
@ -1423,7 +1423,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
/* dummy operator callback */
static int pose_constraint_add_exec(bContext *C, wmOperator *op)
{
Object *ob= ED_object_pose_armature(ED_object_active_context(C));
Object *ob= object_pose_armature_get(ED_object_active_context(C));
int type= RNA_enum_get(op->ptr, "type");
short with_targets= 0;
@ -1526,7 +1526,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
/* present menu with options + validation for targets to use */
static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
bPoseChannel *pchan= get_active_posechannel(ob);
bConstraint *con= NULL;
@ -1610,7 +1610,7 @@ void POSE_OT_ik_add(wmOperatorType *ot)
/* remove IK constraints from selected bones */
static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Object *ob= object_pose_armature_get(CTX_data_active_object(C));
/* only remove IK Constraints */
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)

@ -238,7 +238,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if(CTX_data_equals(member, "visible_pose_bones")) {
Object *obpose= ED_object_pose_armature(obact);
Object *obpose= object_pose_armature_get(obact);
bArmature *arm= (obpose) ? obpose->data : NULL;
bPoseChannel *pchan;
@ -254,7 +254,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if(CTX_data_equals(member, "selected_pose_bones")) {
Object *obpose= ED_object_pose_armature(obact);
Object *obpose= object_pose_armature_get(obact);
bArmature *arm= (obpose) ? obpose->data : NULL;
bPoseChannel *pchan;
@ -289,7 +289,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if(CTX_data_equals(member, "active_pose_bone")) {
bPoseChannel *pchan;
Object *obpose= ED_object_pose_armature(obact);
Object *obpose= object_pose_armature_get(obact);
pchan= get_active_posechannel(obpose);
if (pchan) {

@ -52,6 +52,7 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
@ -346,7 +347,7 @@ int ED_operator_posemode(bContext *C)
if (obact && !(obact->mode & OB_MODE_EDIT)) {
Object *obpose;
if((obpose= ED_object_pose_armature(obact))) {
if((obpose= object_pose_armature_get(obact))) {
if((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) {
return 1;
}

@ -184,7 +184,6 @@ void ED_area_headerprint(struct ScrArea *sa, char *str){}
struct EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, struct EditBone *ebo){return (struct EditBone *) NULL;}
struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, char *name){return (struct EditBone*) NULL;}
struct Object *ED_object_pose_armature(struct Object *ob){ return (struct Object *)NULL; }
struct ListBase *get_active_constraints (struct Object *ob){return (struct ListBase *) NULL;}
struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **pchan_r){return (struct ListBase *) NULL;}
int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan){return 0;}