Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-12-17 00:39:59 +0300
committerHans Goudey <h.goudey@me.com>2021-12-17 00:39:59 +0300
commitda2c564bb0b9c7214d2e782d297bda4c84f5149c (patch)
tree69733bbb7083df96641927b4a8784b051c3dc82c /source/blender/nodes/geometry/nodes/node_geo_set_material.cc
parent35b1e9fc3acd6db565e7e54252a4a4152d8343d9 (diff)
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.
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_set_material.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_set_material.cc22
1 files changed, 20 insertions, 2 deletions
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));
}