Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/attribute_access.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include <utility> | #include <utility> | ||||
| #include "BKE_attribute_math.hh" | #include "BKE_attribute_math.hh" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_geometry_fields.hh" | #include "BKE_geometry_fields.hh" | ||||
| #include "BKE_geometry_set.hh" | #include "BKE_geometry_set.hh" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_pointcloud.h" | #include "BKE_pointcloud.h" | ||||
| #include "BKE_texture_field.hh" | |||||
| #include "BKE_type_conversions.hh" | #include "BKE_type_conversions.hh" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_pointcloud_types.h" | #include "DNA_pointcloud_types.h" | ||||
| #include "BLI_color.hh" | #include "BLI_color.hh" | ||||
| #include "BLI_math_vec_types.hh" | #include "BLI_math_vec_types.hh" | ||||
| ▲ Show 20 Lines • Show All 765 Lines • ▼ Show 20 Lines | GVArray GeometryFieldInput::get_varray_for_context(const fn::FieldContext &context, | ||||
| ResourceScope &UNUSED(scope)) const | ResourceScope &UNUSED(scope)) const | ||||
| { | { | ||||
| if (const GeometryComponentFieldContext *geometry_context = | if (const GeometryComponentFieldContext *geometry_context = | ||||
| dynamic_cast<const GeometryComponentFieldContext *>(&context)) { | dynamic_cast<const GeometryComponentFieldContext *>(&context)) { | ||||
| const GeometryComponent &component = geometry_context->geometry_component(); | const GeometryComponent &component = geometry_context->geometry_component(); | ||||
| const eAttrDomain domain = geometry_context->domain(); | const eAttrDomain domain = geometry_context->domain(); | ||||
| return this->get_varray_for_context(component, domain, mask); | return this->get_varray_for_context(component, domain, mask); | ||||
| } | } | ||||
| else if (const TextureFieldContext *texture_context = dynamic_cast<const TextureFieldContext *>( | |||||
| &context)) { | |||||
| return this->get_varray_for_context(*texture_context); | |||||
| } | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| GVArray AttributeFieldInput::get_varray_for_context(const GeometryComponent &component, | GVArray AttributeFieldInput::get_varray_for_context(const GeometryComponent &component, | ||||
| const eAttrDomain domain, | const eAttrDomain domain, | ||||
| IndexMask UNUSED(mask)) const | IndexMask UNUSED(mask)) const | ||||
| { | { | ||||
| const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_); | const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_); | ||||
| if (auto attributes = component.attributes()) { | if (auto attributes = component.attributes()) { | ||||
| return attributes->lookup(name_, domain, data_type); | return attributes->lookup(name_, domain, data_type); | ||||
| } | } | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| GVArray AttributeFieldInput::get_varray_for_context(const TextureFieldContext &context) const | |||||
| { | |||||
| const eCustomDataType data_type = cpp_type_to_custom_data_type(*type_); | |||||
| if (auto attributes = context.attributes()) { | |||||
| return attributes->lookup(name_, ATTR_DOMAIN_TEXTURE, data_type); | |||||
| } | |||||
| return {}; | |||||
| } | |||||
| std::string AttributeFieldInput::socket_inspection_name() const | std::string AttributeFieldInput::socket_inspection_name() const | ||||
| { | { | ||||
| std::stringstream ss; | std::stringstream ss; | ||||
| ss << '"' << name_ << '"' << TIP_(" attribute from geometry"); | ss << '"' << name_ << '"' << TIP_(" attribute from geometry"); | ||||
| return ss.str(); | return ss.str(); | ||||
| } | } | ||||
| uint64_t AttributeFieldInput::hash() const | uint64_t AttributeFieldInput::hash() const | ||||
| ▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines | |||||