[Bf-blender-cvs] [b55c78a289c] master: Simulation: Add modifier to access simulation data

Jacques Lucke noreply at git.blender.org
Wed May 13 12:43:14 CEST 2020


Commit: b55c78a289c600696282f97191d6e800a1c1ac34
Author: Jacques Lucke
Date:   Wed May 13 12:39:17 2020 +0200
Branches: master
https://developer.blender.org/rBb55c78a289c600696282f97191d6e800a1c1ac34

Simulation: Add modifier to access simulation data

For now the "Simulation" modifier only exists for point cloud objects, because
we need this for the particle system. Right now, the modifier is doing nothing.

There is a new `DEG_add_simulation_relation` function that is used
by the modifier to make sure that the simulation is evaluated before
the modifier is executed.

Reviewers: brecht, sergey

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

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_simulation.h
M	source/blender/blenkernel/intern/simulation.cc
M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/node/deg_node.cc
M	source/blender/depsgraph/intern/node/deg_node.h
M	source/blender/depsgraph/intern/node/deg_node_component.cc
M	source/blender/depsgraph/intern/node/deg_node_component.h
M	source/blender/depsgraph/intern/node/deg_node_operation.cc
M	source/blender/depsgraph/intern/node/deg_node_operation.h
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/MOD_modifiertypes.h
A	source/blender/modifiers/intern/MOD_simulation.cc
M	source/blender/modifiers/intern/MOD_util.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 6f3dae9e01c..75e9a320130 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1826,6 +1826,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "thresh", text="Threshold")
         col.prop(md, "face_influence")
 
+    def SIMULATION(self, layout, ob, md):
+        layout.prop(md, "simulation")
+        layout.prop(md, "data_path")
+
 
 class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
     bl_label = "Modifiers"
diff --git a/source/blender/blenkernel/BKE_simulation.h b/source/blender/blenkernel/BKE_simulation.h
index aad0ada75a9..d1cf782e9e5 100644
--- a/source/blender/blenkernel/BKE_simulation.h
+++ b/source/blender/blenkernel/BKE_simulation.h
@@ -23,9 +23,12 @@ extern "C" {
 
 struct Main;
 struct Simulation;
+struct Depsgraph;
 
 void *BKE_simulation_add(struct Main *bmain, const char *name);
 
+void BKE_simulation_data_update(struct Depsgraph *depsgraph, struct Scene *scene);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index ace91424764..b4cfa7cf0ef 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -22,6 +22,7 @@
 
 #include "DNA_ID.h"
 #include "DNA_defaults.h"
+#include "DNA_scene_types.h"
 #include "DNA_simulation_types.h"
 
 #include "BLI_compiler_compat.h"
@@ -44,6 +45,8 @@
 
 #include "BLT_translation.h"
 
+#include "DEG_depsgraph.h"
+
 static void simulation_init_data(ID *id)
 {
   Simulation *simulation = (Simulation *)id;
@@ -108,3 +111,7 @@ IDTypeInfo IDType_ID_SIM = {
     /* free_data */ simulation_free_data,
     /* make_local */ nullptr,
 };
+
+void BKE_simulation_data_update(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(scene))
+{
+}
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 19e9c5c26b1..81157102bb1 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -39,6 +39,7 @@ struct ID;
 struct Main;
 struct Object;
 struct Scene;
+struct Simulation;
 struct ViewLayer;
 struct bNodeTree;
 
@@ -153,6 +154,9 @@ void DEG_add_object_relation(struct DepsNodeHandle *node_handle,
                              struct Object *object,
                              eDepsObjectComponentType component,
                              const char *description);
+void DEG_add_simulation_relation(struct DepsNodeHandle *node_handle,
+                                 struct Simulation *simulation,
+                                 const char *description);
 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
                            struct Object *object,
                            const char *bone_name,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index cefe87d1e1f..44ddd9522e0 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -97,6 +97,7 @@
 #include "BKE_scene.h"
 #include "BKE_sequencer.h"
 #include "BKE_shader_fx.h"
+#include "BKE_simulation.h"
 #include "BKE_sound.h"
 #include "BKE_tracking.h"
 #include "BKE_volume.h"
@@ -1753,6 +1754,11 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
   add_id_node(&simulation->id);
   build_animdata(&simulation->id);
   build_parameters(&simulation->id);
+
+  add_operation_node(&simulation->id,
+                     NodeType::SIMULATION,
+                     OperationCode::SIMULATION_EVAL,
+                     function_bind(BKE_simulation_data_update, _1, get_cow_datablock(scene_)));
 }
 
 void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 6bdb7500b4a..8f977e07f17 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2578,6 +2578,11 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
   }
   build_animdata(&simulation->id);
   build_parameters(&simulation->id);
