Cleanup: minor refactoring in Cycles update detection code

This commit is contained in:
Brecht Van Lommel 2020-07-09 18:54:42 +02:00
parent ad45b8d6a4
commit e65c78cd43
Notes: blender-bot 2023-02-14 05:28:01 +01:00
Referenced by commit 9c7fda6de3, Fix T81729: Cycles object color not updating for instancers
Referenced by issue #81729, Object Color change doesn't update the rendering in 2.90+ for instanced collections (both linked and local)
3 changed files with 36 additions and 23 deletions

View File

@ -59,7 +59,7 @@ bool BlenderSync::BKE_object_is_modified(BL::Object &b_ob)
return false;
}
bool BlenderSync::object_is_mesh(BL::Object &b_ob)
bool BlenderSync::object_is_geometry(BL::Object &b_ob)
{
BL::ID b_ob_data = b_ob.data();
@ -143,7 +143,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
}
/* only interested in object that we can create meshes from */
if (!object_is_mesh(b_ob)) {
if (!object_is_geometry(b_ob)) {
return NULL;
}

View File

@ -147,30 +147,43 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
/* Object */
else if (b_id.is_a(&RNA_Object)) {
BL::Object b_ob(b_id);
const bool updated_geometry = b_update->is_updated_geometry();
const bool is_geometry = object_is_geometry(b_ob);
const bool is_light = !is_geometry && object_is_light(b_ob);
if (b_update->is_updated_transform() || b_update->is_updated_shading()) {
object_map.set_recalc(b_ob);
light_map.set_recalc(b_ob);
}
if (is_geometry || is_light) {
const bool updated_geometry = b_update->is_updated_geometry();
if (object_is_mesh(b_ob)) {
if (updated_geometry ||
(object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
geometry_map.set_recalc(key);
/* Geometry (mesh, hair, volume). */
if (is_geometry) {
if (b_update->is_updated_transform() || b_update->is_updated_shading()) {
object_map.set_recalc(b_ob);
}
if (updated_geometry ||
(object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
geometry_map.set_recalc(key);
}
if (updated_geometry) {
BL::Object::particle_systems_iterator b_psys;
for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end();
++b_psys) {
particle_system_map.set_recalc(b_ob);
}
}
}
}
else if (object_is_light(b_ob)) {
if (updated_geometry) {
light_map.set_recalc(b_ob);
}
}
/* Light */
else if (is_light) {
if (b_update->is_updated_transform() || b_update->is_updated_shading()) {
object_map.set_recalc(b_ob);
light_map.set_recalc(b_ob);
}
if (updated_geometry) {
BL::Object::particle_systems_iterator b_psys;
for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys)
particle_system_map.set_recalc(b_ob);
if (updated_geometry) {
light_map.set_recalc(b_ob);
}
}
}
}
/* Mesh */

View File

@ -208,7 +208,7 @@ class BlenderSync {
/* util */
void find_shader(BL::ID &id, vector<Shader *> &used_shaders, Shader *default_shader);
bool BKE_object_is_modified(BL::Object &b_ob);
bool object_is_mesh(BL::Object &b_ob);
bool object_is_geometry(BL::Object &b_ob);
bool object_is_light(BL::Object &b_ob);
/* variables */