Page MenuHome

Geometry Nodes: Support computing new attribute before deleting old one.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Jan 14 2021, 12:56 PM.

Details

Summary

This introduces the concept of an OutputAttributePtr, which is a WriteAttributePtr that might not be stored at its final destination yet.

It solves the

If an input and an output attribute have the same name but different type, first compute the new attribute, before deleting the old one.

part of T83793.

Documentation is provided in-code.

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Jan 14 2021, 12:56 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/blenkernel/intern/attribute_access.cc
824–837

I wonder if reordering the cases would make this a bit more readable?

WriteAttributePtr attribute = this->attribute_try_get_for_write(attribute_name);

/* If the attribute doesn't exist, make a new one with the correct type. */
if (!attribute) {
  this->attribute_try_create(attribute_name, domain, data_type);
  attribute = this->attribute_try_get_for_write(attribute_name);
  return OutputAttributePtr(std::move(attribute));
}

/* If an existing attribute has a matching domain and type, just use that. */
if (attribute->domain() == domain && attribute->cpp_type() == *cpp_type) {
  return OutputAttributePtr(std::move(attribute));
}

/* Otherwise create a temporary buffer to use before saving the new attribute. */

The comments might help, or they might be redundant, either way.

This revision is now accepted and ready to land.Jan 14 2021, 3:07 PM
source/blender/blenkernel/intern/attribute_access.cc
824–837

Yeah, makes sense to change the order.