Simulations: Add new simulation data block
authorJacques Lucke <jacques@blender.org>
Mon, 20 Apr 2020 08:37:38 +0000 (10:37 +0200)
committerJacques Lucke <jacques@blender.org>
Mon, 20 Apr 2020 08:45:18 +0000 (10:45 +0200)
This data block will be the container for simulation node trees.
It will be used for the new particle node system (T73324).

The new data block has the type `ID_SIM`.
It is not visible to users and other developers by default yet.
To enable it, activate the cmake option `WITH_NEW_SIMULATION_TYPE`.

New simulation data blocks can be created by running `bpy.data.simulations.new("name")`.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D7225

46 files changed:
CMakeLists.txt
source/blender/blenkernel/BKE_idtype.h
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/BKE_simulation.h [new file with mode: 0644]
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/anim_data.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/idtype.c
source/blender/blenkernel/intern/lib_query.c
source/blender/blenkernel/intern/main.c
source/blender/blenkernel/intern/simulation.cc [new file with mode: 0644]
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/blentranslation/BLT_translation.h
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/render/render_opengl.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_simulation_defaults.h [new file with mode: 0644]
source/blender/makesdna/DNA_simulation_types.h [new file with mode: 0644]
source/blender/makesdna/intern/CMakeLists.txt
source/blender/makesdna/intern/dna_defaults.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_simulation.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_space.c

index 5fb0393dcdae2853569a4e3fa3e4521f8f813f0c..8b70b4252fa121b7e7b5b5639e244d45fe49ef1c 100644 (file)
@@ -323,6 +323,10 @@ option(WITH_FREESTYLE     "Enable Freestyle (advanced edges rendering)" ON)
 option(WITH_NEW_OBJECT_TYPES "Enable new hair and pointcloud objects (use for development only, don't save in files)" OFF)
 mark_as_advanced(WITH_NEW_OBJECT_TYPES)
 
+# New simulation data block
+option(WITH_NEW_SIMULATION_TYPE "Enable simulation data block (use for development only, don't save in files)" OFF)
+mark_as_advanced(WITH_NEW_SIMULATION_TYPE)
+
 # Misc
 if(WIN32)
   option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
index 055452162178ce5d0b73fc78c2ff65e25bfd7ba9..6dc504c200739e13f2251ccaf17a3be4ead9a112 100644 (file)
@@ -165,6 +165,7 @@ extern IDTypeInfo IDType_ID_LP;
 extern IDTypeInfo IDType_ID_HA;
 extern IDTypeInfo IDType_ID_PT;
 extern IDTypeInfo IDType_ID_VO;
+extern IDTypeInfo IDType_ID_SIM;
 
 extern IDTypeInfo IDType_ID_LINK_PLACEHOLDER;
 
index ed1f67350c355871989585ba19004ed483b1bd68..b2472e862ecf3bfa435a4b7ef9fd32b44c59419b 100644 (file)
@@ -147,6 +147,7 @@ typedef struct Main {
   ListBase hairs;
   ListBase pointclouds;
   ListBase volumes;
+  ListBase simulations;
 
   /**
    * Must be generated, used and freed by same code - never assume this is valid data unless you
@@ -220,7 +221,7 @@ const char *BKE_main_blendfile_path_from_global(void);
 
 struct ListBase *which_libbase(struct Main *mainlib, short type);
 
-#define MAX_LIBARRAY 40
+#define MAX_LIBARRAY 41
 int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
 
 #define MAIN_VERSION_ATLEAST(main, ver, subver) \
diff --git a/source/blender/blenkernel/BKE_simulation.h b/source/blender/blenkernel/BKE_simulation.h
new file mode 100644 (file)
index 0000000..aad0ada
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#ifndef __BKE_SIMULATION_H__
+#define __BKE_SIMULATION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Main;
+struct Simulation;
+
+void *BKE_simulation_add(struct Main *bmain, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BKE_SIMULATION_H__ */
index 6e612df33d574ac7f6f9081b854e2e1e0ac25443..bdf8778651d3a399b988bb21f66a30a7949f2807 100644 (file)
@@ -211,6 +211,7 @@ set(SRC
   intern/sequencer.c
   intern/shader_fx.c
   intern/shrinkwrap.c
+  intern/simulation.cc
   intern/softbody.c
   intern/sound.c
   intern/speaker.c
@@ -362,6 +363,7 @@ set(SRC
   BKE_sequencer.h
   BKE_shader_fx.h
   BKE_shrinkwrap.h
+  BKE_simulation.h
   BKE_softbody.h
   BKE_sound.h
   BKE_speaker.h
index 41bfc5b59e493684990c62b3a73dad3c95396616..f77e2ea1e0d63a0918dc8a4f905b056f3a400a40 100644 (file)
@@ -95,6 +95,7 @@ bool id_type_can_have_animdata(const short id_type)
     case ID_HA:
     case ID_PT:
     case ID_VO:
+    case ID_SIM:
       return true;
 
     /* no AnimData */
@@ -1321,6 +1322,9 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use
 
   /* volumes */
   ANIMDATA_IDS_CB(bmain->volumes.first);
+
+  /* simulations */
+  ANIMDATA_IDS_CB(bmain->simulations.first);
 }
 
 /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
@@ -1430,6 +1434,9 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id,
   /* volumes */
   RENAMEFIX_ANIM_IDS(bmain->volumes.first);
 
+  /* simulations */
+  RENAMEFIX_ANIM_IDS(bmain->simulations.first);
+
   /* scenes */
   RENAMEFIX_ANIM_NODETREE_IDS(bmain->scenes.first, Scene);
 }
index de8d5af22ae4bb54e33ba365bb85f1c5daa8bc33..5e4b280d0d0ad75787bbcc5d6bbbe046a8286475 100644 (file)
@@ -2680,6 +2680,9 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, float
   /* volumes */
   EVAL_ANIM_IDS(main->volumes.first, ADT_RECALC_ANIM);
 
+  /* simulations */
+  EVAL_ANIM_IDS(main->simulations.first, ADT_RECALC_ANIM);
+
   /* objects */
   /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
    * this tagged by Depsgraph on framechange. This optimization means that objects
index 5a6e8f532c94ef22703cccb0741550a274059c76..fafd223a0e5a91b1491d9f7a9f18d50dece8a3c6 100644 (file)
@@ -92,6 +92,7 @@ static void id_type_init(void)
   INIT_TYPE(ID_HA);
   INIT_TYPE(ID_PT);
   INIT_TYPE(ID_VO);
+  INIT_TYPE(ID_SIM);
 
   /* Special naughty boy... */
   BLI_assert(IDType_ID_LINK_PLACEHOLDER.main_listbase_index == INDEX_ID_NULL);
@@ -251,6 +252,7 @@ uint64_t BKE_idtype_idcode_to_idfilter(const short idcode)
     CASE_IDFILTER(PT);
     CASE_IDFILTER(LP);
     CASE_IDFILTER(SCE);
+    CASE_IDFILTER(SIM);
     CASE_IDFILTER(SPK);
     CASE_IDFILTER(SO);
     CASE_IDFILTER(TE);
@@ -302,6 +304,7 @@ short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter)
     CASE_IDFILTER(PT);
     CASE_IDFILTER(LP);
     CASE_IDFILTER(SCE);
