Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/attribute_access.cc
| Show First 20 Lines • Show All 767 Lines • ▼ Show 20 Lines | ReadAttributePtr GeometryComponent::attribute_get_for_read(const StringRef attribute_name, | ||||
| const void *default_value) const | const void *default_value) const | ||||
| { | { | ||||
| BLI_assert(this->attribute_domain_with_type_supported(domain, data_type)); | BLI_assert(this->attribute_domain_with_type_supported(domain, data_type)); | ||||
| ReadAttributePtr attribute = this->attribute_try_get_for_read(attribute_name, domain, data_type); | ReadAttributePtr attribute = this->attribute_try_get_for_read(attribute_name, domain, data_type); | ||||
| if (attribute) { | if (attribute) { | ||||
| return attribute; | return attribute; | ||||
| } | } | ||||
| if (default_value != nullptr) { | |||||
| return this->attribute_get_constant_for_read(domain, data_type, default_value); | return this->attribute_get_constant_for_read(domain, data_type, default_value); | ||||
| } | } | ||||
| return nullptr; | |||||
| } | |||||
| blender::bke::ReadAttributePtr GeometryComponent::attribute_get_constant_for_read( | blender::bke::ReadAttributePtr GeometryComponent::attribute_get_constant_for_read( | ||||
| const AttributeDomain domain, const CustomDataType data_type, const void *value) const | const AttributeDomain domain, const CustomDataType data_type, const void *value) const | ||||
| { | { | ||||
| BLI_assert(this->attribute_domain_supported(domain)); | BLI_assert(this->attribute_domain_supported(domain)); | ||||
| const blender::fn::CPPType *cpp_type = blender::bke::custom_data_type_to_cpp_type(data_type); | const blender::fn::CPPType *cpp_type = blender::bke::custom_data_type_to_cpp_type(data_type); | ||||
| BLI_assert(cpp_type != nullptr); | BLI_assert(cpp_type != nullptr); | ||||
| if (value == nullptr) { | if (value == nullptr) { | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | void OutputAttributePtr::save() | ||||
| new_attribute->apply_span(); | new_attribute->apply_span(); | ||||
| attribute_.reset(); | attribute_.reset(); | ||||
| } | } | ||||
| OutputAttributePtr::~OutputAttributePtr() | OutputAttributePtr::~OutputAttributePtr() | ||||
| { | { | ||||
| if (attribute_) { | if (attribute_) { | ||||
| /* TODO: Fix that this is printing all the time now, even after applying and saving. */ | |||||
| CLOG_ERROR(&LOG, "Forgot to call #save or #apply_span_and_save."); | CLOG_ERROR(&LOG, "Forgot to call #save or #apply_span_and_save."); | ||||
| } | } | ||||
| } | } | ||||
| /* Utility function to call #apply_span and #save in the right order. */ | /* Utility function to call #apply_span and #save in the right order. */ | ||||
| void OutputAttributePtr::apply_span_and_save() | void OutputAttributePtr::apply_span_and_save() | ||||
| { | { | ||||
| BLI_assert(attribute_); | BLI_assert(attribute_); | ||||
| ▲ Show 20 Lines • Show All 399 Lines • Show Last 20 Lines | |||||