BLEN-359: Implement updates for instances in viewport #20

Merged
Bogdan Nagirniak merged 20 commits from BLEN-359_1 into hydra-render 2023-04-05 11:47:37 +02:00
Showing only changes of commit 60d68d8bd7 - Show all commits

View File

@ -121,6 +121,9 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
id = ObjectData::prim_id(this, object);
if (remove) {
available_objects.insert(id);
if ((object->transflag & OB_DUPLI) && InstancerData::supported(object)) {
available_objects.insert(InstancerData::prim_id(this, object));
}
}
if (!object_data(id)) {
@ -261,7 +264,6 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
/* Export initial objects */
update_collection(false, false);
update_world();
GetRenderIndex().InsertInstancer(this, GetDelegateID().AppendElementString("Instancer"));
return;
}
@ -270,14 +272,37 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
bool do_update_visibility = false;
bool do_update_world = false;
unsigned int scene_recalc = ((ID *)scene)->recalc;
if (scene_recalc) {
/* Checking scene updates */
CLOG_INFO(LOG_BSD, 2, "Update: %s [%s]", ((ID *)scene)->name,
std::bitset<32>(scene_recalc).to_string().c_str());
if (scene_recalc & ID_RECALC_BASE_FLAGS) {
do_update_visibility = true;
}
if (scene_recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY)) {
do_update_collection = true;
}
if (scene_recalc & ID_RECALC_AUDIO_VOLUME) {
if ((scene->world && !world_data) || (!scene->world && world_data)) {
do_update_world = true;
}
}
if (do_update_collection || do_update_visibility) {
update_collection(do_update_collection, do_update_visibility);
}
}
/* Checking other objects updates */
DEGIDIterData data = {0};
data.graph = depsgraph;
data.only_updated = true;
ITER_BEGIN (
DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) {
CLOG_INFO(
LOG_BSD, 2, "Update: %s [%s]", id->name, std::bitset<32>(id->recalc).to_string().c_str());
CLOG_INFO(LOG_BSD, 2, "Update: %s [%s]", id->name,
std::bitset<32>(id->recalc).to_string().c_str());
switch (GS(id->name)) {
case ID_OB: {
@ -295,27 +320,6 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
}
} break;
// case ID_GR:
// if (id->recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY)) {
// do_update_collection = true;
// }
// break;
case ID_SCE: {
if (id->recalc & ID_RECALC_BASE_FLAGS) {
do_update_visibility = true;
}
if (id->recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY)) {
do_update_collection = true;
}
if (id->recalc & ID_RECALC_AUDIO_VOLUME) {
Scene *scene = (Scene *)id;
if ((scene->world && !world_data) || (!scene->world && world_data)) {
do_update_world = true;
}
}
} break;
case ID_WO: {
if (id->recalc & ID_RECALC_SHADING) {
do_update_world = true;
@ -328,9 +332,6 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
}
ITER_END;
if (do_update_collection || do_update_visibility) {
update_collection(do_update_collection, do_update_visibility);
}
if (do_update_world) {
update_world();
}