Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-06-02 17:42:53 +0300
committerJacques Lucke <jacques@blender.org>2022-06-02 17:42:53 +0300
commit9e43a57d22df57f5e7a572ddff3591df8120b547 (patch)
tree87a63cb5895fda16cb3d0511b48a65cdb458153c /intern/cycles
parent9580f23596fae21d867fa3dae88efd4c57016139 (diff)
Cycles: fix missing attribute update
Differential Revision: https://developer.blender.org/D15102
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/scene/attribute.cpp52
-rw-r--r--intern/cycles/scene/attribute.h1
2 files changed, 33 insertions, 20 deletions
diff --git a/intern/cycles/scene/attribute.cpp b/intern/cycles/scene/attribute.cpp
index df01189a54b..d6b4c0240f6 100644
--- a/intern/cycles/scene/attribute.cpp
+++ b/intern/cycles/scene/attribute.cpp
@@ -661,6 +661,26 @@ Attribute *AttributeSet::find(AttributeStandard std) const
return NULL;
}
+Attribute *AttributeSet::find_matching(const Attribute &other)
+{
+ for (Attribute &attr : attributes) {
+ if (attr.name != other.name) {
+ continue;
+ }
+ if (attr.std != other.std) {
+ continue;
+ }
+ if (attr.type != other.type) {
+ continue;
+ }
+ if (attr.element != other.element) {
+ continue;
+ }
+ return &attr;
+ }
+ return nullptr;
+}
+
void AttributeSet::remove(AttributeStandard std)
{
Attribute *attr = find(std);
@@ -729,32 +749,24 @@ void AttributeSet::clear(bool preserve_voxel_data)
void AttributeSet::update(AttributeSet &&new_attributes)
{
- /* add or update old_attributes based on the new_attributes */
- foreach (Attribute &attr, new_attributes.attributes) {
- Attribute *nattr = add(attr.name, attr.type, attr.element);
- nattr->std = attr.std;
- nattr->set_data_from(std::move(attr));
- }
-
- /* remove any attributes not on new_attributes */
+ /* Remove any attributes not on new_attributes. */
list<Attribute>::iterator it;
for (it = attributes.begin(); it != attributes.end();) {
- if (it->std != ATTR_STD_NONE) {
- if (new_attributes.find(it->std) == nullptr) {
- remove(it++);
- continue;
- }
- }
- else if (it->name != "") {
- if (new_attributes.find(it->name) == nullptr) {
- remove(it++);
- continue;
- }
+ const Attribute &old_attr = *it;
+ if (new_attributes.find_matching(old_attr) == nullptr) {
+ remove(it++);
+ continue;
}
-
it++;
}
+ /* Add or update old_attributes based on the new_attributes. */
+ foreach (Attribute &attr, new_attributes.attributes) {
+ Attribute *nattr = add(attr.name, attr.type, attr.element);
+ nattr->std = attr.std;
+ nattr->set_data_from(std::move(attr));
+ }
+
/* If all attributes were replaced, transform is no longer applied. */
geometry->transform_applied = false;
}
diff --git a/intern/cycles/scene/attribute.h b/intern/cycles/scene/attribute.h
index fd13b8ff6de..7f8cbf32049 100644
--- a/intern/cycles/scene/attribute.h
+++ b/intern/cycles/scene/attribute.h
@@ -194,6 +194,7 @@ class AttributeSet {
void remove(AttributeStandard std);
Attribute *find(AttributeRequest &req);
+ Attribute *find_matching(const Attribute &other);
void remove(Attribute *attribute);