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-08-15 14:37:26 +0400
committerJoshua Leung <aligorith@gmail.com>2011-08-15 14:37:26 +0400
commit674d1b8d68330113967fd0bb6b34edaf9c619cae (patch)
treedc32f16eb7244ec12fe22de21ccdf09db32a3dc1 /source/blender
parentc8ae881b619ec2d2d05b3c55283ca1f4c69828ca (diff)
Select by Keying Set...
* Split off code to refresh relative/builtin KeyingSets for the current context before they get used to a separate function. * Hooked this up to a new PyAPI/RNA function: KeyingSet.refresh(). Call this before checking the paths that a Keying Set has, especially if it is not "absolute" * Added option for "Select Grouped" operator (for Objects), which will select all objects affected by the active Keying Set. This is probably more useful for absolute KeyingSets, where changing the selection is less likely to affect the result. - The equivalent for bones is currently still in development, but is likely to be more useful for animators, where rigs are the primary animation entities they deal with
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/animation/keyingsets.c69
-rw-r--r--source/blender/editors/include/ED_keyframing.h3
-rw-r--r--source/blender/editors/object/object_select.c40
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c33
4 files changed, 120 insertions, 25 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 69abd1cb5a4..dcd1c3abbde 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -875,33 +875,19 @@ void ANIM_relative_keyingset_add_source (ListBase *dsources, ID *id, StructRNA *
/* KeyingSet Operations (Insert/Delete Keyframes) ------------ */
-/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified
- * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
- * Returns the number of channels that keyframes were added to
+/* Given a KeyingSet and context info, validate Keying Set's paths.
+ * This is only really necessary with relative/built-in KeyingSets
+ * where their list of paths is dynamically generated based on the
+ * current context info.
+ *
+ * Returns 0 if succeeded, otherwise an error code: eModifyKey_Returns
*/
-int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
+short ANIM_validate_keyingset (bContext *C, ListBase *dsources, KeyingSet *ks)
{
- Scene *scene= CTX_data_scene(C);
- ReportList *reports = CTX_wm_reports(C);
- KS_Path *ksp;
- int kflag=0, success= 0;
- char *groupname= NULL;
-
- /* sanity checks */
+ /* sanity check */
if (ks == NULL)
return 0;
- /* get flags to use */
- if (mode == MODIFYKEY_MODE_INSERT) {
- /* use KeyingSet's flags as base */
- kflag= ks->keyingflag;
-
- /* suppliment with info from the context */
- kflag |= ANIM_get_keyframing_flags(scene, 1);
- }
- else if (mode == MODIFYKEY_MODE_DELETE)
- kflag= 0;
-
/* if relative Keying Sets, poll and build up the paths */
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo);
@@ -936,6 +922,45 @@ int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingS
}
}
+ /* succeeded; return 0 to tag error free */
+ return 0;
+}
+
+/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified
+ * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
+ * Returns the number of channels that keyframes were added to
+ */
+int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
+{
+ Scene *scene= CTX_data_scene(C);
+ ReportList *reports = CTX_wm_reports(C);
+ KS_Path *ksp;
+ int kflag=0, success= 0;
+ char *groupname= NULL;
+
+ /* sanity checks */
+ if (ks == NULL)
+ return 0;
+
+ /* get flags to use */
+ if (mode == MODIFYKEY_MODE_INSERT) {
+ /* use KeyingSet's flags as base */
+ kflag= ks->keyingflag;
+
+ /* suppliment with info from the context */
+ kflag |= ANIM_get_keyframing_flags(scene, 1);
+ }
+ else if (mode == MODIFYKEY_MODE_DELETE)
+ kflag= 0;
+
+ /* if relative Keying Sets, poll and build up the paths */
+ success = ANIM_validate_keyingset(C, dsources, ks);
+
+ if (success != 0) {
+ /* return error code if failed */
+ return success;
+ }
+
/* apply the paths as specified in the KeyingSet now */
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
int arraylen, i;
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 9dbe86bc5ac..cda3c4f3e71 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -176,6 +176,9 @@ typedef enum eModifyKey_Returns {
MODIFYKEY_MISSING_TYPEINFO = -2,
} eModifyKey_Returns;
+/* poll the current KeyingSet, updating it's set of paths (if "builtin"/"relative") for context changes */
+short ANIM_validate_keyingset(struct bContext *C, ListBase *dsources, struct KeyingSet *ks);
+
/* use the specified KeyingSet to add/remove various Keyframes on the specified frame */
int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction *act, struct KeyingSet *ks, short mode, float cfra);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index a3bd399a60c..b3c4ffc0ac9 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -37,6 +37,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
@@ -65,6 +66,7 @@
#include "ED_object.h"
#include "ED_screen.h"
+#include "ED_keyframing.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -363,6 +365,7 @@ static EnumPropertyItem prop_select_grouped_types[] = {
{9, "PASS", 0, "Pass", "Render pass Index"},
{10, "COLOR", 0, "Color", "Object Color"},
{11, "PROPERTIES", 0, "Properties", "Game Properties"},
+ {12, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"},
{0, NULL, 0, NULL, NULL}
};
@@ -574,6 +577,42 @@ static short select_grouped_gameprops(bContext *C, Object *ob)
return changed;
}
+static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob))
+{
+ KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
+ short changed = 0;
+
+ /* firstly, validate KeyingSet */
+ if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0))
+ return 0;
+
+ /* select each object that Keying Set refers to */
+ // TODO: perhaps to be more in line with the rest of these, we should only take objects
+ // if the passed in object is included in this too
+ CTX_DATA_BEGIN(C, Base*, base, selectable_bases)
+ {
+ /* only check for this object if it isn't selected already, to limit time wasted */
+ if ((base->flag & SELECT) == 0) {
+ KS_Path *ksp;
+
+ /* this is the slow way... we could end up with > 500 items here,
+ * with none matching, but end up doing this on 1000 objects...
+ */
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ /* if id matches, select then stop looping (match found) */
+ if (ksp->id == base->object) {
+ ED_base_object_select(base, BA_SELECT);
+ changed = 1;
+ break;
+ }
+ }
+ }
+ }
+ CTX_DATA_END;
+
+ return changed;
+}
+
static int object_select_grouped_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
@@ -608,6 +647,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
else if(nr==9) changed |= select_grouped_index_object(C, ob);
else if(nr==10) changed |= select_grouped_color(C, ob);
else if(nr==11) changed |= select_grouped_gameprops(C, ob);
+ else if(nr==12) changed |= select_grouped_keyingset(C, ob);
if (changed) {
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index b3d2c02d0e4..714a74ec424 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -39,16 +39,43 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+
#ifdef RNA_RUNTIME
-#include "BKE_animsys.h"
+#include "BKE_context.h"
+#include "BKE_report.h"
+
+#include "ED_keyframing.h"
+
+static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList *reports)
+{
+ // TODO: enable access to providing a list of overrides (dsources)?
+ int success = ANIM_validate_keyingset(C, NULL, ks);
+
+ if (success != 0) {
+ switch (success) {
+ case MODIFYKEY_INVALID_CONTEXT:
+ BKE_report(reports, RPT_ERROR, "Invalid context for Keying Set");
+ break;
+
+ case MODIFYKEY_MISSING_TYPEINFO:
+ BKE_report(reports, RPT_ERROR, "Incomplete built-in Keying Set. Appears to be missing type info");
+ break;
+ }
+ }
+}
#else
void RNA_api_keyingset(StructRNA *srna)
{
-// FunctionRNA *func;
-// PropertyRNA *parm;
+ FunctionRNA *func;
+ //PropertyRNA *parm;
+
+ /* validate relative Keying Set (used to ensure paths are ok for context) */
+ func= RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh");
+ RNA_def_function_ui_description(func, "Refresh Keying Set to ensure that it is valid for the current context. Call before each use of one");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
}
#endif