diff options
author | Jacques Lucke <jacques@blender.org> | 2021-02-17 14:04:45 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-02-17 14:06:10 +0300 |
commit | 9419452f859117aa17dda7d89810c83bbdcda288 (patch) | |
tree | aa7857846df27a0335446fe078c76b47287390d5 /intern | |
parent | 17dddc94171497c616eea8bcf47215ae118dd162 (diff) |
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.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/render/attribute.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/attribute.h | 1 | ||||
-rw-r--r-- | intern/cycles/render/geometry.cpp | 12 |
3 files changed, 19 insertions, 0 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index ce4ae6e4295..331d30802f1 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -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 */ diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h index f9997d3c422..c1be62addc0 100644 --- a/intern/cycles/render/attribute.h +++ b/intern/cycles/render/attribute.h @@ -179,6 +179,7 @@ class AttributeSet { Geometry *geometry; AttributePrimitive prim; list<Attribute> attributes; + bool modified = true; AttributeSet(Geometry *geometry, AttributePrimitive prim); AttributeSet(AttributeSet &&) = default; diff --git a/intern/cycles/render/geometry.cpp b/intern/cycles/render/geometry.cpp index f79b1689c14..575042360aa 100644 --- a/intern/cycles/render/geometry.cpp +++ b/intern/cycles/render/geometry.cpp @@ -1440,6 +1440,18 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro foreach (Geometry *geom, scene->geometry) { geom->has_volume = false; + if (geom->attributes.modified) { + device_update_flags |= ATTRS_NEED_REALLOC; + } + + if (geom->is_mesh()) { + Mesh *mesh = static_cast<Mesh *>(geom); + + if (mesh->subd_attributes.modified) { + device_update_flags |= ATTRS_NEED_REALLOC; + } + } + foreach (Node *node, geom->get_used_shaders()) { Shader *shader = static_cast<Shader *>(node); if (shader->has_volume) { |