2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-23 19:47:33 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-23 19:47:33 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-23 19:47:33 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edanimation
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
#include <string.h>
|
2008-12-23 19:47:33 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2009-12-08 18:28:09 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2009-01-03 11:35:39 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2016-02-09 02:18:05 +13:00
|
|
|
#include "DNA_gpencil_types.h"
|
2009-01-03 11:35:39 +00:00
|
|
|
#include "DNA_object_types.h"
|
2009-12-21 09:52:43 +00:00
|
|
|
#include "DNA_node_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2009-12-21 09:52:43 +00:00
|
|
|
#include "DNA_sequence_types.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2009-12-08 18:28:09 +00:00
|
|
|
#include "BKE_animsys.h"
|
2009-12-21 09:52:43 +00:00
|
|
|
#include "BKE_action.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "BKE_context.h"
|
2014-05-19 00:24:45 +10:00
|
|
|
#include "BKE_fcurve.h"
|
2016-02-09 02:18:05 +13:00
|
|
|
#include "BKE_gpencil.h"
|
2018-06-07 12:47:00 +02:00
|
|
|
#include "BKE_main.h"
|
2009-12-21 09:52:43 +00:00
|
|
|
#include "BKE_node.h"
|
|
|
|
|
#include "BKE_sequencer.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
2008-12-23 19:47:33 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
2009-01-03 11:35:39 +00:00
|
|
|
#include "ED_anim_api.h"
|
2008-12-23 19:47:33 +00:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* **************************** depsgraph tagging ******************************** */
|
|
|
|
|
|
2009-12-08 18:28:09 +00:00
|
|
|
/* tags the given anim list element for refreshes (if applicable)
|
2018-06-01 18:19:39 +02:00
|
|
|
* due to Animation Editor editing
|
2009-12-21 09:52:43 +00:00
|
|
|
*/
|
2018-06-07 12:47:00 +02:00
|
|
|
void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
|
2009-12-08 18:28:09 +00:00
|
|
|
{
|
|
|
|
|
ID *id;
|
|
|
|
|
FCurve *fcu;
|
|
|
|
|
AnimData *adt;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
id = ale->id;
|
2009-12-21 09:52:43 +00:00
|
|
|
if (!id)
|
2009-12-08 18:28:09 +00:00
|
|
|
return;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-08 18:28:09 +00:00
|
|
|
/* tag AnimData for refresh so that other views will update in realtime with these changes */
|
2012-05-08 15:30:00 +00:00
|
|
|
adt = BKE_animdata_from_id(id);
|
2015-05-12 13:29:00 +05:00
|
|
|
if (adt) {
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(id, ID_RECALC_ANIMATION);
|
2018-05-28 16:45:28 +02:00
|
|
|
if (adt->action != NULL) {
|
2019-03-13 15:38:45 +01:00
|
|
|
DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION);
|
2018-05-28 16:45:28 +02:00
|
|
|
}
|
2015-05-12 13:29:00 +05:00
|
|
|
}
|
2009-12-08 18:28:09 +00:00
|
|
|
|
2018-11-12 16:17:57 +03:00
|
|
|
/* Tag copy on the main object if updating anything directly inside AnimData */
|
|
|
|
|
if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) {
|
2019-03-13 15:38:45 +01:00
|
|
|
DEG_id_tag_update(id, ID_RECALC_ANIMATION);
|
2018-11-12 16:17:57 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 18:28:09 +00:00
|
|
|
/* update data */
|
2012-05-08 15:30:00 +00:00
|
|
|
fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
if (fcu && fcu->rna_path) {
|
2009-12-08 18:28:09 +00:00
|
|
|
/* if we have an fcurve, call the update for the property we
|
2012-03-03 16:31:46 +00:00
|
|
|
* are editing, this is then expected to do the proper redraws
|
|
|
|
|
* and depsgraph updates */
|
2009-12-08 18:28:09 +00:00
|
|
|
PointerRNA id_ptr, ptr;
|
|
|
|
|
PropertyRNA *prop;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-08 18:28:09 +00:00
|
|
|
RNA_id_pointer_create(id, &id_ptr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Bugfix [#34836] Crash when driver variable has path == 'data'
Most of the places which relied on RNA_path_resolve() did so believing that if
it returned true, that it had found a valid property, and that the returned
pointer+property combination would be what the path referred to. However, it
turns out that if the property at the end of the path turns out to be a
"pointer" property (e.g. "data" for Object.data), this would automatically
become the pointer part, while the prop part would be set to null. Hence, if a
user accidentally (or otherwise) specifies a path for the single-property driver
variable type like this, then Blender would crash.
This commit introduces two convenience functions - RNA_path_resolve_property()
and RNA_path_resolve_property_full() - which mirror/wrap the existing
RNA_path_resolve() functions. The only difference though is that these include a
check to ensure that what was found from resolving the path was in fact a
property (they only return true iff this is the case), and make it explicitly
clear in the name that this is what they will do so that there's no further
confusion. It is possible to do without these wrapper functions by doing these
checks inline, but the few cases that had been patched already were pretty
hideous looking specimens. Using these just make it clearer and simpler for all.
I've also beefed up the docs on these a bit, and changed these to using bools.
2013-04-22 13:22:07 +00:00
|
|
|
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop))
|
2018-06-07 12:47:00 +02:00
|
|
|
RNA_property_update_main(bmain, scene, &ptr, prop);
|
2009-12-08 18:28:09 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2014-12-05 14:15:46 +13:00
|
|
|
/* in other case we do standard depsgraph update, ideally
|
2012-03-03 16:31:46 +00:00
|
|
|
* we'd be calling property update functions here too ... */
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); // XXX or do we want something more restrictive?
|
2009-12-08 18:28:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* tags the given ID block for refreshes (if applicable) due to
|
2009-12-08 18:28:09 +00:00
|
|
|
* Animation Editor editing */
|
2018-11-12 16:17:57 +03:00
|
|
|
void ANIM_id_update(Main *bmain, ID *id)
|
2009-12-08 18:28:09 +00:00
|
|
|
{
|
2009-12-21 09:52:43 +00:00
|
|
|
if (id) {
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update_ex(bmain, id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); // XXX or do we want something more restrictive?
|
2009-12-08 18:28:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* **************************** animation data <-> data syncing ******************************** */
|
2012-03-02 16:05:54 +00:00
|
|
|
/* This code here is used to synchronize the
|
2018-11-14 12:53:15 +11:00
|
|
|
* - selection (to find selected data easier)
|
|
|
|
|
* - ... (insert other relevant items here later)
|
2009-12-21 09:52:43 +00:00
|
|
|
* status in relevant Blender data with the status stored in animation channels.
|
2009-01-03 11:35:39 +00:00
|
|
|
*
|
2018-06-01 18:19:39 +02:00
|
|
|
* This should be called in the refresh() callbacks for various editors in
|
2009-12-21 09:52:43 +00:00
|
|
|
* response to appropriate notifiers.
|
2009-01-03 11:35:39 +00:00
|
|
|
*/
|
2009-12-21 09:52:43 +00:00
|
|
|
|
|
|
|
|
/* perform syncing updates for Action Groups */
|
2012-08-18 05:14:21 +00:00
|
|
|
static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGroup **active_agrp)
|
2009-01-03 11:35:39 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
bActionGroup *agrp = (bActionGroup *)ale->data;
|
|
|
|
|
ID *owner_id = ale->id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* major priority is selection status
|
|
|
|
|
* so we need both a group and an owner
|
|
|
|
|
*/
|
|
|
|
|
if (ELEM(NULL, agrp, owner_id))
|
2009-01-03 11:35:39 +00:00
|
|
|
return;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* for standard Objects, check if group is the name of some bone */
|
|
|
|
|
if (GS(owner_id->name) == ID_OB) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = (Object *)owner_id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
|
/* check if there are bones, and whether the name matches any
|
2009-12-21 09:52:43 +00:00
|
|
|
* NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone
|
|
|
|
|
*/
|
|
|
|
|
if (ob->pose) {
|
2012-05-08 15:30:00 +00:00
|
|
|
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
|
2012-08-18 05:14:21 +00:00
|
|
|
bArmature *arm = ob->data;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
if (pchan) {
|
2012-08-18 05:43:06 +00:00
|
|
|
bActionGroup *bgrp;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:14:21 +00:00
|
|
|
/* if one matches, sync the selection status */
|
|
|
|
|
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))
|
2009-12-21 09:52:43 +00:00
|
|
|
agrp->flag |= AGRP_SELECTED;
|
|
|
|
|
else
|
|
|
|
|
agrp->flag &= ~AGRP_SELECTED;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:14:21 +00:00
|
|
|
/* also sync active group status */
|
|
|
|
|
if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) {
|
|
|
|
|
/* if no previous F-Curve has active flag, then we're the first and only one to get it */
|
|
|
|
|
if (*active_agrp == NULL) {
|
|
|
|
|
agrp->flag |= AGRP_ACTIVE;
|
|
|
|
|
*active_agrp = agrp;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* someone else has already taken it - set as not active */
|
|
|
|
|
agrp->flag &= ~AGRP_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* this can't possibly be active now */
|
|
|
|
|
agrp->flag &= ~AGRP_ACTIVE;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:43:06 +00:00
|
|
|
/* sync group colors */
|
|
|
|
|
bgrp = (bActionGroup *)BLI_findlink(&ob->pose->agroups, (pchan->agrp_index - 1));
|
|
|
|
|
if (bgrp) {
|
|
|
|
|
agrp->customCol = bgrp->customCol;
|
|
|
|
|
action_group_colors_sync(agrp, bgrp);
|
|
|
|
|
}
|
2009-12-21 09:52:43 +00:00
|
|
|
}
|
2009-01-03 11:35:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-12-21 09:52:43 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* perform syncing updates for F-Curves */
|
2019-02-20 08:26:17 +11:00
|
|
|
static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale, FCurve **active_fcurve)
|
2009-01-03 11:35:39 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
FCurve *fcu = (FCurve *)ale->data;
|
|
|
|
|
ID *owner_id = ale->id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
|
|
|
|
/* major priority is selection status, so refer to the checks done in anim_filter.c
|
2009-12-21 09:52:43 +00:00
|
|
|
* skip_fcurve_selected_data() for reference about what's going on here...
|
|
|
|
|
*/
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(NULL, fcu, fcu->rna_path, owner_id))
|
2009-01-03 11:35:39 +00:00
|
|
|
return;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-02-19 15:56:44 +01:00
|
|
|
if (GS(owner_id->name) == ID_SCE) {
|
2009-12-21 09:52:43 +00:00
|
|
|
Scene *scene = (Scene *)owner_id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* only affect if F-Curve involves sequence_editor.sequences */
|
|
|
|
|
if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
|
2014-03-20 15:45:20 +06:00
|
|
|
Editing *ed = BKE_sequencer_editing_get(scene, false);
|
2009-12-21 09:52:43 +00:00
|
|
|
Sequence *seq;
|
|
|
|
|
char *seq_name;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* get strip name, and check if this strip is selected */
|
2012-07-09 22:16:50 +00:00
|
|
|
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
|
2014-04-01 11:34:00 +11:00
|
|
|
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
|
2009-12-21 09:52:43 +00:00
|
|
|
if (seq_name) MEM_freeN(seq_name);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:26:40 +00:00
|
|
|
/* update selection status */
|
2009-12-21 09:52:43 +00:00
|
|
|
if (seq) {
|
|
|
|
|
if (seq->flag & SELECT)
|
|
|
|
|
fcu->flag |= FCURVE_SELECTED;
|
|
|
|
|
else
|
|
|
|
|
fcu->flag &= ~FCURVE_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (GS(owner_id->name) == ID_NT) {
|
|
|
|
|
bNodeTree *ntree = (bNodeTree *)owner_id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* check for selected nodes */
|
|
|
|
|
if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
|
|
|
|
|
bNode *node;
|
|
|
|
|
char *node_name;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* get strip name, and check if this strip is selected */
|
2012-07-09 22:16:50 +00:00
|
|
|
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
|
2009-12-21 09:52:43 +00:00
|
|
|
node = nodeFindNodebyName(ntree, node_name);
|
|
|
|
|
if (node_name) MEM_freeN(node_name);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:26:40 +00:00
|
|
|
/* update selection/active status */
|
2009-12-21 09:52:43 +00:00
|
|
|
if (node) {
|
2012-08-18 05:26:40 +00:00
|
|
|
/* update selection status */
|
2009-12-21 09:52:43 +00:00
|
|
|
if (node->flag & NODE_SELECT)
|
|
|
|
|
fcu->flag |= FCURVE_SELECTED;
|
2009-01-05 09:54:39 +00:00
|
|
|
else
|
2009-12-21 09:52:43 +00:00
|
|
|
fcu->flag &= ~FCURVE_SELECTED;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:26:40 +00:00
|
|
|
/* update active status */
|
|
|
|
|
/* XXX: this may interfere with setting bones as active if both exist at once;
|
|
|
|
|
* then again, if that's the case, production setups aren't likely to be animating
|
|
|
|
|
* nodes while working with bones?
|
|
|
|
|
*/
|
|
|
|
|
if (node->flag & NODE_ACTIVE) {
|
|
|
|
|
if (*active_fcurve == NULL) {
|
|
|
|
|
fcu->flag |= FCURVE_ACTIVE;
|
|
|
|
|
*active_fcurve = fcu;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fcu->flag &= ~FCURVE_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fcu->flag &= ~FCURVE_ACTIVE;
|
|
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
2009-12-21 09:52:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-28 16:54:57 +13:00
|
|
|
/* perform syncing updates for GPencil Layers */
|
|
|
|
|
static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale)
|
|
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl = (bGPDlayer *)ale->data;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-12-28 16:54:57 +13:00
|
|
|
/* Make sure the selection flags agree with the "active" flag.
|
|
|
|
|
* The selection flags are used in the Dopesheet only, whereas
|
|
|
|
|
* the active flag is used everywhere else. Hence, we try to
|
|
|
|
|
* sync these here so that it all seems to be have as the user
|
|
|
|
|
* expects - T50184
|
|
|
|
|
*
|
|
|
|
|
* Assume that we only really do this when the active status changes.
|
|
|
|
|
* (NOTE: This may prove annoying if it means selection is always lost)
|
|
|
|
|
*/
|
|
|
|
|
if (gpl->flag & GP_LAYER_ACTIVE) {
|
|
|
|
|
gpl->flag |= GP_LAYER_SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
gpl->flag &= ~GP_LAYER_SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* ---------------- */
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* Main call to be exported to animation editors */
|
2012-04-29 17:11:40 +00:00
|
|
|
void ANIM_sync_animchannels_to_data(const bContext *C)
|
2009-12-21 09:52:43 +00:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
|
|
|
|
ListBase anim_data = {NULL, NULL};
|
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
int filter;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-18 05:14:21 +00:00
|
|
|
bActionGroup *active_agrp = NULL;
|
|
|
|
|
FCurve *active_fcurve = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* get animation context info for filtering the channels */
|
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
|
return;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* filter data */
|
2018-06-04 09:31:30 +02:00
|
|
|
/* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed
|
2012-08-18 05:14:21 +00:00
|
|
|
* However, don't include duplicates so that selection statuses don't override each other
|
|
|
|
|
*/
|
|
|
|
|
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS;
|
2009-12-21 09:52:43 +00:00
|
|
|
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
/* flush settings as appropriate depending on the types of the channels */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (ale = anim_data.first; ale; ale = ale->next) {
|
2009-12-21 09:52:43 +00:00
|
|
|
switch (ale->type) {
|
|
|
|
|
case ANIMTYPE_GROUP:
|
2012-08-18 05:14:21 +00:00
|
|
|
animchan_sync_group(&ac, ale, &active_agrp);
|
2009-12-21 09:52:43 +00:00
|
|
|
break;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-21 09:52:43 +00:00
|
|
|
case ANIMTYPE_FCURVE:
|
2012-08-18 05:14:21 +00:00
|
|
|
animchan_sync_fcurve(&ac, ale, &active_fcurve);
|
2009-12-21 09:52:43 +00:00
|
|
|
break;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-12-28 16:54:57 +13:00
|
|
|
case ANIMTYPE_GPLAYER:
|
|
|
|
|
animchan_sync_gplayer(&ac, ale);
|
|
|
|
|
break;
|
2009-01-03 11:35:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-05-19 00:24:45 +10:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
|
|
|
|
|
{
|
|
|
|
|
bAnimListElem *ale;
|
|
|
|
|
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ELEM(ac->datatype, ANIMCONT_MASK)) {
|
2014-06-09 20:03:28 +10:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
/* quiet assert */
|
|
|
|
|
for (ale = anim_data->first; ale; ale = ale->next) {
|
|
|
|
|
ale->update = 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-05-19 00:24:45 +10:00
|
|
|
return;
|
2014-06-09 20:03:28 +10:00
|
|
|
}
|
2014-05-19 00:24:45 +10:00
|
|
|
|
|
|
|
|
for (ale = anim_data->first; ale; ale = ale->next) {
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ale->type == ANIMTYPE_GPLAYER) {
|
|
|
|
|
bGPDlayer *gpl = ale->data;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ale->update & ANIM_UPDATE_ORDER) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_ORDER;
|
|
|
|
|
if (gpl) {
|
|
|
|
|
//gpencil_sort_frames(gpl);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ale->update & ANIM_UPDATE_DEPS) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_DEPS;
|
2018-06-07 12:47:00 +02:00
|
|
|
ANIM_list_elem_update(ac->bmain, ac->scene, ale);
|
2016-02-09 02:18:05 +13:00
|
|
|
}
|
2018-09-19 16:46:56 +02:00
|
|
|
/* disable handles to avoid crash */
|
|
|
|
|
if (ale->update & ANIM_UPDATE_HANDLES) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_HANDLES;
|
|
|
|
|
}
|
2014-05-19 00:24:45 +10:00
|
|
|
}
|
2016-02-09 02:18:05 +13:00
|
|
|
else if (ale->datatype == ALE_FCURVE) {
|
|
|
|
|
FCurve *fcu = ale->key_data;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ale->update & ANIM_UPDATE_ORDER) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_ORDER;
|
|
|
|
|
if (fcu)
|
|
|
|
|
sort_time_fcurve(fcu);
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ale->update & ANIM_UPDATE_HANDLES) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_HANDLES;
|
|
|
|
|
if (fcu)
|
|
|
|
|
calchandles_fcurve(fcu);
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-02-09 02:18:05 +13:00
|
|
|
if (ale->update & ANIM_UPDATE_DEPS) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_DEPS;
|
2018-06-07 12:47:00 +02:00
|
|
|
ANIM_list_elem_update(ac->bmain, ac->scene, ale);
|
2016-02-09 02:18:05 +13:00
|
|
|
}
|
2014-05-19 00:24:45 +10:00
|
|
|
}
|
2018-11-12 16:17:57 +03:00
|
|
|
else if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) {
|
2016-05-28 19:50:05 +02:00
|
|
|
if (ale->update & ANIM_UPDATE_DEPS) {
|
|
|
|
|
ale->update &= ~ANIM_UPDATE_DEPS;
|
2018-06-07 12:47:00 +02:00
|
|
|
ANIM_list_elem_update(ac->bmain, ac->scene, ale);
|
2016-05-28 19:50:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-07-31 10:22:19 +02:00
|
|
|
else if (ale->update) {
|
|
|
|
|
#if 0
|
|
|
|
|
if (G.debug & G_DEBUG) {
|
|
|
|
|
printf("%s: Unhandled animchannel updates (%d) for type=%d (%p)\n",
|
|
|
|
|
__func__, ale->update, ale->type, ale->data);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
/* Prevent crashes in cases where it can't be handled */
|
|
|
|
|
ale->update = 0;
|
|
|
|
|
}
|
2016-05-28 19:50:05 +02:00
|
|
|
|
2014-05-19 00:24:45 +10:00
|
|
|
BLI_assert(ale->update == 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ANIM_animdata_freelist(ListBase *anim_data)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
bAnimListElem *ale, *ale_next;
|
|
|
|
|
for (ale = anim_data->first; ale; ale = ale_next) {
|
|
|
|
|
ale_next = ale->next;
|
|
|
|
|
BLI_assert(ale->update == 0);
|
|
|
|
|
MEM_freeN(ale);
|
|
|
|
|
}
|
|
|
|
|
BLI_listbase_clear(anim_data);
|
|
|
|
|
#else
|
|
|
|
|
BLI_freelistN(anim_data);
|
|
|
|
|
#endif
|
2009-01-03 11:35:39 +00:00
|
|
|
}
|