From 7f3048913e8de00d2c737b7b2fc305da95ca9dbd Mon Sep 17 00:00:00 2001 From: Vasyl-Pidhirskyi Date: Fri, 5 May 2023 14:34:49 +0300 Subject: [PATCH 1/2] Fix rendering of Car Demo scene --- .../scene_delegate/blender_scene_delegate.cc | 21 +++++++------------ .../render/hydra/scene_delegate/instancer.cc | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index 840a996fe3bf..a8e9d3b7098d 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -434,11 +434,9 @@ void BlenderSceneDelegate::add_new_objects() Object *, object) { - if (!ObjectData::is_supported(object)) { - continue; + if (ObjectData::is_supported(object)) { + update_objects(object); } - - update_objects(object); update_instancers(object); } ITER_END; @@ -462,10 +460,9 @@ void BlenderSceneDelegate::remove_unused_objects() &data, Object *, object) { - if (!ObjectData::is_supported(object)) { - continue; + if (ObjectData::is_supported(object)) { + available_objects.insert(object_prim_id(object).GetName()); } - available_objects.insert(object_prim_id(object).GetName()); available_objects.insert(instancer_prim_id(object).GetName()); } ITER_END; @@ -542,12 +539,10 @@ void BlenderSceneDelegate::update_visibility() Object *, object) { - if (!ObjectData::is_supported(object)) { - continue; - } - - if (!object_data(object_prim_id(object))) { - update_objects(object); + if (ObjectData::is_supported(object)) { + if (!object_data(object_prim_id(object))) { + update_objects(object); + } } if (!instancer_data(instancer_prim_id(object))) { update_instancers(object); diff --git a/source/blender/render/hydra/scene_delegate/instancer.cc b/source/blender/render/hydra/scene_delegate/instancer.cc index 50bc558c20fb..1746d070c8af 100644 --- a/source/blender/render/hydra/scene_delegate/instancer.cc +++ b/source/blender/render/hydra/scene_delegate/instancer.cc @@ -64,7 +64,7 @@ void InstancerData::update() ID_LOG(2, ""); Object *object = (Object *)id; - if (id->recalc & ID_RECALC_GEOMETRY || ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY || + if (id->recalc & ID_RECALC_GEOMETRY || (object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) || id->recalc & ID_RECALC_TRANSFORM) { set_instances(); scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty( -- 2.30.2 From 9c1c286b261bc1571a2b0fb947318cdb213a2464 Mon Sep 17 00:00:00 2001 From: Vasyl-Pidhirskyi Date: Fri, 5 May 2023 16:07:37 +0300 Subject: [PATCH 2/2] Removed redundant code. Formatted code --- .../hydra/scene_delegate/blender_scene_delegate.cc | 10 +++------- .../blender/render/hydra/scene_delegate/instancer.cc | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index a8e9d3b7098d..375ffb43ecc3 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -434,9 +434,7 @@ void BlenderSceneDelegate::add_new_objects() Object *, object) { - if (ObjectData::is_supported(object)) { - update_objects(object); - } + update_objects(object); update_instancers(object); } ITER_END; @@ -539,10 +537,8 @@ void BlenderSceneDelegate::update_visibility() Object *, object) { - if (ObjectData::is_supported(object)) { - if (!object_data(object_prim_id(object))) { - update_objects(object); - } + if (!object_data(object_prim_id(object))) { + update_objects(object); } if (!instancer_data(instancer_prim_id(object))) { update_instancers(object); diff --git a/source/blender/render/hydra/scene_delegate/instancer.cc b/source/blender/render/hydra/scene_delegate/instancer.cc index 1746d070c8af..9ed24aa6f6f0 100644 --- a/source/blender/render/hydra/scene_delegate/instancer.cc +++ b/source/blender/render/hydra/scene_delegate/instancer.cc @@ -64,7 +64,8 @@ void InstancerData::update() ID_LOG(2, ""); Object *object = (Object *)id; - if (id->recalc & ID_RECALC_GEOMETRY || (object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) || + if (id->recalc & ID_RECALC_GEOMETRY || + (object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) || id->recalc & ID_RECALC_TRANSFORM) { set_instances(); scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty( -- 2.30.2