Support several instancers on one object #24

Merged
Bogdan Nagirniak merged 16 commits from BLEN-383 into hydra-render 2023-04-19 02:46:24 +02:00
3 changed files with 13 additions and 6 deletions
Showing only changes of commit a5d7819d03 - Show all commits

View File

@ -88,8 +88,11 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
{ {
if (visibility) { if (visibility) {
/* Check and update visibility */ /* Check and update visibility */
for (auto &obj : objects) { for (auto &it : objects) {
obj.second->update_visibility(view3d); it.second->update_visibility(view3d);
}
for (auto &it : instancers) {
it.second->update_visibility(view3d);
} }
} }

View File

@ -71,6 +71,11 @@ bool InstancerData::update_visibility(View3D *view3d)
if (ret) { if (ret) {
scene_delegate->GetRenderIndex().GetChangeTracker().MarkInstancerDirty( scene_delegate->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
p_id, pxr::HdChangeTracker::DirtyVisibility); p_id, pxr::HdChangeTracker::DirtyVisibility);
for (auto &it : instances) {
it.second.obj_data->visible = visible;
scene_delegate->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
it.second.obj_data->p_id, pxr::HdChangeTracker::DirtyVisibility);
}
} }
return ret; return ret;
} }
@ -135,10 +140,9 @@ void InstancerData::check_update(Object *object)
} }
} }
void InstancerData::check_remove(Object *object) void InstancerData::check_remove(pxr::SdfPath const &obj_id)
{ {
pxr::SdfPath path = ObjectData::prim_id(scene_delegate, object); pxr::SdfPath path = p_id.AppendElementString(obj_id.GetName());
path = p_id.AppendElementString(path.GetName());
auto it = instances.find(path); auto it = instances.find(path);
if (it == instances.end()) { if (it == instances.end()) {
return; return;

View File

@ -36,7 +36,7 @@ class InstancerData : public ObjectData {
ObjectData *object_data(pxr::SdfPath const &id); ObjectData *object_data(pxr::SdfPath const &id);
pxr::SdfPathVector prototypes(); pxr::SdfPathVector prototypes();
void check_update(Object *object); void check_update(Object *object);
void check_remove(Object *object); void check_remove(pxr::SdfPath const &obj_id);
private: private:
void set_instances(); void set_instances();