Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
| Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | static void randomize_attribute(GeometryComponent &component, | ||||
| const bNode &node = params.node(); | const bNode &node = params.node(); | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(node.custom1); | const CustomDataType data_type = static_cast<CustomDataType>(node.custom1); | ||||
| const AttributeDomain domain = static_cast<AttributeDomain>(node.custom2); | const AttributeDomain domain = static_cast<AttributeDomain>(node.custom2); | ||||
| const std::string attribute_name = params.get_input<std::string>("Attribute"); | const std::string attribute_name = params.get_input<std::string>("Attribute"); | ||||
| if (attribute_name.empty()) { | if (attribute_name.empty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| WriteAttributePtr attribute = component.attribute_try_ensure_for_write( | OutputAttributePtr attribute = component.attribute_try_get_for_output( | ||||
| attribute_name, domain, data_type); | attribute_name, domain, data_type); | ||||
| if (!attribute) { | if (!attribute) { | ||||
| return; | return; | ||||
| } | } | ||||
| Array<uint32_t> hashes = get_geometry_element_ids_as_uints(component, domain); | Array<uint32_t> hashes = get_geometry_element_ids_as_uints(component, domain); | ||||
| switch (data_type) { | switch (data_type) { | ||||
| Show All 11 Lines | switch (data_type) { | ||||
| } | } | ||||
| case CD_PROP_BOOL: { | case CD_PROP_BOOL: { | ||||
| randomize_attribute_bool(*attribute, hashes, seed); | randomize_attribute_bool(*attribute, hashes, seed); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| attribute.save(); | |||||
| } | } | ||||
| static void geo_node_random_attribute_exec(GeoNodeExecParams params) | static void geo_node_random_attribute_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| const int seed = params.get_input<int>("Seed"); | const int seed = params.get_input<int>("Seed"); | ||||
| if (geometry_set.has<MeshComponent>()) { | if (geometry_set.has<MeshComponent>()) { | ||||
| Show All 24 Lines | |||||