Cycles: detect when attributes have changed

This patch has originally been written by Kévin Dietrich, thanks!
It is part of D10210.

As Brecht noted in D10210, this might not handle all cases yet.
I better solution should come soonish.
This commit is contained in:
Jacques Lucke
2021-02-17 12:04:45 +01:00
parent 17dddc9417
commit 9419452f85
3 changed files with 19 additions and 0 deletions

View File

@@ -440,6 +440,7 @@ Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement eleme
Attribute new_attr(name, type, element, geometry, prim);
attributes.emplace_back(std::move(new_attr));
modified = true;
return &attributes.back();
}
@@ -461,6 +462,7 @@ void AttributeSet::remove(ustring name)
for (it = attributes.begin(); it != attributes.end(); it++) {
if (&*it == attr) {
modified = true;
attributes.erase(it);
return;
}
@@ -606,6 +608,7 @@ void AttributeSet::remove(AttributeStandard std)
for (it = attributes.begin(); it != attributes.end(); it++) {
if (&*it == attr) {
modified = true;
attributes.erase(it);
return;
}
@@ -671,12 +674,14 @@ void AttributeSet::update(AttributeSet &&new_attributes)
for (it = attributes.begin(); it != attributes.end();) {
if (it->std != ATTR_STD_NONE) {
if (new_attributes.find(it->std) == nullptr) {
modified = true;
attributes.erase(it++);
continue;
}
}
else if (it->name != "") {
if (new_attributes.find(it->name) == nullptr) {
modified = true;
attributes.erase(it++);
continue;
}
@@ -691,6 +696,7 @@ void AttributeSet::clear_modified()
foreach (Attribute &attr, attributes) {
attr.modified = false;
}
modified = false;
}
/* AttributeRequest */