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:
authorJoshua Leung <aligorith@gmail.com>2011-04-19 17:01:50 +0400
committerJoshua Leung <aligorith@gmail.com>2011-04-19 17:01:50 +0400
commit94b99b5d4a7c20cf2f4488b599e74619a7c860a6 (patch)
tree3ab0c737968a6d739e72b2a990eedbbdc329ac57 /source/blender/blenkernel/intern/anim_sys.c
parentc4debb1c642af4f97818d1e33986223b69b0aa6d (diff)
Bugfix [#25960] Action/NLA Editor issues with animdata context
Actions now get tagged with an ID-code, which is used to determine what ID-blocks they can be assigned to. This ensures that material actions cannot be assigned to the object-level for example. * Action lists in general will now show only the actions that can be set for that particular slot. This prevents selection of invalid actions, and helps cut down the list of actions. ** An exception here is the Add Action Clip in NLA Editor, which will show all actions but will only add where appropriate. This is because it's not easy/possible to tell in advance which blocktypes to filter for when building this list. (TODO?) * The "Action Editor" is now strictly for object-level action editing+setting now. This avoids repeateded confusion by people who try using this to view their shapekey actions, which should go to the Shape Key Editor instead! ** A context switcher for the legitimate times where this capability might come in handy is still being investigated. * "Floating" actions (i.e. actions in some action_library.blend) are NOT able to be automatically tagged until they are assigned to some datablocks (i.e. loaded onto the rig + played back once). It is possible to write scripts that check for certain RNA-paths and "guess" what datablocks they work on, but it is recommended that you load up the Datablocks Viewer, and go through such actions by hand, setting the "ID Root Type" property as appropriate per action.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 2708239a4c3..f7eaff475fa 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1199,6 +1199,39 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
/* ***************************************** */
/* Actions Evaluation */
+/* strictly not necessary for actual "evaluation", but it is a useful safety check
+ * to reduce the amount of times that users end up having to "revive" wrongly-assigned
+ * actions
+ */
+static void action_idcode_patch_check (ID *id, bAction *act)
+{
+ int idcode = 0;
+
+ /* just in case */
+ if (ELEM(NULL, id, act))
+ return;
+ else
+ idcode = GS(id->name);
+
+ /* the actual checks... hopefully not too much of a performance hit in the long run... */
+ if (act->idroot == 0) {
+ /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds)
+ * - this has problems if there are 2 users, and the first one encountered is the invalid one
+ * in which case, the user will need to manually fix this (?)
+ */
+ act->idroot = idcode;
+ }
+ else if (act->idroot != idcode) {
+ /* only report this error if debug mode is enabled (to save performance everywhere else) */
+ if (G.f & G_DEBUG) {
+ printf("AnimSys Safety Check Failed: Action '%s' is not meant to be used from ID-Blocks of type %d such as '%s'\n",
+ act->id.name+2, idcode, id->name);
+ }
+ }
+}
+
+/* ----------------------------------------- */
+
/* Evaluate Action Group */
void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup *agrp, AnimMapper *remap, float ctime)
{
@@ -1208,6 +1241,8 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup
if ELEM(NULL, act, agrp) return;
if ((remap) && (remap->target != act)) remap= NULL;
+ action_idcode_patch_check(ptr->id.data, act);
+
/* if group is muted, don't evaluated any of the F-Curve */
if (agrp->flag & AGRP_MUTED)
return;
@@ -1231,6 +1266,8 @@ void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper *remap,
if (act == NULL) return;
if ((remap) && (remap->target != act)) remap= NULL;
+ action_idcode_patch_check(ptr->id.data, act);
+
/* calculate then execute each curve */
animsys_evaluate_fcurves(ptr, &act->curves, remap, ctime);
}
@@ -1630,6 +1667,17 @@ static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, L
FCurve *fcu;
float evaltime;
+ /* sanity checks for action */
+ if (strip == NULL)
+ return;
+
+ if (strip->act == NULL) {
+ printf("NLA-Strip Eval Error: Strip '%s' has no Action\n", strip->name);
+ return;
+ }
+
+ action_idcode_patch_check(ptr->id.data, strip->act);
+
/* join this strip's modifiers to the parent's modifiers (own modifiers first) */
nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);