Anim: added BKE_object_moves_in_time(object) function

This function exposes the already-existing static `object_moves_in_time()`
function, and optionally recursively checks the parent object for
animatedness as well.

I also added checking `AnimData::overrides` to
`BKE_animdata_id_is_animated()`. This ensures that, apart from the optional
recursion to the parent object, the function has the same functionality.
This commit is contained in:
2019-11-26 17:59:27 +01:00
parent b21648ab36
commit bf9c2e6fde
3 changed files with 15 additions and 12 deletions

View File

@@ -350,6 +350,8 @@ bool BKE_object_is_child_recursive(const struct Object *ob_parent, const struct
int BKE_object_is_modified(struct Scene *scene, struct Object *ob); int BKE_object_is_modified(struct Scene *scene, struct Object *ob);
int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob); int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob);
bool BKE_object_moves_in_time(const struct Object *object, bool recurse_parent);
int BKE_object_scenes_users_get(struct Main *bmain, struct Object *ob); int BKE_object_scenes_users_get(struct Main *bmain, struct Object *ob);
struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct MovieClip *BKE_object_movieclip_get(struct Scene *scene,

View File

@@ -298,7 +298,8 @@ bool BKE_animdata_id_is_animated(const struct ID *id)
return true; return true;
} }
return !BLI_listbase_is_empty(&adt->drivers) || !BLI_listbase_is_empty(&adt->nla_tracks); return !BLI_listbase_is_empty(&adt->drivers) || !BLI_listbase_is_empty(&adt->nla_tracks) ||
!BLI_listbase_is_empty(&adt->overrides);
} }
/* Copying -------------------------------------------- */ /* Copying -------------------------------------------- */

View File

@@ -3763,26 +3763,26 @@ int BKE_object_is_modified(Scene *scene, Object *ob)
* speed. In combination with checks of modifier stack and real life usage * speed. In combination with checks of modifier stack and real life usage
* percentage of false-positives shouldn't be that height. * percentage of false-positives shouldn't be that height.
*/ */
static bool object_moves_in_time(Object *object) bool BKE_object_moves_in_time(const Object *object, bool recurse_parent)
{ {
AnimData *adt = object->adt; /* If object has any sort of animation data assume it is moving. */
if (adt != NULL) { if (BKE_animdata_id_is_animated(&object->id)) {
/* If object has any sort of animation data assume it is moving. */ return true;
if (adt->action != NULL || !BLI_listbase_is_empty(&adt->nla_tracks) ||
!BLI_listbase_is_empty(&adt->drivers) || !BLI_listbase_is_empty(&adt->overrides)) {
return true;
}
} }
if (!BLI_listbase_is_empty(&object->constraints)) { if (!BLI_listbase_is_empty(&object->constraints)) {
return true; return true;
} }
if (object->parent != NULL) { if (recurse_parent && object->parent != NULL) {
/* TODO(sergey): Do recursive check here? */ return BKE_object_moves_in_time(object->parent, true);
return true;
} }
return false; return false;
} }
static bool object_moves_in_time(const Object *object)
{
return BKE_object_moves_in_time(object, true);
}
static bool object_deforms_in_time(Object *object) static bool object_deforms_in_time(Object *object)
{ {
if (BKE_key_from_object(object) != NULL) { if (BKE_key_from_object(object) != NULL) {