Differential D14970 Diff 55893 source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
| Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if (domain_size == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| bke::GeometryFieldContext field_context{component, domain}; | bke::GeometryFieldContext field_context{component, domain}; | ||||
| const IndexMask mask{IndexMask(domain_size)}; | const IndexMask mask{IndexMask(domain_size)}; | ||||
| const CPPType &type = field.cpp_type(); | const CPPType &type = field.cpp_type(); | ||||
| const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(type); | const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(type); | ||||
| const bke::AttributeValidator validator = attributes.lookup_validator(name); | |||||
| /* Could avoid allocating a new buffer if: | /* Could avoid allocating a new buffer if: | ||||
| * - We are writing to an attribute that exists already with the correct domain and type. | * - We are writing to an attribute that exists already with the correct domain and type. | ||||
| * - The field does not depend on that attribute (we can't easily check for that yet). */ | * - The field does not depend on that attribute (we can't easily check for that yet). */ | ||||
| void *buffer = MEM_mallocN(type.size() * domain_size, __func__); | void *buffer = MEM_mallocN(type.size() * domain_size, __func__); | ||||
| fn::FieldEvaluator evaluator{field_context, &mask}; | fn::FieldEvaluator evaluator{field_context, &mask}; | ||||
| evaluator.add_with_destination(field, GMutableSpan{type, buffer, domain_size}); | evaluator.add_with_destination(validator.validate_field_if_necessary(field), | ||||
| GMutableSpan{type, buffer, domain_size}); | |||||
| evaluator.evaluate(); | evaluator.evaluate(); | ||||
| if (GAttributeWriter attribute = attributes.lookup_for_write(name)) { | if (GAttributeWriter attribute = attributes.lookup_for_write(name)) { | ||||
| if (attribute.domain == domain && attribute.varray.type() == type) { | if (attribute.domain == domain && attribute.varray.type() == type) { | ||||
| attribute.varray.set_all(buffer); | attribute.varray.set_all(buffer); | ||||
| attribute.finish(); | attribute.finish(); | ||||
| type.destruct_n(buffer, domain_size); | type.destruct_n(buffer, domain_size); | ||||
| MEM_freeN(buffer); | MEM_freeN(buffer); | ||||
| ▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines | |||||