From c4f7f59c659f7d986e4a2602eff4135fc58cf2f1 Mon Sep 17 00:00:00 2001 From: Christophe Hery Date: Mon, 11 Apr 2022 14:52:20 -0500 Subject: Curves: Add support for new curves type in Set Material node Simply add the few lines so that the Cycles renderable New Curves (with a small temporary patch to output the new type to render engines) would get assigned a shader (in particular a hair shader). Differential Revision: https://developer.blender.org/D14622 --- .../blender/nodes/geometry/nodes/node_geo_set_material.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source') 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 c48129acbdc..70063b3af19 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc @@ -9,6 +9,7 @@ #include "DNA_meshdata_types.h" #include "DNA_pointcloud_types.h" #include "DNA_volume_types.h" +#include "DNA_curves_types.h" #include "BKE_material.h" @@ -63,6 +64,7 @@ static void node_geo_exec(GeoNodeExecParams params) /* Only add the warnings once, even if there are many unique instances. */ bool point_selection_warning = false; bool volume_selection_warning = false; + bool curves_selection_warning = false; geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { if (geometry_set.has_mesh()) { @@ -89,6 +91,12 @@ static void node_geo_exec(GeoNodeExecParams params) point_selection_warning = true; } } + if (Curves *curves = geometry_set.get_curves_for_write()) { + BKE_id_material_eval_assign(&curves->id, 1, material); + if (selection_field.node().depends_on_input()) { + curves_selection_warning = true; + } + } }); if (volume_selection_warning) { @@ -101,6 +109,11 @@ static void node_geo_exec(GeoNodeExecParams params) NodeWarningType::Info, TIP_("Point clouds only support a single material; selection input can not be a field")); } + if (curves_selection_warning) { + params.error_message_add( + NodeWarningType::Info, + TIP_("Curves only support a single material; selection input can not be a field")); + } params.set_output("Geometry", std::move(geometry_set)); } -- cgit v1.2.3