Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
| Show First 20 Lines • Show All 407 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| GeometrySet geometry_set_out; | GeometrySet geometry_set_out; | ||||
| GeometryNodePointDistributeMethod distribute_method = | GeometryNodePointDistributeMethod distribute_method = | ||||
| static_cast<GeometryNodePointDistributeMethod>(params.node().custom1); | static_cast<GeometryNodePointDistributeMethod>(params.node().custom1); | ||||
| if (!geometry_set.has_mesh()) { | if (!geometry_set.has_mesh()) { | ||||
| params.error_message_add(NODE_WARNING_ERROR, "Geometry must contain a mesh"); | |||||
| params.set_output("Geometry", std::move(geometry_set_out)); | params.set_output("Geometry", std::move(geometry_set_out)); | ||||
| return; | return; | ||||
| } | } | ||||
| const float density = params.extract_input<float>("Density Max"); | const float density = params.extract_input<float>("Density Max"); | ||||
| const std::string density_attribute = params.extract_input<std::string>("Density Attribute"); | const std::string density_attribute = params.extract_input<std::string>("Density Attribute"); | ||||
| if (density <= 0.0f) { | if (density <= 0.0f) { | ||||
| params.set_output("Geometry", std::move(geometry_set_out)); | params.set_output("Geometry", std::move(geometry_set_out)); | ||||
| return; | return; | ||||
| } | } | ||||
| const MeshComponent &mesh_component = *geometry_set.get_component_for_read<MeshComponent>(); | const MeshComponent &mesh_component = *geometry_set.get_component_for_read<MeshComponent>(); | ||||
| const Mesh *mesh_in = mesh_component.get_for_read(); | const Mesh *mesh_in = mesh_component.get_for_read(); | ||||
| if (mesh_in == nullptr || mesh_in->mpoly == nullptr) { | if (mesh_in->mpoly == nullptr) { | ||||
| params.error_message_add(NODE_WARNING_ERROR, "Mesh has no faces"); | |||||
| params.set_output("Geometry", std::move(geometry_set_out)); | params.set_output("Geometry", std::move(geometry_set_out)); | ||||
| return; | return; | ||||
| } | } | ||||
| const FloatReadAttribute density_factors = mesh_component.attribute_get_for_read<float>( | const FloatReadAttribute density_factors = mesh_component.attribute_get_for_read<float>( | ||||
| density_attribute, ATTR_DOMAIN_POINT, 1.0f); | density_attribute, ATTR_DOMAIN_POINT, 1.0f); | ||||
| const int seed = params.get_input<int>("Seed"); | const int seed = params.get_input<int>("Seed"); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||