Fix visibility of instancer object #43

Merged
Bogdan Nagirniak merged 16 commits from BLEN-405_1 into hydra-render 2023-05-24 13:44:35 +02:00
4 changed files with 19 additions and 16 deletions
Showing only changes of commit 14e0207e5e - Show all commits

View File

@ -370,8 +370,8 @@ void BlenderSceneDelegate::check_updates()
DEGIDIterData data = {0}; DEGIDIterData data = {0};
data.graph = depsgraph; data.graph = depsgraph;
data.only_updated = true; data.only_updated = true;
ITER_BEGIN ( ITER_BEGIN (DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id)
DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id) { {
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
2, 2,
@ -438,8 +438,7 @@ void BlenderSceneDelegate::add_new_objects()
{ {
DEGObjectIterSettings settings = {0}; DEGObjectIterSettings settings = {0};
settings.depsgraph = depsgraph; settings.depsgraph = depsgraph;
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
DEGObjectIterData data = {0}; DEGObjectIterData data = {0};
data.settings = &settings; data.settings = &settings;
data.graph = settings.depsgraph; data.graph = settings.depsgraph;
@ -449,7 +448,8 @@ void BlenderSceneDelegate::add_new_objects()
DEG_iterator_objects_end, DEG_iterator_objects_end,
&data, &data,
Object *, Object *,
object) { object)
{
update_objects(object); update_objects(object);
update_instancers(object); update_instancers(object);
@ -474,7 +474,8 @@ void BlenderSceneDelegate::remove_unused_objects()
DEG_iterator_objects_end, DEG_iterator_objects_end,
&data, &data,
Object *, Object *,
object) { object)
{
if (ObjectData::is_supported(object)) { if (ObjectData::is_supported(object)) {
available_objects.insert(object_prim_id(object).GetName()); available_objects.insert(object_prim_id(object).GetName());
} }
@ -550,7 +551,8 @@ void BlenderSceneDelegate::update_visibility()
DEG_iterator_objects_end, DEG_iterator_objects_end,
&data, &data,
Object *, Object *,
object) { object)
{
if (!object_data(object_prim_id(object))) { if (!object_data(object_prim_id(object))) {
update_objects(object); update_objects(object);

View File

@ -43,16 +43,13 @@ bool InstancerData::is_visible(BlenderSceneDelegate *scene_delegate,
bool ret = true; bool ret = true;
eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph); eEvaluationMode deg_mode = DEG_get_mode(scene_delegate->depsgraph);
ret = BKE_object_visibility(object, deg_mode) & (OB_VISIBLE_SELF | OB_VISIBLE_INSTANCES); ret = BKE_object_visibility(object, deg_mode) & (OB_VISIBLE_SELF | OB_VISIBLE_INSTANCES);
if (ret && child_object && child_object->transflag & OB_DUPLI) if (ret && child_object && child_object->transflag & OB_DUPLI) {
{
int flag = deg_mode == DAG_EVAL_VIEWPORT ? OB_DUPLI_FLAG_VIEWPORT : OB_DUPLI_FLAG_RENDER; int flag = deg_mode == DAG_EVAL_VIEWPORT ? OB_DUPLI_FLAG_VIEWPORT : OB_DUPLI_FLAG_RENDER;
ret = child_object->duplicator_visibility_flag & flag; ret = child_object->duplicator_visibility_flag & flag;
} }
return ret; return ret;
} }
void InstancerData::init() void InstancerData::init()
{ {
ID_LOG(2, ""); ID_LOG(2, "");
@ -86,7 +83,8 @@ void InstancerData::update()
Object *object = (Object *)id; Object *object = (Object *)id;
if (id->recalc & ID_RECALC_GEOMETRY || if (id->recalc & ID_RECALC_GEOMETRY ||
(object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) || (object->data && ((ID *)object->data)->recalc & ID_RECALC_GEOMETRY) ||
id->recalc & ID_RECALC_TRANSFORM) { id->recalc & ID_RECALC_TRANSFORM)
{
set_instances(); set_instances();
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty( scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
prim_id, pxr::HdChangeTracker::AllDirty); prim_id, pxr::HdChangeTracker::AllDirty);
@ -197,7 +195,8 @@ void InstancerData::check_update(Object *object)
if (l_it != light_instances_.end()) { if (l_it != light_instances_.end()) {
Object *obj = (Object *)l_it->second.data->id; Object *obj = (Object *)l_it->second.data->id;
if (obj->id.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY) || if (obj->id.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY) ||
((ID *)obj->data)->recalc & ID_RECALC_GEOMETRY) { ((ID *)obj->data)->recalc & ID_RECALC_GEOMETRY)
{
set_instances(); set_instances();
} }
return; return;

View File

@ -27,7 +27,8 @@ void MeshData::init()
Object *object = (Object *)id; Object *object = (Object *)id;
if (object->type == OB_MESH && object->mode == OB_MODE_OBJECT && if (object->type == OB_MESH && object->mode == OB_MODE_OBJECT &&
BLI_listbase_is_empty(&object->modifiers)) { BLI_listbase_is_empty(&object->modifiers))
{
write_mesh((Mesh *)object->data); write_mesh((Mesh *)object->data);
} }
else { else {

View File

@ -60,7 +60,8 @@ bool ObjectData::is_supported(Object *object)
return false; return false;
} }
bool ObjectData::is_visible(BlenderSceneDelegate* scene_delegate, Object* object) { bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object)
{
bool ret = true; bool ret = true;
if (DEG_get_mode(scene_delegate->depsgraph) == DAG_EVAL_VIEWPORT) { if (DEG_get_mode(scene_delegate->depsgraph) == DAG_EVAL_VIEWPORT) {
@ -80,7 +81,7 @@ bool ObjectData::is_visible(BlenderSceneDelegate* scene_delegate, Object* object
} }
} }
return ret; return ret;
} }
bool ObjectData::update_visibility() bool ObjectData::update_visibility()
{ {