+
+  OperationKey simulation_update_key(
+      &simulation->id, NodeType::SIMULATION, OperationCode::SIMULATION_EVAL);
+  TimeSourceKey time_src_key;
+  add_relation(time_src_key, simulation_update_key, "TimeSrc -> Simulation");
 }
 
 void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index bde48affc28..dbe88ee92a8 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -439,7 +439,8 @@ static void deg_debug_graphviz_node(const DebugContext &ctx, const Node *node)
     case NodeType::SYNCHRONIZATION:
     case NodeType::AUDIO:
     case NodeType::ARMATURE:
-    case NodeType::GENERIC_DATABLOCK: {
+    case NodeType::GENERIC_DATABLOCK:
+    case NodeType::SIMULATION: {
       ComponentNode *comp_node = (ComponentNode *)node;
       if (!comp_node->operations.empty()) {
         deg_debug_graphviz_node_cluster_begin(ctx, node);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 9e12d00b42f..9e50bd87d6c 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -34,6 +34,7 @@
 #include "DNA_cachefile_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_simulation_types.h"
 
 #include "BKE_main.h"
 #include "BKE_scene.h"
@@ -103,6 +104,16 @@ void DEG_add_object_relation(DepsNodeHandle *node_handle,
   deg_node_handle->builder->add_node_handle_relation(comp_key, deg_node_handle, description);
 }
 
+void DEG_add_simulation_relation(DepsNodeHandle *node_handle,
+                                 Simulation *simulation,
+                                 const char *description)
+{
+  DEG::OperationKey operation_key(
+      &simulation->id, DEG::NodeType::SIMULATION, DEG::OperationCode::SIMULATION_EVAL);
+  DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
+  deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description);
+}
+
 void DEG_add_object_cache_relation(DepsNodeHandle *node_handle,
                                    CacheFile *cache_file,
                                    eDepsObjectComponentType component,
diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc
index d95e05a6f4f..10760d3170b 100644
--- a/source/blender/depsgraph/intern/node/deg_node.cc
+++ b/source/blender/depsgraph/intern/node/deg_node.cc
@@ -114,6 +114,8 @@ const char *nodeTypeAsString(NodeType type)
       return "ARMATURE";
     case NodeType::GENERIC_DATABLOCK:
       return "GENERIC_DATABLOCK";
+    case NodeType::SIMULATION:
+      return "SIMULATION";
 
     /* Total number of meaningful node types. */
     case NodeType::NUM_TYPES:
@@ -172,6 +174,7 @@ eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type)
     case NodeType::SHADING:
     case NodeType::CACHE:
     case NodeType::PROXY:
+    case NodeType::SIMULATION:
       return DEG_SCENE_COMP_PARAMETERS;
   }
   BLI_assert(!"Unhandled node type, not suppsed to happen.");
@@ -245,6 +248,7 @@ eDepsObjectComponentType nodeTypeToObjectComponent(NodeType type)
     case NodeType::BATCH_CACHE:
     case NodeType::DUPLI:
     case NodeType::SYNCHRONIZATION:
+    case NodeType::SIMULATION:
     case NodeType::UNDEFINED:
     case NodeType::NUM_TYPES:
       return DEG_OB_COMP_PARAMETERS;
diff --git a/source/blender/depsgraph/intern/node/deg_node.h b/source/blender/depsgraph/intern/node/deg_node.h
index ad1eba2f7ba..f0ce38ddeae 100644
--- a/source/blender/depsgraph/intern/node/deg_node.h
+++ b/source/blender/depsgraph/intern/node/deg_node.h
@@ -127,6 +127,8 @@ enum class NodeType {
   DUPLI,
   /* Synchronization back to original datablock. */
   SYNCHRONIZATION,
+  /* Simulation component. */
+  SIMULATION,
 
   /* Total number of meaningful node types. */
   NUM_TYPES,
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc
index e2c1f74ec46..f4d042fecf9 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_component.cc
@@ -333,6 +333,7 @@ DEG_COMPONENT_NODE_DEFINE(Synchronization, SYNCHRONIZATION, 0);
 DEG_COMPONENT_NODE_DEFINE(Audio, AUDIO, 0);
 DEG_COMPONENT_NODE_DEFINE(Armature, ARMATURE, 0);
 DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0);
+DEG_COMPONENT_NODE_DEFINE(Simulation, SIMULATION, 0);
 
 /* Node Types Register =================================== */
 
@@ -362,6 +363,7 @@ void deg_register_component_depsnodes()
   register_node_typeinfo(&DNTI_AUDIO);
   register_node_typeinfo(&DNTI_ARMATURE);
   register_node_typeinfo(&DNTI_GENERIC_DATABLOCK);
+  register_node_typeinfo(&DNTI_SIMULATION);
 }
 
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h
index 41d5c130ffd..ca37401d200 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.h
+++ b/source/blender/depsgraph/intern/node/deg_node_component.h
@@ -191,6 +191,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Synchronization);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Audio);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(Armature);
 DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Simulation);
 
 /* Bone Component */
 struct BoneComponentNode : public ComponentNode {
diff --git a/so

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list