+    CASE_IDFILTER(SIM);
     CASE_IDFILTER(SPK);
     CASE_IDFILTER(SO);
     CASE_IDFILTER(TE);
@@ -356,6 +359,7 @@ int BKE_idtype_idcode_to_index(const short idcode)
     CASE_IDINDEX(LP);
     CASE_IDINDEX(SCE);
     CASE_IDINDEX(SCR);
+    CASE_IDINDEX(SIM);
     CASE_IDINDEX(SPK);
     CASE_IDINDEX(SO);
     CASE_IDINDEX(TE);
@@ -417,6 +421,7 @@ short BKE_idtype_idcode_from_index(const int index)
     CASE_IDCODE(LP);
     CASE_IDCODE(SCE);
     CASE_IDCODE(SCR);
+    CASE_IDCODE(SIM);
     CASE_IDCODE(SPK);
     CASE_IDCODE(SO);
     CASE_IDCODE(TE);
index 4ffdcf14fa740afc00804feb9ec2d3f5445fa038..302ed065e5d1d997b30aad82f9684bbda5509a08 100644 (file)
@@ -49,6 +49,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
@@ -1294,6 +1295,7 @@ static void library_foreach_ID_link(Main *bmain,
       case ID_PAL:
       case ID_PC:
       case ID_CF:
+      case ID_SIM:
         break;
 
       /* Deprecated. */
@@ -1456,6 +1458,7 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
     case ID_PAL:
     case ID_PC:
     case ID_CF:
+    case ID_SIM:
       /* Those types never use/reference other IDs... */
       return false;
     case ID_IP:
index caa29f7817aba52942e1b7df6e21cd705f31f2ca..ea3bee8b2f69596e90f60f3bb4de9d9043b022b6 100644 (file)
@@ -479,6 +479,8 @@ ListBase *which_libbase(Main *bmain, short type)
       return &(bmain->pointclouds);
     case ID_VO:
       return &(bmain->volumes);
+    case ID_SIM:
+      return &(bmain->simulations);
   }
   return NULL;
 }
@@ -554,6 +556,7 @@ int set_listbasepointers(Main *bmain, ListBase **lb)
   lb[INDEX_ID_WS] = &(bmain->workspaces); /* before wm, so it's freed after it! */
   lb[INDEX_ID_WM] = &(bmain->wm);
   lb[INDEX_ID_MSK] = &(bmain->masks);
+  lb[INDEX_ID_SIM] = &(bmain->simulations);
 
   lb[INDEX_ID_NULL] = NULL;
 
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
new file mode 100644 (file)
index 0000000..5b08bf8
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_ID.h"
+#include "DNA_defaults.h"
+#include "DNA_simulation_types.h"
+
+#include "BLI_compiler_compat.h"
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_anim_data.h"
+#include "BKE_animsys.h"
+#include "BKE_idtype.h"
+#include "BKE_lib_id.h"
+#include "BKE_lib_query.h"
+#include "BKE_lib_remap.h"
+#include "BKE_main.h"
+#include "BKE_simulation.h"
+
+#include "BLT_translation.h"
+
+static void simulation_init_data(ID *id)
+{
+  Simulation *simulation = (Simulation *)id;
+  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(simulation, id));
+
+  MEMCPY_STRUCT_AFTER(simulation, DNA_struct_default_get(Simulation), id);
+}
+
+static void simulation_copy_data(Main *UNUSED(bmain),
+                                 ID *UNUSED(id_dst),
+                                 const ID *UNUSED(id_src),
+                                 const int UNUSED(flag))
+{
+}
+
+static void simulation_make_local(Main *bmain, ID *id, const int flags)
+{
+  BKE_lib_id_make_local_generic(bmain, id, flags);
+}
+
+static void simulation_free_data(ID *id)
+{
+  Simulation *simulation = (Simulation *)id;
+  BKE_animdata_free(&simulation->id, false);
+}
+
+void *BKE_simulation_add(Main *bmain, const char *name)
+{
+  Simulation *simulation = (Simulation *)BKE_libblock_alloc(bmain, ID_SIM, name, 0);
+
+  simulation_init_data(&simulation->id);
+
+  return simulation;
+}
+
+IDTypeInfo IDType_ID_SIM = {
+    /* id_code */ ID_SIM,
+    /* id_filter */ FILTER_ID_SIM,
+    /* main_listbase_index */ INDEX_ID_SIM,
+    /* struct_size */ sizeof(Simulation),
+    /* name */ "Simulation",
+    /* name_plural */ "simulations",
+    /* translation_context */ BLT_I18NCONTEXT_ID_SIMULATION,
+    /* flags */ 0,
+
+    /* init_data */ simulation_init_data,
+    /* copy_data */ simulation_copy_data,
+    /* free_data */ simulation_free_data,
+    /* make_local */ simulation_make_local,
+};
index 41f309f6e5e82987164178a1dc2a28afddb8a0b3..a57e14a22b70103ca8de3d260a40e167a68669e1 100644 (file)
@@ -86,6 +86,7 @@
 #include "DNA_sdna_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_shader_fx_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
 #include "BKE_screen.h"
 #include "BKE_sequencer.h"
 #include "BKE_shader_fx.h"
+#include "BKE_simulation.h"
 #include "BKE_sound.h"
 #include "BKE_volume.h"
 #include "BKE_workspace.h"
@@ -9140,6 +9142,24 @@ static void direct_link_volume(FileData *fd, Volume *volume)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Read ID: Simulation
+ * \{ */
+
+static void lib_link_simulation(FileData *UNUSED(fd),
+                                Main *UNUSED(main),
+                                Simulation *UNUSED(simulation))
+{
+}
+
+static void direct_link_simulation(FileData *fd, Simulation *simulation)
+{
+  simulation->adt = newdataadr(fd, simulation->adt);
+  direct_link_animdata(fd, simulation->adt);
+}
+
+/** \} */
+
 /* -------------------------------------------------------------------- */
 /** \name Read Library Data Block
  * \{ */
@@ -9258,6 +9278,8 @@ static const char *dataname(short id_code)
       return "Data from PT";
     case ID_VO:
       return "Data from VO";
+    case ID_SIM:
+      return "Data from SIM";
   }
   return "Data from Lib Block";
 }
