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:
authorMatt Ebb <matt@mke3.net>2009-09-21 10:43:20 +0400
committerMatt Ebb <matt@mke3.net>2009-09-21 10:43:20 +0400
commitfcab32fa206838caf1c45c0cdf5facc65e2d6918 (patch)
tree8919adf821400e8ddeb464c0ee45a513b2d4ac83
parentad7fab49d4346315cdb3db4bd087714ae45ffc89 (diff)
* Added AnimData for Armature data, for animating armature/bone settings.
This allows you to do funky things like animating the number of segments in a b-bone.
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c5
-rw-r--r--source/blender/blenloader/intern/readfile.c16
-rw-r--r--source/blender/blenloader/intern/writefile.c2
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c71
-rw-r--r--source/blender/editors/animation/anim_filter.c45
-rw-r--r--source/blender/editors/include/ED_anim_api.h2
-rw-r--r--source/blender/makesdna/DNA_action_types.h1
-rw-r--r--source/blender/makesdna/DNA_armature_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_armature.c9
9 files changed, 145 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 8b761a2ee0e..af4bcd8b0f7 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -72,7 +72,7 @@ static short id_has_animdata (ID *id)
switch (GS(id->name)) {
/* has AnimData */
case ID_OB:
- case ID_MB: case ID_CU:
+ case ID_MB: case ID_CU: case ID_AR:
case ID_KE:
case ID_PA:
case ID_MA: case ID_TE: case ID_NT:
@@ -1525,6 +1525,9 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM);
}
+ /* armatures */
+ EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM);
+
/* meshes */
// TODO...
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 78949d8bd8c..af7fda82fe4 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2331,6 +2331,7 @@ static void lib_link_armature(FileData *fd, Main *main)
while(arm) {
if(arm->id.flag & LIB_NEEDLINK) {
+ if (arm->adt) lib_link_animdata(fd, &arm->id, arm->adt);
arm->id.flag -= LIB_NEEDLINK;
}
arm= arm->id.next;
@@ -2357,6 +2358,7 @@ static void direct_link_armature(FileData *fd, bArmature *arm)
link_list(fd, &arm->bonebase);
arm->edbo= NULL;
arm->sketch = NULL;
+ arm->adt= newdataadr(fd, arm->adt);
bone=arm->bonebase.first;
while (bone) {
@@ -9697,15 +9699,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
sce->unit.scale_length= 1.0f;
for(ob = main->object.first; ob; ob = ob->id.next) {
- ModifierData *md;
-
- /* add backwards pointer for fluidsim modifier RNA access */
- for (md=ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Fluidsim) {
- FluidsimModifierData *fluidmd= (FluidsimModifierData*) md;
- fluidmd->fss->fmd = fluidmd;
- }
- }
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+ if (fluidmd) fluidmd->fss->fmd = fluidmd;
}
for(sce= main->scene.first; sce; sce= sce->id.next)
@@ -10434,6 +10429,9 @@ static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
{
Bone *curBone;
+ if(arm->adt)
+ expand_animdata(fd, mainvar, arm->adt);
+
for (curBone = arm->bonebase.first; curBone; curBone=curBone->next) {
expand_bones(fd, mainvar, curBone);
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 98db27182ab..37d0ee58bb2 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2116,6 +2116,8 @@ static void write_armatures(WriteData *wd, ListBase *idbase)
writestruct(wd, ID_AR, "bArmature", 1, arm);
if (arm->id.properties) IDP_WriteProperty(arm->id.properties, wd);
+ if (arm->adt) write_animdata(wd, arm->adt);
+
/* Direct data */
bone= arm->bonebase.first;
while(bone) {
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index e3418fa194f..7f0f2411bd0 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -1526,6 +1526,76 @@ static bAnimChannelType ACF_DSMBALL=
acf_dsmball_setting_ptr /* pointer for setting */
};
+/* Armature Expander ------------------------------------------- */
+
+// TODO: just get this from RNA?
+static int acf_dsarm_icon(bAnimListElem *ale)
+{
+ return ICON_ARMATURE_DATA;
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_dsarm_setting_flag(int setting, short *neg)
+{
+ /* clear extra return data first */
+ *neg= 0;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_EXPAND: /* expanded */
+ return ARM_DS_EXPAND;
+
+ case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
+ return ADT_NLA_EVAL_OFF;
+
+ case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
+ *neg= 1;
+ return ADT_CURVES_NOT_VISIBLE;
+
+ default: /* unsupported */
+ return 0;
+ }
+}
+
+/* get pointer to the setting */
+static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type)
+{
+ bArmature *arm= (bArmature *)ale->data;
+
+ /* clear extra return data first */
+ *type= 0;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_EXPAND: /* expanded */
+ GET_ACF_FLAG_PTR(arm->flag);
+
+ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
+ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
+ if (arm->adt)
+ GET_ACF_FLAG_PTR(arm->adt->flag)
+ else
+ return NULL;
+
+ default: /* unsupported */
+ return NULL;
+ }
+}
+
+/* metaball expander type define */
+static bAnimChannelType ACF_DSARM=
+{
+ acf_generic_dataexpand_backdrop,/* backdrop */
+ acf_generic_indention_1, /* indent level */
+ acf_generic_basic_offset, /* offset */
+
+ acf_generic_idblock_name, /* name */
+ acf_dsarm_icon, /* icon */
+
+ acf_generic_dataexpand_setting_valid, /* has setting */
+ acf_dsarm_setting_flag, /* flag for setting */
+ acf_dsarm_setting_ptr /* pointer for setting */
+};
+
+
/* ShapeKey Entry ------------------------------------------- */
// XXX ... this is currently obsolete...
@@ -1709,6 +1779,7 @@ void ANIM_init_channel_typeinfo_data (void)
animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */
animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */
animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */
+ animchannelTypeInfo[type++]= &ACF_DSARM; /* Armature Channel */
animchannelTypeInfo[type++]= NULL; /* ShapeKey */ // XXX this is no longer used for now...
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 55fb1ccace0..38b702f81e0 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -52,6 +52,7 @@
#include "DNA_ID.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"
+#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
@@ -1101,6 +1102,14 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
expanded= FILTER_MBALL_OBJD(mb);
}
break;
+ case OB_ARMATURE: /* ------- Armature ---------- */
+ {
+ bArmature *arm= (bArmature *)ob->data;
+
+ type= ANIMTYPE_DSARM;
+ expanded= FILTER_ARM_OBJD(arm);
+ }
+ break;
}
/* special exception for drivers instead of action */
@@ -1297,6 +1306,19 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
}
}
break;
+ case OB_ARMATURE: /* ------- Armature ---------- */
+ {
+ bArmature *arm= (bArmature *)ob->data;
+
+ if ((ads->filterflag & ADS_FILTER_NOARM) == 0) {
+ ANIMDATA_FILTER_CASES(arm,
+ { /* AnimData blocks - do nothing... */ },
+ obdata_ok= 1;,
+ obdata_ok= 1;,
+ obdata_ok= 1;)
+ }
+ }
+ break;
}
if (obdata_ok)
items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
@@ -1652,6 +1674,23 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);)
}
break;
+ case OB_ARMATURE: /* ------- Armature ---------- */
+ {
+ bArmature *arm= (bArmature *)ob->data;
+ dataOk= 0;
+ ANIMDATA_FILTER_CASES(arm,
+ if ((ads->filterflag & ADS_FILTER_NOARM)==0) {
+ /* for the special AnimData blocks only case, we only need to add
+ * the block if it is valid... then other cases just get skipped (hence ok=0)
+ */
+ ANIMDATA_ADD_ANIMDATA(arm);
+ dataOk=0;
+ },
+ dataOk= !(ads->filterflag & ADS_FILTER_NOARM);,
+ dataOk= !(ads->filterflag & ADS_FILTER_NOARM);,
+ dataOk= !(ads->filterflag & ADS_FILTER_NOARM);)
+ }
+ break;
default: /* --- other --- */
dataOk= 0;
break;
@@ -1734,6 +1773,12 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
dataOk= ANIMDATA_HAS_KEYS(mb);
}
break;
+ case OB_ARMATURE: /* -------- Armature ---------- */
+ {
+ bArmature *arm= (bArmature *)ob->data;
+ dataOk= ANIMDATA_HAS_KEYS(arm);
+ }
+ break;
default: /* --- other --- */
dataOk= 0;
break;
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 799829a6e87..7e7aba85363 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -137,6 +137,7 @@ typedef enum eAnim_ChannelType {
ANIMTYPE_DSWOR,
ANIMTYPE_DSPART,
ANIMTYPE_DSMBALL,
+ ANIMTYPE_DSARM,
ANIMTYPE_SHAPEKEY, // XXX probably can become depreceated???
@@ -206,6 +207,7 @@ typedef enum eAnimFilter_Flags {
#define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND))
#define FILTER_PART_OBJD(part) ((part->flag & PART_DS_EXPAND))
#define FILTER_MBALL_OBJD(mb) ((mb->flag2 & MB_DS_EXPAND))
+#define FILTER_ARM_OBJD(arm) ((arm->flag & ARM_DS_EXPAND))
/* 'Sub-object/Action' channels (flags stored in Action) */
#define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED))
#define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0)
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 318204e3dd8..42696eeb092 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -372,6 +372,7 @@ typedef enum DOPESHEET_FILTERFLAG {
ADS_FILTER_NOSCE = (1<<15),
ADS_FILTER_NOPART = (1<<16),
ADS_FILTER_NOMBA = (1<<17),
+ ADS_FILTER_NOARM = (1<<18),
/* NLA-specific filters */
ADS_FILTER_NLA_NOACT = (1<<20), /* if the AnimData block has no NLA data, don't include to just show Action-line */
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index bb60fb107ff..590e7dadcdc 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -31,6 +31,8 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
+struct AnimData;
+
/* this system works on different transformation space levels;
1) Bone Space; with each Bone having own (0,0,0) origin
@@ -69,6 +71,7 @@ typedef struct Bone {
typedef struct bArmature {
ID id;
+ struct AnimData *adt;
ListBase bonebase;
ListBase chainbase;
ListBase *edbo; /* editbone listbase, we use pointer so we can check state */
@@ -102,7 +105,8 @@ typedef enum eArmature_Flag {
ARM_AUTO_IK = (1<<9),
ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */
ARM_COL_CUSTOM = (1<<11), /* draw custom colours */
- ARM_GHOST_ONLYSEL = (1<<12) /* when ghosting, only show selected bones (this should belong to ghostflag instead) */
+ ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */
+ ARM_DS_EXPAND = (1<<13)
} eArmature_Flag;
/* armature->drawtype */
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index d06c8ccee03..379ec208bc1 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -62,6 +62,11 @@ static void rna_Armature_redraw_data(bContext *C, PointerRNA *ptr)
WM_event_add_notifier(C, NC_GEOM|ND_DATA, id);
}
+static char *rna_Bone_path(PointerRNA *ptr)
+{
+ return BLI_sprintfN("bones[\"%s\"]", ((Bone*)ptr->data)->name);
+}
+
static void rna_bone_layer_set(short *layer, const int *values)
{
int i, tot= 0;
@@ -431,6 +436,7 @@ static void rna_def_bone(BlenderRNA *brna)
srna= RNA_def_struct(brna, "Bone", NULL);
RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock.");
RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
+ RNA_def_struct_path_func(srna, "rna_Bone_path");
/* pointers/collections */
/* parent (pointer) */
@@ -553,9 +559,10 @@ static void rna_def_armature(BlenderRNA *brna)
srna= RNA_def_struct(brna, "Armature", "ID");
RNA_def_struct_ui_text(srna, "Armature", "Armature datablock containing a hierarchy of bones, usually used for rigging characters.");
RNA_def_struct_ui_icon(srna, ICON_ARMATURE_DATA);
-
RNA_def_struct_sdna(srna, "bArmature");
+ rna_def_animdata_common(srna);
+
/* Collections */
prop= RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "bonebase", NULL);