Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/scene/attribute.cpp
| Show First 20 Lines • Show All 655 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| foreach (const Attribute &attr, attributes) | foreach (const Attribute &attr, attributes) | ||||
| if (attr.std == std) | if (attr.std == std) | ||||
| return (Attribute *)&attr; | return (Attribute *)&attr; | ||||
| return NULL; | 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) | void AttributeSet::remove(AttributeStandard std) | ||||
| { | { | ||||
| Attribute *attr = find(std); | Attribute *attr = find(std); | ||||
| if (attr) { | if (attr) { | ||||
| list<Attribute>::iterator it; | list<Attribute>::iterator it; | ||||
| for (it = attributes.begin(); it != attributes.end(); it++) { | for (it = attributes.begin(); it != attributes.end(); it++) { | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void AttributeSet::clear(bool preserve_voxel_data) | ||||
| } | } | ||||
| else { | else { | ||||
| attributes.clear(); | attributes.clear(); | ||||
| } | } | ||||
| } | } | ||||
| void AttributeSet::update(AttributeSet &&new_attributes) | void AttributeSet::update(AttributeSet &&new_attributes) | ||||
| { | { | ||||
| /* add or update old_attributes based on the new_attributes */ | /* Remove any attributes not on 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 */ | |||||
| list<Attribute>::iterator it; | list<Attribute>::iterator it; | ||||
| for (it = attributes.begin(); it != attributes.end();) { | for (it = attributes.begin(); it != attributes.end();) { | ||||
| if (it->std != ATTR_STD_NONE) { | const Attribute &old_attr = *it; | ||||
| if (new_attributes.find(it->std) == nullptr) { | if (new_attributes.find_matching(old_attr) == nullptr) { | ||||
| remove(it++); | |||||
| continue; | |||||
| } | |||||
| } | |||||
| else if (it->name != "") { | |||||
| if (new_attributes.find(it->name) == nullptr) { | |||||
| remove(it++); | remove(it++); | ||||
| continue; | continue; | ||||
| } | } | ||||
| it++; | |||||
| } | } | ||||
| 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. */ | /* If all attributes were replaced, transform is no longer applied. */ | ||||
| geometry->transform_applied = false; | geometry->transform_applied = false; | ||||
| } | } | ||||
| void AttributeSet::clear_modified() | void AttributeSet::clear_modified() | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines | |||||