@@ -9409,6 +9431,9 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
     case ID_VO:
       direct_link_volume(fd, (Volume *)id);
       break;
+    case ID_SIM:
+      direct_link_simulation(fd, (Simulation *)id);
+      break;
   }
 
   return success;
@@ -10089,6 +10114,9 @@ static void lib_link_all(FileData *fd, Main *bmain)
       case ID_AC:
         lib_link_action(fd, bmain, (bAction *)id);
         break;
+      case ID_SIM:
+        lib_link_simulation(fd, bmain, (Simulation *)id);
+        break;
       case ID_IP:
         /* XXX deprecated... still needs to be maintained for version patches still. */
         lib_link_ipo(fd, bmain, (Ipo *)id);
@@ -11511,6 +11539,13 @@ static void expand_volume(FileData *fd, Main *mainvar, Volume *volume)
   }
 }
 
+static void expand_simulation(FileData *fd, Main *mainvar, Simulation *simulation)
+{
+  if (simulation->adt) {
+    expand_animdata(fd, mainvar, simulation->adt);
+  }
+}
+
 /**
  * Set the callback func used over all ID data found by \a BLO_expand_main func.
  *
@@ -11640,6 +11675,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
             case ID_VO:
               expand_volume(fd, mainvar, (Volume *)id);
               break;
+            case ID_SIM:
+              expand_simulation(fd, mainvar, (Simulation *)id);
+              break;
             default:
               break;
           }
index ee5e6f4610a1ff2f66f4f9eeaa8992b34fae554f..322351b4b4b9614d1634baff14ed5ae48735a60b 100644 (file)
 #include "DNA_sdna_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_shader_fx_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
@@ -3848,6 +3849,18 @@ static void write_volume(WriteData *wd, Volume *volume, const void *id_address)
   }
 }
 
+static void write_simulation(WriteData *wd, Simulation *simulation)
+{
+  if (simulation->id.us > 0 || wd->use_memfile) {
+    writestruct(wd, ID_SIM, Simulation, 1, simulation);
+    write_iddata(wd, &simulation->id);
+
+    if (simulation->adt) {
+      write_animdata(wd, simulation->adt);
+    }
+  }
+}
+
 /* Keep it last of write_foodata functions. */
 static void write_libraries(WriteData *wd, Main *main)
 {
@@ -4197,6 +4210,9 @@ static bool write_file_handle(Main *mainvar,
           case ID_VO:
             write_volume(wd, (Volume *)id_buffer, id);
             break;
+          case ID_SIM:
+            write_simulation(wd, (Simulation *)id);
+            break;
           case ID_LI:
             /* Do nothing, handled below - and should never be reached. */
             BLI_assert(0);
index 74c46b1cf3e6ce7128eb7d2a403d5c902d89d67d..5f6ae0a86e97455cfadc1141595a3578af7042ed 100644 (file)
@@ -122,6 +122,7 @@ bool BLT_lang_is_ime_supported(void);
 #define BLT_I18NCONTEXT_ID_IMAGE "Image"
 /*#define BLT_I18NCONTEXT_ID_IPO                  "Ipo"*/ /* Deprecated */
 #define BLT_I18NCONTEXT_ID_SHAPEKEY "Key"
+#define BLT_I18NCONTEXT_ID_SIMULATION "Simulation"
 #define BLT_I18NCONTEXT_ID_LIGHT "Light"
 #define BLT_I18NCONTEXT_ID_LIBRARY "Library"
 #define BLT_I18NCONTEXT_ID_LATTICE "Lattice"
@@ -202,6 +203,7 @@ typedef struct {
         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCENE, "id_scene"), \
         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCREEN, "id_screen"), \
         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SEQUENCE, "id_sequence"), \
+        BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SIMULATION, "id_simulation"), \
         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SPEAKER, "id_speaker"), \
         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SOUND, "id_sound"), \
         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_TEXTURE, "id_texture"), \
index 01cc95813cade808246f68727468ff883bb855b8..0c0cc8ebc973e056715302062bb5f04bf52edd06 100644 (file)
@@ -60,6 +60,7 @@ extern "C" {
 #include "DNA_rigidbody_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_speaker_types.h"
 #include "DNA_texture_types.h"
@@ -481,6 +482,9 @@ void DepsgraphNodeBuilder::build_id(ID *id)
     case ID_SCE:
       build_scene_parameters((Scene *)id);
       break;
+    case ID_SIM:
+      build_simulation((Simulation *)id);
+      break;
     default:
       fprintf(stderr, "Unhandled ID %s\n", id->name);
       BLI_assert(!"Should never happen");
@@ -1698,6 +1702,16 @@ void DepsgraphNodeBuilder::build_sound(bSound *sound)
   build_parameters(&sound->id);
 }
 
