[Bf-blender-cvs] [89880e891c5] temp-test-point-cloud-simulation-depsgraph-integration: initial testing for integration in depsgraph

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


Commit: 89880e891c56b67996d4d4511d7516c37b38f793
Author: Jacques Lucke
Date:   Wed Apr 15 18:26:07 2020 +0200
Branches: temp-test-point-cloud-simulation-depsgraph-integration
https://developer.blender.org/rB89880e891c56b67996d4d4511d7516c37b38f793

initial testing for integration in depsgraph

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

M	release/scripts/startup/bl_ui/properties_data_pointcloud.py
M	source/blender/blenkernel/intern/pointcloud.c
M	source/blender/blenloader/intern/readfile.c
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/node/deg_node_operation.cc
M	source/blender/depsgraph/intern/node/deg_node_operation.h
M	source/blender/draw/intern/draw_cache_impl_pointcloud.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/makesdna/DNA_pointcloud_types.h
M	source/blender/makesrna/intern/rna_pointcloud.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_pointcloud.py b/release/scripts/startup/bl_ui/properties_data_pointcloud.py
index 10ebdea3155..31275089948 100644
--- a/release/scripts/startup/bl_ui/properties_data_pointcloud.py
+++ b/release/scripts/startup/bl_ui/properties_data_pointcloud.py
@@ -58,6 +58,8 @@ class DATA_PT_pointcloud(DataButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
         pointcloud = context.pointcloud
+
+        layout.prop(pointcloud, "source_simulation")
         pass
 
 class DATA_PT_custom_props_pointcloud(DataButtonsPanel, PropertyPanel, Panel):
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c
index 31b8de53291..c13376377d1 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.c
@@ -21,8 +21,11 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_defaults.h"
+#include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_pointcloud_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_simulation_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_math.h"
@@ -48,24 +51,6 @@
 
 /* PointCloud datablock */
 
-static void pointcloud_random(PointCloud *pointcloud)
-{
-  pointcloud->totpoint = 400;
-  CustomData_realloc(&pointcloud->pdata, pointcloud->totpoint);
-  BKE_pointcloud_update_customdata_pointers(pointcloud);
-
-  RNG *rng = BLI_rng_new(0);
-
-  for (int i = 0; i < pointcloud->totpoint; i++) {
-    pointcloud->co[i][0] = 2.0f * BLI_rng_get_float(rng) - 1.0f;
-    pointcloud->co[i][1] = 2.0f * BLI_rng_get_float(rng) - 1.0f;
-    pointcloud->co[i][2] = 2.0f * BLI_rng_get_float(rng) - 1.0f;
-    pointcloud->radius[i] = 0.05f * BLI_rng_get_float(rng);
-  }
-
-  BLI_rng_free(rng);
-}
-
 static void pointcloud_init_data(ID *id)
 {
   PointCloud *pointcloud = (PointCloud *)id;
@@ -77,8 +62,6 @@ static void pointcloud_init_data(ID *id)
   CustomData_add_layer(&pointcloud->pdata, CD_LOCATION, CD_CALLOC, NULL, pointcloud->totpoint);
   CustomData_add_layer(&pointcloud->pdata, CD_RADIUS, CD_CALLOC, NULL, pointcloud->totpoint);
   BKE_pointcloud_update_customdata_pointers(pointcloud);
-
-  pointcloud_random(pointcloud);
 }
 
 void *BKE_pointcloud_add(Main *bmain, const char *name)
@@ -184,7 +167,7 @@ void BKE_pointcloud_update_customdata_pointers(PointCloud *pointcloud)
 
 PointCloud *BKE_pointcloud_new_for_eval(const PointCloud *pointcloud_src, int totpoint)
 {
-  PointCloud *pointcloud_dst = BKE_id_new_nomain(ID_HA, NULL);
+  PointCloud *pointcloud_dst = BKE_id_new_nomain(ID_PT, NULL);
 
   STRNCPY(pointcloud_dst->id.name, pointcloud_src->id.name);
   pointcloud_dst->mat = MEM_dupallocN(pointcloud_src->mat);
@@ -212,11 +195,35 @@ PointCloud *BKE_pointcloud_copy_for_eval(struct PointCloud *pointcloud_src, bool
 }
 
 static PointCloud *pointcloud_evaluate_modifiers(struct Depsgraph *UNUSED(depsgraph),
-                                                 struct Scene *UNUSED(scene),
+                                                 Scene *scene,
                                                  Object *UNUSED(object),
                                                  PointCloud *pointcloud_input)
 {
-  return pointcloud_input;
+  PointCloud *pointcloud = BKE_id_new_nomain(ID_PT, "New Point Cloud");
+
+  Simulation *simulation = pointcloud_input->source_simulation;
+  if (simulation == NULL) {
+    pointcloud->totpoint = 20;
+  }
+  else {
+    pointcloud->totpoint = BLI_listbase_count(&simulation->nodetree->nodes);
+  }
+  CustomData_realloc(&pointcloud->pdata, pointcloud->totpoint);
+  BKE_pointcloud_update_customdata_pointers(pointcloud);
+
+  RNG *rng = BLI_rng_new(45);
+
+  printf("PointCloud eval\n");
+
+  for (int i = 0; i < pointcloud->totpoint; i++) {
+    pointcloud->co[i][0] = 0.1f * scene->r.cfra;
+    pointcloud->co[i][1] = BLI_rng_get_float(rng);
+    pointcloud->co[i][2] = BLI_rng_get_float(rng);
+    pointcloud->radius[i] = 0.1f;
+  }
+
+  BLI_rng_free(rng);
+  return pointcloud;
 }
 
 void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9214dd4b1de..0ce04d81778 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9131,6 +9131,7 @@ static void lib_link_pointcloud(FileData *fd, Main *UNUSED(main), PointCloud *po
   for (int a = 0; a < pointcloud->totcol; a++) {
     pointcloud->mat[a] = newlibadr(fd, pointcloud->id.lib, pointcloud->mat[a]);
   }
+  pointcloud->source_simulation = newlibadr(fd, pointcloud->id.lib, pointcloud->source_simulation);
 }
 
 static void direct_link_pointcloud(FileData *fd, PointCloud *pointcloud)
@@ -9145,6 +9146,8 @@ static void direct_link_pointcloud(FileData *fd, PointCloud *pointcloud)
   /* Materials */
   pointcloud->mat = newdataadr(fd, pointcloud->mat);
   test_pointer_array(fd, (void **)&pointcloud->mat);
+
+  pointcloud->batch_cache = NULL;
 }
 
 /** \} */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index a837eaf32dc..46923721e63 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -57,6 +57,7 @@ extern "C" {
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
+#include "DNA_pointcloud_types.h"
 #include "DNA_rigidbody_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
@@ -1361,6 +1362,11 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
     case ID_PT: {
       op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
       op_node->set_as_entry();
+
+      PointCloud *pointcloud = (PointCloud *)obdata;
+      if (pointcloud->source_simulation) {
+        build_simulation(pointcloud->source_simulation);
+      }
       break;
     }
     case ID_VO: {
@@ -1708,9 +1714,18 @@ void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
   if (built_map_.checkIsBuiltAndTag(simulation)) {
     return;
   }
+
+  {
+    add_operation_node(&simulation->id,
+                       NodeType::PARAMETERS,
+                       OperationCode::SIMULATION_EVAL,
+                       [](struct ::Depsgraph *depsgraph) { printf("Sim eval %p\n", depsgraph); });
+  }
+
   add_id_node(&simulation->id);
   build_animdata(&simulation->id);
   build_parameters(&simulation->id);
+  build_nodetree(simulation->nodetree);
 }
 
 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 f49f4cafa47..c09b19183ea 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -59,6 +59,7 @@ extern "C" {
 #include "DNA_object_force_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
+#include "DNA_pointcloud_types.h"
 #include "DNA_rigidbody_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
@@ -2163,8 +2164,16 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
     }
     case ID_HA:
       break;
-    case ID_PT:
+    case ID_PT: {
+      PointCloud *pointcloud = (PointCloud *)obdata;
+      if (pointcloud->source_simulation != NULL) {
+        ComponentKey simulation_key(&pointcloud->source_simulation->id, NodeType::PARAMETERS);
+        ComponentKey geometry_key(obdata, NodeType::GEOMETRY);
+        add_relation(simulation_key, geometry_key, "Source Simulation");
+        build_simulation(pointcloud->source_simulation);
+      }
       break;
+    }
     case ID_VO: {
       Volume *volume = (Volume *)obdata;
       if (volume->is_sequence) {
@@ -2513,6 +2522,19 @@ void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
   }
   build_animdata(&simulation->id);
   build_parameters(&simulation->id);
+
+  TimeSourceKey time_key;
+  OperationKey simulation_key(
+      &simulation->id, NodeType::PARAMETERS, OperationCode::SIMULATION_EVAL);
+  add_relation(time_key, simulation_key, "Simulation time source");
+
+  OperationKey parameters_exit_key(
+      &simulation->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
+  add_relation(simulation_key, parameters_exit_key, "Simulation exit relation");
+
+  build_nodetree(simulation->nodetree);
+  ComponentKey nodetree_key(&simulation->nodetree->id, NodeType::PARAMETERS);
+  add_relation(nodetree_key, simulation_key, "Simulation node tree");
 }
 
 void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index 78399d5c953..17a26c8704d 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -193,6 +193,9 @@ const char *operationCodeAsString(OperationCode opcode)
     /* instancing/duplication. */
     case OperationCode::DUPLI:
       return "DUPLI";
+    /* Simulation. */
+    case OperationCode::SIMULATION_EVAL:
+      return "SIMULATION_EVAL";
   }
   BLI_assert(!"Unhandled operation code, should never happen.");
   return "UNKNOWN";
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h
index bdc0df7f399..0962860bf23 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.h
@@ -197,6 +197,9 @@ enum class OperationCode {
 
   /* Duplication/instancing system. --------------------------------------- */
   DUPLI,
+
+  /* Simulation. ---------------------------------------------------------- */
+  SIMULATION_EVAL,
 };
 const char *operationCodeAsString(OperationCode opcode);
 
diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.c b/source/blender/draw/inter

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list