[Bf-blender-cvs] [69aecad5477] temp-test-point-cloud-simulation-depsgraph-integration: Merge branch 'master' into simulation-data-block

Jacques Lucke noreply at git.blender.org
Wed Apr 15 18:27:10 CEST 2020


Commit: 69aecad5477dd3a01c3bf600d2f32d4b08c9e6a4
Author: Jacques Lucke
Date:   Mon Apr 6 11:51:57 2020 +0200
Branches: temp-test-point-cloud-simulation-depsgraph-integration
https://developer.blender.org/rB69aecad5477dd3a01c3bf600d2f32d4b08c9e6a4

Merge branch 'master' into simulation-data-block

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/anim_data.c
index 00000000000,41bfc5b59e4..f77e2ea1e0d
mode 000000,100644..100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@@ -1,0 -1,1435 +1,1442 @@@
+ /*
+  * 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
+  * of the License, or (at your option) any later version.
+  *
+  * 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,
+  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  *
+  * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
+  * All rights reserved.
+  */
+ 
+ /** \file
+  * \ingroup bke
+  */
+ #include "MEM_guardedalloc.h"
+ 
+ #include <string.h>
+ 
+ #include "BKE_action.h"
+ #include "BKE_anim_data.h"
+ #include "BKE_animsys.h"
+ #include "BKE_context.h"
+ #include "BKE_fcurve.h"
+ #include "BKE_global.h"
+ #include "BKE_lib_id.h"
+ #include "BKE_main.h"
+ #include "BKE_nla.h"
+ #include "BKE_node.h"
+ #include "BKE_report.h"
+ 
+ #include "DNA_ID.h"
+ #include "DNA_anim_types.h"
+ #include "DNA_light_types.h"
+ #include "DNA_node_types.h"
+ #include "DNA_space_types.h"
+ #include "DNA_windowmanager_types.h"
+ #include "DNA_world_types.h"
+ 
+ #include "BLI_alloca.h"
+ #include "BLI_dynstr.h"
+ #include "BLI_listbase.h"
+ #include "BLI_string.h"
+ #include "BLI_utildefines.h"
+ 
+ #include "DEG_depsgraph.h"
+ 
+ #include "RNA_access.h"
+ 
+ #include "CLG_log.h"
+ 
+ static CLG_LogRef LOG = {"bke.anim_sys"};
+ 
+ /* ***************************************** */
+ /* AnimData API */
+ 
+ /* Getter/Setter -------------------------------------------- */
+ 
+ /* Check if ID can have AnimData */
+ bool id_type_can_have_animdata(const short id_type)
+ {
+   /* Only some ID-blocks have this info for now */
+   /* TODO: finish adding this for the other blocktypes */
+   switch (id_type) {
+     /* has AnimData */
+     case ID_OB:
+     case ID_ME:
+     case ID_MB:
+     case ID_CU:
+     case ID_AR:
+     case ID_LT:
+     case ID_KE:
+     case ID_PA:
+     case ID_MA:
+     case ID_TE:
+     case ID_NT:
+     case ID_LA:
+     case ID_CA:
+     case ID_WO:
+     case ID_LS:
+     case ID_LP:
+     case ID_SPK:
+     case ID_SCE:
+     case ID_MC:
+     case ID_MSK:
+     case ID_GD:
+     case ID_CF:
+     case ID_HA:
+     case ID_PT:
+     case ID_VO:
++    case ID_SIM:
+       return true;
+ 
+     /* no AnimData */
+     default:
+       return false;
+   }
+ }
+ 
+ bool id_can_have_animdata(const ID *id)
+ {
+   /* sanity check */
+   if (id == NULL) {
+     return false;
+   }
+ 
+   return id_type_can_have_animdata(GS(id->name));
+ }
+ 
+ /* Get AnimData from the given ID-block. In order for this to work, we assume that
+  * the AnimData pointer is stored immediately after the given ID-block in the struct,
+  * as per IdAdtTemplate.
+  */
+ AnimData *BKE_animdata_from_id(ID *id)
+ {
+   /* only some ID-blocks have this info for now, so we cast the
+    * types that do to be of type IdAdtTemplate, and extract the
+    * AnimData that way
+    */
+   if (id_can_have_animdata(id)) {
+     IdAdtTemplate *iat = (IdAdtTemplate *)id;
+     return iat->adt;
+   }
+   else {
+     return NULL;
+   }
+ }
+ 
+ /* Add AnimData to the given ID-block. In order for this to work, we assume that
+  * the AnimData pointer is stored immediately after the given ID-block in the struct,
+  * as per IdAdtTemplate. Also note that
+  */
+ AnimData *BKE_animdata_add_id(ID *id)
+ {
+   /* Only some ID-blocks have this info for now, so we cast the
+    * types that do to be of type IdAdtTemplate, and add the AnimData
+    * to it using the template
+    */
+   if (id_can_have_animdata(id)) {
+     IdAdtTemplate *iat = (IdAdtTemplate *)id;
+ 
+     /* check if there's already AnimData, in which case, don't add */
+     if (iat->adt == NULL) {
+       AnimData *adt;
+ 
+       /* add animdata */
+       adt = iat->adt = MEM_callocN(sizeof(AnimData), "AnimData");
+ 
+       /* set default settings */
+       adt->act_influence = 1.0f;
+     }
+ 
+     return iat->adt;
+   }
+   else {
+     return NULL;
+   }
+ }
+ 
+ /* Action Setter --------------------------------------- */
+ 
+ /**
+  * Called when user tries to change the active action of an AnimData block
+  * (via RNA, Outliner, etc.)
+  */
+ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
+ {
+   AnimData *adt = BKE_animdata_from_id(id);
+   bool ok = false;
+ 
+   /* animdata validity check */
+   if (adt == NULL) {
+     BKE_report(reports, RPT_WARNING, "No AnimData to set action on");
+     return ok;
+   }
+ 
+   /* active action is only editable when it is not a tweaking strip
+    * see rna_AnimData_action_editable() in rna_animation.c
+    */
+   if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) {
+     /* cannot remove, otherwise things turn to custard */
+     BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA");
+     return ok;
+   }
+ 
+   /* manage usercount for current action */
+   if (adt->action) {
+     id_us_min((ID *)adt->action);
+   }
+ 
+   /* assume that AnimData's action can in fact be edited... */
+   if (act) {
+     /* action must have same type as owner */
+     if (ELEM(act->idroot, 0, GS(id->name))) {
+       /* can set */
+       adt->action = act;
+       id_us_plus((ID *)adt->action);
+       ok = true;
+     }
+     else {
+       /* cannot set */
+       BKE_reportf(
+           reports,
+           RPT_ERROR,
+           "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths "
+           "for this purpose",
+           act->id.name + 2,
+           id->name);
+       /* ok = false; */
+     }
+   }
+   else {
+     /* just clearing the action... */
+     adt->action = NULL;
+     ok = true;
+   }
+ 
+   return ok;
+ }
+ 
+ /* Freeing -------------------------------------------- */
+ 
+ /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */
+ void BKE_animdata_free(ID *id, const bool do_id_user)
+ {
+   /* Only some ID-blocks have this info for now, so we cast the
+    * types that do to be of type IdAdtTemplate
+    */
+   if (id_can_have_animdata(id)) {
+     IdAdtTemplate *iat = (IdAdtTemplate *)id;
+     AnimData *adt = iat->adt;
+ 
+     /* check if there's any AnimData to start with */
+     if (adt) {
+       if (do_id_user) {
+         /* unlink action (don't free, as it's in its own list) */
+         if (adt->action) {
+           id_us_min(&adt->action->id);
+         }
+         /* same goes for the temporarily displaced action */
+         if (adt->tmpact) {
+           id_us_min(&adt->tmpact->id);
+         }
+       }
+ 
+       /* free nla data */
+       BKE_nla_tracks_free(&adt->nla_tracks, do_id_user);
+ 
+       /* free drivers - stored as a list of F-Curves */
+       free_fcurves(&adt->drivers);
+ 
+       /* free driver array cache */
+       MEM_SAFE_FREE(adt->driver_array);
+ 
+       /* free overrides */
+       /* TODO... */
+ 
+       /* free animdata now */
+       MEM_freeN(adt);
+       iat->adt = NULL;
+     }
+   }
+ }
+ 
+ bool BKE_animdata_id_is_animated(const struct ID *id)
+ {
+   if (id == NULL) {
+     return false;
+   }
+ 
+   const AnimData *adt = BKE_animdata_from_id((ID *)id);
+   if (adt == NULL) {
+     return false;
+   }
+ 
+   if (adt->action != NULL && !BLI_listbase_is_empty(&adt->action->curves)) {
+     return true;
+   }
+ 
+   return !BLI_listbase_is_empty(&adt->drivers) || !BLI_listbase_is_empty(&adt->nla_tracks) ||
+          !BLI_listbase_is_empty(&adt->overrides);
+ }
+ 
+ /* Copying -------------------------------------------- */
+ 
+ /**
+  * Make a copy of the given AnimData - to be used when copying data-blocks.
+  * \param flag: Control ID pointers management,
+  * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h
+  * \return The copied animdata.
+  */
+ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
+ {
+   AnimData *dadt;
+ 
+   const bool do_action = (flag & LIB_ID_COPY_ACTIONS) != 0 && (flag & LIB_ID_CREATE_NO_MAIN) == 0;
+   const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0;
+ 
+   /* sanity check before duplicating struct */
+   if (adt == NULL) {
+     return NULL;
+   }
+   dadt = MEM_dupallocN(adt);
+ 
+   /* make a copy of action - at worst, user has to delete copies... */
+   if (do_action) {
+     BLI_assert(bmain != NULL);
+     BLI_assert(dadt->action == NULL || dadt->action != dadt->tmpact);
+     BKE_id_copy_ex(bmain, (ID *)dadt->action, (ID **)&dadt->action, flag);
+     BKE_id_copy_ex(bmain, (ID *)dadt->tmpact, (ID **)&dadt->tmpact, flag);
+   }
+   else if (do_id_user) {
+     id_us_plus((ID *)dadt->action);
+     id_us_plus((ID *)dadt->tmpact);
+   }
+ 
+   /* duplicate NLA data */
+   BKE_nla_tracks_copy(bmain, &dadt->nla_tracks, &adt->nla_tracks, flag);
+ 
+   /* duplicate drivers (F-Curves) */
+   copy_fcurves(&dadt->drivers, &adt->drivers);
+   dadt->driver_array = NULL;
+ 
+   /* don't copy overrides */
+   BLI_listbase_clear(&dadt->overrides);
+ 
+   /* return */
+   return dadt;
+ }
+ 
+ /**
+  * \param flag: Control ID pointers management,
+  * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_lib_id.h
+  * \return true is successfully copied.
+  */
+ bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag)
+ {
+   AnimData *adt;
+ 
+   if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) {
+     return false;
+   }
+ 
+   BKE_animdata_free(id_to, (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0);
+ 
+   adt = BKE_animdata_from_id(id_from);
+   if (adt) {
+     IdAdtTemplate *iat = (IdAdtTemplate *)id_to;
+   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list