+void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
+{
+  if (built_map_.checkIsBuiltAndTag(simulation)) {
+    return;
+  }
+  add_id_node(&simulation->id);
+  build_animdata(&simulation->id);
+  build_parameters(&simulation->id);
+}
+
 void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
 {
   if (scene->ed == nullptr) {
index 7fcc8b431e7a577f204d32776a7c2b92650e5718..15c1a42574f6b7d7e30fdd6bd35e31e183f29dcd 100644 (file)
@@ -52,6 +52,7 @@ struct MovieClip;
 struct Object;
 struct ParticleSettings;
 struct Scene;
+struct Simulation;
 struct Speaker;
 struct Tex;
 struct World;
@@ -217,6 +218,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
   virtual void build_lightprobe(LightProbe *probe);
   virtual void build_speaker(Speaker *speaker);
   virtual void build_sound(bSound *sound);
+  virtual void build_simulation(Simulation *simulation);
   virtual void build_scene_sequencer(Scene *scene);
   virtual void build_scene_audio(Scene *scene);
   virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer);
index e968ad1ea5de39e3a34e729033edbbe358f8451d..1adf7c09c2865c2fbed30cb5c5eb93034895acb7 100644 (file)
@@ -62,6 +62,7 @@ extern "C" {
 #include "DNA_rigidbody_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_speaker_types.h"
 #include "DNA_texture_types.h"
@@ -558,6 +559,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
     case ID_SCE:
       build_scene_parameters((Scene *)id);
       break;
+    case ID_SIM:
+      build_simulation((Simulation *)id);
+      break;
     default:
       fprintf(stderr, "Unhandled ID %s\n", id->name);
       BLI_assert(!"Should never happen");
@@ -2502,6 +2506,15 @@ void DepsgraphRelationBuilder::build_sound(bSound *sound)
   build_parameters(&sound->id);
 }
 
+void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
+{
+  if (built_map_.checkIsBuiltAndTag(simulation)) {
+    return;
+  }
+  build_animdata(&simulation->id);
+  build_parameters(&simulation->id);
+}
+
 void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
 {
   if (scene->ed == nullptr) {
index 099a00d66a61809d72c91d20827602eb1039d06e..caec7cc1496c05c9d308c90e635c7d9ebd7d70ee 100644 (file)
@@ -68,6 +68,7 @@ struct Object;
 struct ParticleSettings;
 struct ParticleSystem;
 struct Scene;
+struct Simulation;
 struct Speaker;
 struct Tex;
 struct ViewLayer;
@@ -282,6 +283,7 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
   virtual void build_lightprobe(LightProbe *probe);
   virtual void build_speaker(Speaker *speaker);
   virtual void build_sound(bSound *sound);
+  virtual void build_simulation(Simulation *simulation);
   virtual void build_scene_sequencer(Scene *scene);
   virtual void build_scene_audio(Scene *scene);
   virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer);
index b569f909d7adc04bdb12454870cc2c5b62acb768..0e00e48267bd3d13c2adcd0bd5e8d512b5c87c56 100644 (file)
@@ -51,6 +51,7 @@
 #include "DNA_pointcloud_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
 #include "DNA_volume_types.h"
@@ -3033,6 +3034,83 @@ static bAnimChannelType ACF_DSVOLUME = {
     acf_dsvolume_setting_ptr              /* pointer for setting */
 };
 
+/* Simulation Expander ----------------------------------------- */
+
+static int acf_dssimulation_icon(bAnimListElem *UNUSED(ale))
+{
+  /* TODO: Use correct icon. */
+  return ICON_PHYSICS;
+}
+
+static int acf_dssimulation_setting_flag(bAnimContext *UNUSED(ac),
+                                         eAnimChannel_Settings setting,
+                                         bool *neg)
+{
+  /* clear extra return data first */
+  *neg = false;
+
+  switch (setting) {
+    case ACHANNEL_SETTING_EXPAND: /* expanded */
+      return SIM_DS_EXPAND;
+
+    case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
+      return ADT_NLA_EVAL_OFF;
+
+    case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
+      *neg = true;
+      return ADT_CURVES_NOT_VISIBLE;
+
+    case ACHANNEL_SETTING_SELECT: /* selected */
+      return ADT_UI_SELECTED;
+
+    default: /* unsupported */
+      return 0;
+  }
+}
+
+static void *acf_dssimulation_setting_ptr(bAnimListElem *ale,
+                                          eAnimChannel_Settings setting,
+                                          short *type)
+{
+  Simulation *simulation = (Simulation *)ale->data;
+
+  /* clear extra return data first */
+  *type = 0;
+
+  switch (setting) {
+    case ACHANNEL_SETTING_EXPAND: /* expanded */
+      return GET_ACF_FLAG_PTR(simulation->flag, type);
+
+    case ACHANNEL_SETTING_SELECT:  /* selected */
+    case ACHANNEL_SETTING_MUTE:    /* muted (for NLA only) */
+    case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
+      if (simulation->adt)
+        return GET_ACF_FLAG_PTR(simulation->adt->flag, type);
+      return NULL;
+
+    default: /* unsupported */
+      return NULL;
+  }
+}
+
+static bAnimChannelType ACF_DSSIMULATION = {
+    "Simulation Expander",  /* type name */
+    ACHANNEL_ROLE_EXPANDER, /* role */
+
+    acf_generic_dataexpand_color,    /* backdrop color */
+    acf_generic_dataexpand_backdrop, /* backdrop */
+    acf_generic_indention_1,         /* indent level */
+    acf_generic_basic_offset,        /* offset */
+
+    acf_generic_idblock_name,      /* name */
+    acf_generic_idblock_name_prop, /* name prop */
+    acf_dssimulation_icon,         /* icon */
+
+    acf_generic_dataexpand_setting_valid, /* has setting */
+    acf_dssimulation_setting_flag,        /* flag for setting */
+    acf_dssimulation_setting_ptr          /* pointer for setting */
+};
+
 /* GPencil Expander  ------------------------------------------- */
 
 // TODO: just get this from RNA?
@@ -4049,6 +4127,7 @@ static void ANIM_init_channel_typeinfo_data(void)
     animchannelTypeInfo[type++] = &ACF_DSHAIR;       /* Hair Channel */
     animchannelTypeInfo[type++] = &ACF_DSPOINTCLOUD; /* PointCloud Channel */
     animchannelTypeInfo[type++] = &ACF_DSVOLUME;     /* Volume Channel */
+    animchannelTypeInfo[type++] = &ACF_DSSIMULATION; /* Simulation Channel */
 
     animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */
 
index a1b1c7815d869280f834a6673a91790a2a47c63d..302b1318bba0a82266a5e7350132a6577fe37c81 100644 (file)
@@ -138,7 +138,8 @@ void ANIM_set_active_channel(bAnimContext *ac,
       case ANIMTYPE_DSMCLIP:
       case ANIMTYPE_DSHAIR:
       case ANIMTYPE_DSPOINTCLOUD:
-      case ANIMTYPE_DSVOLUME: {
+      case ANIMTYPE_DSVOLUME:
+      case ANIMTYPE_DSSIMULATION: {
         /* need to verify that this data is valid for now */
         if (ale->adt) {
           ACHANNEL_SET_FLAG(ale->adt, ACHANNEL_SETFLAG_CLEAR, ADT_UI_ACTIVE);
@@ -194,7 +195,8 @@ void ANIM_set_active_channel(bAnimContext *ac,
       case ANIMTYPE_DSMCLIP:
       case ANIMTYPE_DSHAIR:
       case ANIMTYPE_DSPOINTCLOUD:
-      case ANIMTYPE_DSVOLUME: {
+      case ANIMTYPE_DSVOLUME:
+      case ANIMTYPE_DSSIMULATION: {
         /* need to verify that this data is valid for now */
         if (ale && ale->adt) {
           ale->adt->flag |= ADT_UI_ACTIVE;
@@ -332,7 +334,8 @@ void ANIM_deselect_anim_channels(
         case ANIMTYPE_DSMCLIP:
         case ANIMTYPE_DSHAIR:
         case ANIMTYPE_DSPOINTCLOUD:
-        case ANIMTYPE_DSVOLUME: {
+        case ANIMTYPE_DSVOLUME:
+        case ANIMTYPE_DSSIMULATION: {
           if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
             sel = ACHANNEL_SETFLAG_CLEAR;
           }
@@ -428,7 +431,8 @@ void ANIM_deselect_anim_channels(
       case ANIMTYPE_DSMCLIP:
       case ANIMTYPE_DSHAIR:
       case ANIMTYPE_DSPOINTCLOUD:
-      case ANIMTYPE_DSVOLUME: {
+      case ANIMTYPE_DSVOLUME:
+      case ANIMTYPE_DSSIMULATION: {
         /* need to verify that this data is valid for now */
         if (ale->adt) {
           ACHANNEL_SET_FLAG(ale->adt, sel, ADT_UI_SELECTED);
@@ -2964,7 +2968,8 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
     case ANIMTYPE_DSMCLIP:
     case ANIMTYPE_DSHAIR:
     case ANIMTYPE_DSPOINTCLOUD:
-    case ANIMTYPE_DSVOLUME: {
+    case ANIMTYPE_DSVOLUME:
+    case ANIMTYPE_DSSIMULATION: {
       /* sanity checking... */
       if (ale->adt) {
         /* select/deselect */
index 4dc0bef3a1b4bf28450a9851518c5cddd32e337c..e4da4e66e21c583cb62e0b86e0ad1215aa7995f3 100644 (file)
@@ -67,6 +67,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
 #include "DNA_userdef_types.h"
@@ -826,6 +827,18 @@ static bAnimListElem *make_new_animlistelem(void *data,
         ale->adt = BKE_animdata_from_id(data);
         break;
       }
+      case ANIMTYPE_DSSIMULATION: {
+        Simulation *simulation = (Simulation *)data;
+        AnimData *adt = simulation->adt;
+
+        ale->flag = FILTER_SIMULATION_OBJD(simulation);
+
+        ale->key_data = (adt) ? adt->action : NULL;
+        ale->datatype = ALE_ACT;
+
+        ale->adt = BKE_animdata_from_id(data);
+        break;
+      }
       case ANIMTYPE_DSSKEY: {
         Key *key = (Key *)data;
         AnimData *adt = key->adt;
index a9b34e3c7353cdfc67b178403f26e9fdab5fc8c5..7d38792f332034c92c35bdc03ff384973732cdd9 100644 (file)
@@ -229,6 +229,7 @@ typedef enum eAnim_ChannelType {
   ANIMTYPE_DSHAIR,
   ANIMTYPE_DSPOINTCLOUD,
   ANIMTYPE_DSVOLUME,
+  ANIMTYPE_DSSIMULATION,
 
   ANIMTYPE_SHAPEKEY,
 
@@ -356,6 +357,8 @@ typedef enum eAnimFilter_Flags {
 #define FILTER_HAIR_OBJD(ha) (CHECK_TYPE_INLINE(ha, Hair *), ((ha->flag & HA_DS_EXPAND)))
 #define FILTER_POINTS_OBJD(pt) (CHECK_TYPE_INLINE(pt, PointCloud *), ((pt->flag & PT_DS_EXPAND)))
 #define FILTER_VOLUME_OBJD(vo) (CHECK_TYPE_INLINE(vo, Volume *), ((vo->flag & VO_DS_EXPAND)))
+#define FILTER_SIMULATION_OBJD(sim) \
+  (CHECK_TYPE_INLINE(sim, Simulation *), ((sim->flag & SIM_DS_EXPAND)))
 /* Variable use expanders */
 #define FILTER_NTREE_DATA(ntree) \
   (CHECK_TYPE_INLINE(ntree, bNodeTree *), (((ntree)->flag & NTREE_DS_EXPAND)))
index 084eb943665b1a889108309248acab3f6dcd33b6..e3184ac413fc77c413cd3fa0d84f7e3789d94bb6 100644 (file)
@@ -2326,6 +2326,9 @@ int UI_idcode_icon_get(const int idcode)
       return ICON_WORLD_DATA;
     case ID_WS:
       return ICON_WORKSPACE;
+    case ID_SIM:
+      /* TODO: Use correct icon. */
+      return ICON_PHYSICS;
     default:
       return ICON_NONE;
   }
index 27ce20ae3743b62702cbd3692ec980dd3d4e8119..b76a21fc46aa1c42b0cbc6814bb2d658e06baaec 100644 (file)
@@ -688,6 +688,8 @@ static const char *template_id_browse_tip(const StructRNA *type)
         return N_("Browse Point Cloud Data to be linked");
       case ID_VO:
         return N_("Browse Volume Data to be linked");
+      case ID_SIM:
+        return N_("Browser Simulation to be linked");
     }
   }
   return N_("Browse ID data to be linked");
@@ -753,7 +755,8 @@ static uiBut *template_id_def_new_but(uiBlock *block,
                             BLT_I18NCONTEXT_ID_LIGHTPROBE,
                             BLT_I18NCONTEXT_ID_HAIR,
                             BLT_I18NCONTEXT_ID_POINTCLOUD,
-                            BLT_I18NCONTEXT_ID_VOLUME, );
+                            BLT_I18NCONTEXT_ID_VOLUME,
+                            BLT_I18NCONTEXT_ID_SIMULATION, );
   /* Note: BLT_I18N_MSGID_MULTI_CTXT takes a maximum number of parameters,
    * check the definition to see if a new call must be added when the limit
    * is exceeded. */
index f35f92feaec07d449e787cd083a60e84d9b153c1..b2b0000693998856035d6ac50e382e24ce55c144 100644 (file)
@@ -630,6 +630,7 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
     case ID_HA:  /* Hair */
     case ID_PT:  /* PointCloud */
     case ID_VO:  /* Volume */
+    case ID_SIM: /* Simulation */
       break;
 
       /* Blacklist: */
index 262af338f2a147b64d7bcea190c413ea9536a1ec..307b6d9bc21acb2c6cfab11bfca9b0137a1d4e72 100644 (file)
@@ -143,7 +143,8 @@ bool nla_panel_context(const bContext *C,
       case ANIMTYPE_PALETTE:
       case ANIMTYPE_DSHAIR:
       case ANIMTYPE_DSPOINTCLOUD:
-      case ANIMTYPE_DSVOLUME: {
+      case ANIMTYPE_DSVOLUME:
+      case ANIMTYPE_DSSIMULATION: {
         /* for these channels, we only do AnimData */
         if (ale->adt && adt_ptr) {
           ID *id;
index 5adcec8a5d77a8154c9e3759ce2f1a5427ae031b..d399ea47d7e0f407498657d8ad490c04d33d47b1 100644 (file)
@@ -193,7 +193,8 @@ static int mouse_nla_channels(
     case ANIMTYPE_PALETTE:
     case ANIMTYPE_DSHAIR:
     case ANIMTYPE_DSPOINTCLOUD:
-    case ANIMTYPE_DSVOLUME: {
+    case ANIMTYPE_DSVOLUME:
+    case ANIMTYPE_DSSIMULATION: {
       /* sanity checking... */
       if (ale->adt) {
         /* select/deselect */
index ce83cfc3c9787f2900d73ebd531d7f2150322147..6eba41982a7b0e8e6e9e4e37604dcf1815d9fb7d 100644 (file)
@@ -2581,6 +2581,10 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
         case ID_PC:
           data.icon = ICON_CURVE_BEZCURVE;
           break;
+        case ID_SIM:
+          /* TODO: Use correct icon. */
+          data.icon = ICON_PHYSICS;
+          break;
         default:
           break;
       }
index 90092817accf679aac9e872048e40db1644ef20d..3032d38b7ac688367fda41c42fa35e2d2f8e3e93 100644 (file)
@@ -108,7 +108,8 @@ typedef struct TreeElementIcon {
         ID_LP, \
         ID_HA, \
         ID_PT, \
-        ID_VO) || /* Only in 'blendfile' mode ... :/ */ \
+        ID_VO, \
+        ID_SIM) || /* Only in 'blendfile' mode ... :/ */ \
    ELEM(GS((_id)->name), \
         ID_SCR, \
         ID_WM, \
index a6c1594678b997c0d480aca13f67708a9150ee4c..24c0e63ee9a8c763ade5e16b5add89a83dd326e1 100644 (file)
@@ -39,6 +39,7 @@
 #include "DNA_pointcloud_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_volume_types.h"
 #include "DNA_world_types.h"
 
@@ -160,6 +161,7 @@ static void set_operation_types(SpaceOutliner *soops,
           case ID_HA:
           case ID_PT:
           case ID_VO:
+          case ID_SIM:
             is_standard_id = true;
             break;
           case ID_WM:
index b226d2911886fca63dd1312d8f9e482e77751a33..9b06de67825f5dd5f93b1ff6987dfe9d3fa68c81 100644 (file)
@@ -46,6 +46,7 @@
 #include "DNA_pointcloud_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_speaker_types.h"
 #include "DNA_volume_types.h"
 #include "DNA_world_types.h"
@@ -773,6 +774,13 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
         outliner_add_element(soops, &te->subtree, volume, te, TSE_ANIM_DATA, 0);
       break;
     }
+    case ID_SIM: {
+      Simulation *simulation = (Simulation *)id;
+      if (outliner_animdata_test(simulation->adt)) {
+        outliner_add_element(soops, &te->subtree, simulation, te, TSE_ANIM_DATA, 0);
+      }
+      break;
+    }
     default:
       break;
   }
index 0565840b34485e3516f265999e4eb0642df2347c..ba1485004aed98f20592a541115e8d40bdfdd148 100644 (file)
@@ -424,6 +424,7 @@ typedef enum ID_Type {
   ID_HA = MAKE_ID2('H', 'A'),  /* Hair */
   ID_PT = MAKE_ID2('P', 'T'),  /* PointCloud */
   ID_VO = MAKE_ID2('V', 'O'),  /* Volume */
+  ID_SIM = MAKE_ID2('S', 'I'), /* Simulation */
 } ID_Type;
 
 /* Only used as 'placeholder' in .blend files for directly linked data-blocks. */
@@ -723,6 +724,7 @@ typedef enum IDRecalcFlag {
 #define FILTER_ID_HA (1ULL << 32)
 #define FILTER_ID_PT (1ULL << 33)
 #define FILTER_ID_VO (1ULL << 34)
+#define FILTER_ID_SIM (1ULL << 35)
 
 #define FILTER_ID_ALL \
   (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU | FILTER_ID_GD | \
@@ -730,7 +732,7 @@ typedef enum IDRecalcFlag {
    FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | \
    FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | \
    FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | \
-   FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO)
+   FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM)
 
 /* IMPORTANT: this enum matches the order currently use in set_listbasepointers,
  * keep them in sync! */
@@ -774,6 +776,7 @@ enum {
   INDEX_ID_WS,
   INDEX_ID_WM,
   INDEX_ID_MSK,
+  INDEX_ID_SIM,
   INDEX_ID_NULL,
   INDEX_ID_MAX,
 };
diff --git a/source/blender/makesdna/DNA_simulation_defaults.h b/source/blender/makesdna/DNA_simulation_defaults.h
new file mode 100644 (file)
index 0000000..b4cecd8
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_SIMULATION_DEFAULTS_H__
+#define __DNA_SIMULATION_DEFAULTS_H__
+
+/* Struct members on own line. */
+/* clang-format off */
+
+/* -------------------------------------------------------------------- */
+/** \name Simulation Struct
+ * \{ */
+
+#define _DNA_DEFAULT_Simulation \
+  { \
+    .flag = 0, \
+  }
+
+/** \} */
+
+/* clang-format on */
+
+#endif /* __DNA_SIMULATION_DEFAULTS_H__ */
diff --git a/source/blender/makesdna/DNA_simulation_types.h b/source/blender/makesdna/DNA_simulation_types.h
new file mode 100644 (file)
index 0000000..84c22d7
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#ifndef __DNA_SIMULATION_TYPES_H__
+#define __DNA_SIMULATION_TYPES_H__
+
+#include "DNA_ID.h"
+
+typedef struct Simulation {
+  ID id;
+  struct AnimData *adt; /* animation data (must be immediately after id) */
+
+  int flag;
+  int _pad1[1];
+} Simulation;
+
+/* Simulation.flag */
+enum {
+  SIM_DS_EXPAND = (1 << 0),
+};
+
+#endif /* __DNA_SIMULATION_TYPES_H__ */
index a101e96e95826c47f77b31b205a01e917a1362f6..1b0bf086269d2782debe014b32d93c7f17c4b63c 100644 (file)
@@ -146,6 +146,7 @@ set(SRC
   ../DNA_object_defaults.h
   ../DNA_pointcloud_defaults.h
   ../DNA_scene_defaults.h
+  ../DNA_simulation_defaults.h
   ../DNA_speaker_defaults.h
   ../DNA_texture_defaults.h
   ../DNA_vec_defaults.h
index dadd2fd9d7d85edecd2493b8bb3753380e967f2f..2d86e97debfddce12465ca6ecf50ffdbe6efb344 100644 (file)
@@ -71,6 +71,7 @@
 #include "DNA_object_types.h"
 #include "DNA_pointcloud_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
 #include "DNA_texture_types.h"
@@ -93,6 +94,7 @@
 #include "DNA_object_defaults.h"
 #include "DNA_pointcloud_defaults.h"
 #include "DNA_scene_defaults.h"
+#include "DNA_simulation_defaults.h"
 #include "DNA_speaker_defaults.h"
 #include "DNA_texture_defaults.h"
 #include "DNA_volume_defaults.h"
@@ -150,6 +152,9 @@ SDNA_DEFAULT_DECL_STRUCT(PointCloud);
 SDNA_DEFAULT_DECL_STRUCT(Scene);
 SDNA_DEFAULT_DECL_STRUCT(ToolSettings);
 
+/* DNA_simulation_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(Simulation);
+
 /* DNA_speaker_defaults.h */
 SDNA_DEFAULT_DECL_STRUCT(Speaker);
 
@@ -260,6 +265,9 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
     SDNA_DEFAULT_DECL_EX(GP_Sculpt_Settings, ToolSettings.gp_sculpt),
     SDNA_DEFAULT_DECL_EX(GP_Sculpt_Guide, ToolSettings.gp_sculpt.guide),
 
+    /* DNA_simulation_defaults.h */
+    SDNA_DEFAULT_DECL(Simulation),
+
     /* DNA_speaker_defaults.h */
     SDNA_DEFAULT_DECL(Speaker),
 
index 39b26fef176f5f072ca3202806ddbad8828f023f..49f778f2eb17d937ac2aedd95d414b9f3fbbd3db 100644 (file)
@@ -136,6 +136,7 @@ static const char *includefiles[] = {
     "DNA_hair_types.h",
     "DNA_pointcloud_types.h",
     "DNA_volume_types.h",
+    "DNA_simulation_types.h",
 
     /* see comment above before editing! */
 
@@ -1590,6 +1591,7 @@ int main(int argc, char **argv)
 #include "DNA_sdna_types.h"
 #include "DNA_sequence_types.h"
 #include "DNA_shader_fx_types.h"
+#include "DNA_simulation_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_space_types.h"
 #include "DNA_speaker_types.h"
index 26773e59feb9b299a5ea8e89abba215bd2a5a45f..673669d26f636654ec66212f59bfbd2935fc65b4 100644 (file)
@@ -548,6 +548,7 @@ extern StructRNA RNA_ShrinkwrapConstraint;
 extern StructRNA RNA_ShrinkwrapModifier;
 extern StructRNA RNA_SimpleDeformModifier;
 extern StructRNA RNA_SimplifyGpencilModifier;
+extern StructRNA RNA_Simulation;
 extern StructRNA RNA_SkinModifier;
 extern StructRNA RNA_SmoothGpencilModifier;
 extern StructRNA RNA_SmoothModifier;
index 64b7a3e70c1dab5a0afcded62364b243480f5d01..cd05aba8794483b2dff09a59650613e61e208743 100644 (file)
@@ -103,6 +103,13 @@ if(WITH_NEW_OBJECT_TYPES)
   )
 endif()
 
+if (WITH_NEW_SIMULATION_TYPE)
+  list(APPEND DEFSRC
+    rna_simulation.c
+  )
+endif()
+
+
 set(APISRC
   rna_action_api.c
   rna_animation_api.c
@@ -342,6 +349,11 @@ if(WITH_NEW_OBJECT_TYPES)
   add_definitions(-DWITH_NEW_OBJECT_TYPES)
 endif()
 
+if (WITH_NEW_SIMULATION_TYPE)
+  add_definitions(-DWITH_NEW_SIMULATION_TYPE)
+endif()
+
+
 # Build makesrna executable
 blender_include_dirs(
   .
index 46854bc630749c95a34e55620e61c7c7c59dd016..86a088f38ed8bc40993d14d8c595868d447106bf 100644 (file)
@@ -4302,6 +4302,9 @@ static RNAProcessItem PROCESS_ITEMS[] = {
     {"rna_screen.c", NULL, RNA_def_screen},
     {"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
     {"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
+#ifdef WITH_NEW_SIMULATION_TYPE
+    {"rna_simulation.c", NULL, RNA_def_simulation},
+#endif
     {"rna_space.c", "rna_space_api.c", RNA_def_space},
     {"rna_speaker.c", NULL, RNA_def_speaker},
     {"rna_test.c", NULL, RNA_def_test},
index 7a371a1a1d5d3d4e18865023ab14faf114e0b3c0..4b9dbbb31b60e98133f714d047cad34b9fa83581 100644 (file)
@@ -71,6 +71,9 @@ const EnumPropertyItem rna_enum_id_type_items[] = {
     {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
     {ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_CUBEMAP, "Light Probe", ""},
     {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
+#ifdef WITH_NEW_SIMULATION_TYPE
+    {ID_SIM, "SIMULATION", ICON_PHYSICS, "Simulation", ""}, /* TODO: Use correct icon. */
+#endif
     {ID_SO, "SOUND", ICON_SOUND, "Sound", ""},
     {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""},
     {ID_TXT, "TEXT", ICON_TEXT, "Text", ""},
@@ -303,6 +306,11 @@ short RNA_type_to_ID_code(const StructRNA *type)
   if (base_type == &RNA_Screen) {
     return ID_SCR;
   }
+#  ifdef WITH_NEW_SIMULATION_TYPE
+  if (base_type == &RNA_Simulation) {
+    return ID_SIM;
+  }
+#  endif
   if (base_type == &RNA_Sound) {
     return ID_SO;
   }
@@ -405,6 +413,12 @@ StructRNA *ID_code_to_RNA_type(short idcode)
       return &RNA_Scene;
     case ID_SCR:
       return &RNA_Screen;
+    case ID_SIM:
+#  ifdef WITH_NEW_SIMULATION_TYPE
+      return &RNA_Simulation;
+#  else
+      return &RNA_ID;
+#  endif
     case ID_SO:
       return &RNA_Sound;
     case ID_SPK:
index 2709726193045f7319df41a262032b2c1881f7de..cb59eee6afaa224480bffc3398d486259fb6d1df 100644 (file)
@@ -185,6 +185,7 @@ void RNA_def_render(struct BlenderRNA *brna);
 void RNA_def_rigidbody(struct BlenderRNA *brna);
 void RNA_def_rna(struct BlenderRNA *brna);
 void RNA_def_scene(struct BlenderRNA *brna);
+void RNA_def_simulation(struct BlenderRNA *brna);
 void RNA_def_view_layer(struct BlenderRNA *brna);
 void RNA_def_screen(struct BlenderRNA *brna);
 void RNA_def_sculpt_paint(struct BlenderRNA *brna);
@@ -449,6 +450,7 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop);
 void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop);
 void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop);
 void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop);
+void RNA_def_main_simulations(BlenderRNA *brna, PropertyRNA *cprop);
 
 /* ID Properties */
 
index 855d5f46890a1294bec3a87b77ae5f8a6540348f..2f37e4079c79a9f3615abf0404c60c6c8c58932f 100644 (file)
@@ -134,6 +134,9 @@ RNA_MAIN_LISTBASE_FUNCS_DEF(pointclouds)
 RNA_MAIN_LISTBASE_FUNCS_DEF(scenes)
 RNA_MAIN_LISTBASE_FUNCS_DEF(screens)
 RNA_MAIN_LISTBASE_FUNCS_DEF(shapekeys)
+#  ifdef WITH_NEW_SIMULATION_TYPE
+RNA_MAIN_LISTBASE_FUNCS_DEF(simulations)
+#  endif
 RNA_MAIN_LISTBASE_FUNCS_DEF(sounds)
 RNA_MAIN_LISTBASE_FUNCS_DEF(speakers)
 RNA_MAIN_LISTBASE_FUNCS_DEF(texts)
@@ -402,6 +405,14 @@ void RNA_def_main(BlenderRNA *brna)
        "Volumes",
        "Volume data-blocks",
        RNA_def_main_volumes},
+#  ifdef WITH_NEW_SIMULATION_TYPE
+      {"simulations",
+       "Simulation",
+       "rna_Main_simulations_begin",
+       "Simulations",
+       "Simulation data-blocks",
+       RNA_def_main_simulations},
+#  endif
       {NULL, NULL, NULL, NULL, NULL, NULL},
   };
 
index 9799054ccd2c72e6bbb026e06de9eb4d7329b417..c5781175d65e0450e58ad0f5480a36d4b8cd3dda 100644 (file)
@@ -69,6 +69,7 @@
 #  include "BKE_particle.h"
 #  include "BKE_pointcloud.h"
 #  include "BKE_scene.h"
+#  include "BKE_simulation.h"
 #  include "BKE_sound.h"
 #  include "BKE_speaker.h"
 #  include "BKE_text.h"
@@ -98,6 +99,7 @@
 #  include "DNA_node_types.h"
 #  include "DNA_particle_types.h"
 #  include "DNA_pointcloud_types.h"
+#  include "DNA_simulation_types.h"
 #  include "DNA_sound_types.h"
 #  include "DNA_speaker_types.h"
 #  include "DNA_text_types.h"
@@ -738,6 +740,18 @@ static Volume *rna_Main_volumes_new(Main *bmain, const char *name)
   return volume;
 }
 
+#  ifdef WITH_NEW_SIMULATION_TYPE
+static Simulation *rna_Main_simulations_new(Main *bmain, const char *name)
+{
+  char safe_name[MAX_ID_NAME - 2];
+  rna_idname_validate(name, safe_name);
+
+  Simulation *simulation = BKE_simulation_add(bmain, safe_name);
+  id_us_min(&simulation->id);
+  return simulation;
+}
+#  endif
+
 /* tag functions, all the same */
 #  define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \
     static void rna_Main_##_func_name##_tag(Main *bmain, bool value) \
@@ -785,6 +799,9 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA)
 RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT)
 #  endif
 RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO)
+#  ifdef WITH_NEW_SIMULATION_TYPE
+RNA_MAIN_ID_TAG_FUNCS_DEF(simulations, simulations, ID_SIM)
+#  endif
 
 #  undef RNA_MAIN_ID_TAG_FUNCS_DEF
 
@@ -2304,4 +2321,44 @@ void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop)
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
 }
 
+void RNA_def_main_simulations(BlenderRNA *brna, PropertyRNA *cprop)
+{
+  StructRNA *srna;
+  FunctionRNA *func;
+  PropertyRNA *parm;
+
+  RNA_def_property_srna(cprop, "BlendDataSimulations");
+  srna = RNA_def_struct(brna, "BlendDataSimulations", NULL);
+  RNA_def_struct_sdna(srna, "Main");
+  RNA_def_struct_ui_text(srna, "Main Simulations", "Collection of simulations");
+
+  func = RNA_def_function(srna, "new", "rna_Main_simulations_new");
+  RNA_def_function_ui_description(func, "Add a new simulation to the main database");
+  parm = RNA_def_string(func, "name", "Simulation", 0, "", "New name for the data-block");
+  RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+  /* return type */
+  parm = RNA_def_pointer(func, "simulation", "Simulation", "", "New simulation data-block");
+  RNA_def_function_return(func, parm);
+
+  func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
+  RNA_def_function_flag(func, FUNC_USE_REPORTS);
+  RNA_def_function_ui_description(func, "Remove a simulation from the current blendfile");
+  parm = RNA_def_pointer(func, "simulation", "Simulation", "", "Simulation to remove");
+  RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+  RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+  RNA_def_boolean(
+      func, "do_unlink", true, "", "Unlink all usages of this simulation before deleting it");
+  RNA_def_boolean(func,
+                  "do_id_user",
+                  true,
+                  "",
+                  "Decrement user counter of all datablocks used by this simulation data");
+  RNA_def_boolean(
+      func, "do_ui_user", true, "", "Make sure interface does not reference this simulation data");
+
+  func = RNA_def_function(srna, "tag", "rna_Main_simulations_tag");
+  parm = RNA_def_boolean(func, "value", 0, "Value", "");
+  RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+}
+
 #endif
diff --git a/source/blender/makesrna/intern/rna_simulation.c b/source/blender/makesrna/intern/rna_simulation.c
new file mode 100644 (file)
index 0000000..2ffda8a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup RNA
+ */
+
+#include <stdlib.h>
+
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "DNA_simulation_types.h"
+
+#include "rna_internal.h"
+
+#ifdef RNA_RUNTIME
+
+#else
+
+static void rna_def_simulation(BlenderRNA *brna)
+{
+  StructRNA *srna;
+
+  srna = RNA_def_struct(brna, "Simulation", "ID");
+  RNA_def_struct_ui_text(srna, "Simulation", "Simulation data-block");
+  RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
+
+  /* common */
+  rna_def_animdata_common(srna);
+}
+
+void RNA_def_simulation(BlenderRNA *brna)
+{
+  rna_def_simulation(brna);
+}
+
+#endif
index c6a94aae450c55d929b95f688690f4a9338391b2..10809b067d7b64745d4b4bb671147d10639927b7 100644 (file)
@@ -5527,6 +5527,13 @@ static void rna_def_fileselect_idfilter(BlenderRNA *brna)
        "Show/hide Point Cloud data-blocks"},
 #  endif
       {FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"},
+#  ifdef WITH_NEW_SIMULATION_TYPE
+      {FILTER_ID_SIM,
+       "filter_simulation",
+       ICON_PHYSICS,
+       "Simulations",
+       "Show Simulation data-blocks"}, /* TODO: Use correct icon. */
+#  endif
       {FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"},
       {FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"},
       {FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"},