Differential D15500 Diff 53862 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 102 Lines • ▼ Show 20 Lines | static void try_capture_field_on_geometry(GeometryComponent &component, | ||||
| * - We are writing to an attribute that exists already. | * - We are writing to an attribute that exists already. | ||||
| * - 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(field, GMutableSpan{type, buffer, domain_size}); | ||||
| evaluator.evaluate(); | evaluator.evaluate(); | ||||
| attributes.remove(name); | |||||
| if (attributes.contains(name)) { | if (attributes.contains(name)) { | ||||
| GAttributeWriter write_attribute = attributes.lookup_for_write(name); | GAttributeWriter write_attribute = attributes.lookup_for_write(name); | ||||
| if (write_attribute && write_attribute.domain == domain && | if (write_attribute && write_attribute.domain == domain && | ||||
| write_attribute.varray.type() == type) { | write_attribute.varray.type() == type) { | ||||
| write_attribute.varray.set_all(buffer); | write_attribute.varray.set_all(buffer); | ||||
| write_attribute.finish(); | write_attribute.finish(); | ||||
| type.destruct_n(buffer, domain_size); | |||||
| MEM_freeN(buffer); | |||||
| return; | |||||
| } | } | ||||
| else { | else { | ||||
| attributes.remove(name); | |||||
| if (attributes.contains(name)) { | |||||
| /* Cannot change type of built-in attribute. */ | /* Cannot change type of built-in attribute. */ | ||||
| } | |||||
| type.destruct_n(buffer, domain_size); | type.destruct_n(buffer, domain_size); | ||||
| MEM_freeN(buffer); | MEM_freeN(buffer); | ||||
| return; | |||||
| } | } | ||||
| else { | } | ||||
| } | |||||
| if (!attributes.add(name, domain, data_type, bke::AttributeInitMove{buffer})) { | if (!attributes.add(name, domain, data_type, bke::AttributeInitMove{buffer})) { | ||||
| MEM_freeN(buffer); | MEM_freeN(buffer); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| std::string name = params.extract_input<std::string>("Name"); | std::string name = params.extract_input<std::string>("Name"); | ||||
| if (name.empty()) { | if (name.empty()) { | ||||
| params.set_output("Geometry", std::move(geometry_set)); | params.set_output("Geometry", std::move(geometry_set)); | ||||
| ▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines | |||||