[Bf-blender-cvs] [da2c564bb0b] master: Geometry Nodes: Support point clouds in the set material node

Hans Goudey noreply at git.blender.org
Thu Dec 16 22:40:06 CET 2021


Commit: da2c564bb0b9c7214d2e782d297bda4c84f5149c
Author: Hans Goudey
Date:   Thu Dec 16 15:39:59 2021 -0600
Branches: master
https://developer.blender.org/rBda2c564bb0b9c7214d2e782d297bda4c84f5149c

Geometry Nodes: Support point clouds in the set material node

Now that point clouds can be rendered with cycles, it makes sense
to allow assigning a material to them. Note that like volumes, they
only support a single material though.

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

M	source/blender/nodes/geometry/nodes/node_geo_set_material.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc
index fd65bcc235a..084b31f4134 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc
@@ -21,6 +21,7 @@
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_pointcloud_types.h"
 #include "DNA_volume_types.h"
 
 #include "BKE_material.h"
@@ -30,7 +31,8 @@ namespace blender::nodes::node_geo_set_material_cc {
 static void node_declare(NodeDeclarationBuilder &b)
 {
   b.add_input<decl::Geometry>(N_("Geometry"))
-      .supported_type({GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_VOLUME});
+      .supported_type(
+          {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_VOLUME, GEO_COMPONENT_TYPE_POINT_CLOUD});
   b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field();
   b.add_input<decl::Material>(N_("Material")).hide_label();
   b.add_output<decl::Geometry>(N_("Geometry"));
@@ -66,7 +68,10 @@ static void node_geo_exec(GeoNodeExecParams params)
 
   GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
 
+  /* Only add the warnings once, even if there are many unique instances. */
+  bool point_selection_warning = false;
   bool volume_selection_warning = false;
+
   geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
     if (geometry_set.has<MeshComponent>()) {
       MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>();
@@ -91,14 +96,27 @@ static void node_geo_exec(GeoNodeExecParams params)
 
       BKE_id_material_eval_assign(&volume.id, 1, material);
     }
+    if (geometry_set.has_pointcloud()) {
+      PointCloud &pointcloud = *geometry_set.get_pointcloud_for_write();
+
+      if (selection_field.node().depends_on_input()) {
+        point_selection_warning = true;
+      }
+
+      BKE_id_material_eval_assign(&pointcloud.id, 1, material);
+    }
   });
 
   if (volume_selection_warning) {
-    /* Only add the warning once, even if there are many unique volume instances. */
     params.error_message_add(
         NodeWarningType::Info,
         TIP_("Volumes only support a single material; selection input can not be a field"));
   }
+  if (point_selection_warning) {
+    params.error_message_add(
+        NodeWarningType::Info,
+        TIP_("Point clouds only support a single material; selection input can not be a field"));
+  }
 
   params.set_output("Geometry", std::move(geometry_set));
 }



More information about the Bf-blender-cvs mailing list