forked from blender/blender
Fix visibility of instancer object #43
@ -188,8 +188,18 @@ pxr::SdfPathVector InstancerData::prototypes() const
|
||||
void InstancerData::check_update(Object *object)
|
||||
{
|
||||
pxr::SdfPath path = object_prim_id(object);
|
||||
|
||||
/* Checking object in existing mesh_instances_ */
|
||||
auto m_it = mesh_instances_.find(path);
|
||||
if (m_it != mesh_instances_.end()) {
|
||||
if (!is_instance_visible(object)) {
|
||||
m_it->second.data->remove();
|
||||
mesh_instances_.erase(m_it);
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
|
||||
prim_id, pxr::HdChangeTracker::AllDirty);
|
||||
return;
|
||||
}
|
||||
|
||||
m_it->second.data->update();
|
||||
|
||||
if (m_it->second.data->id->recalc & ID_RECALC_TRANSFORM) {
|
||||
@ -200,8 +210,16 @@ void InstancerData::check_update(Object *object)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Checking object in existing light_instances_ */
|
||||
auto l_it = light_instances_.find(path);
|
||||
if (l_it != light_instances_.end()) {
|
||||
if (!is_instance_visible(object)) {
|
||||
l_it->second.transforms.clear();
|
||||
update_light_instance(l_it->second);
|
||||
light_instances_.erase(l_it);
|
||||
return;
|
||||
}
|
||||
|
||||
Object *obj = (Object *)l_it->second.data->id;
|
||||
if (obj->id.recalc & (ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY) ||
|
||||
((ID *)obj->data)->recalc & ID_RECALC_GEOMETRY)
|
||||
@ -210,6 +228,28 @@ void InstancerData::check_update(Object *object)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Checking if object wasn't added to instances before */
|
||||
if (is_supported(object) && is_instance_visible(object)) {
|
||||
bool do_set_instances = false;
|
||||
ListBase *lb = object_duplilist(
|
||||
scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
|
||||
LISTBASE_FOREACH (DupliObject *, dupli, lb) {
|
||||
if (dupli->ob == object) {
|
||||
do_set_instances = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free_object_duplilist(lb);
|
||||
|
||||
if (do_set_instances) {
|
||||
set_instances();
|
||||
if (!mesh_instances_.empty()) {
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
|
||||
prim_id, pxr::HdChangeTracker::AllDirty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InstancerData::check_remove(std::set<std::string> &available_objects)
|
||||
@ -315,10 +355,7 @@ void InstancerData::set_instances()
|
||||
scene_delegate_->depsgraph, scene_delegate_->scene, (Object *)id);
|
||||
LISTBASE_FOREACH (DupliObject *, dupli, lb) {
|
||||
Object *ob = dupli->ob;
|
||||
if (!is_supported(ob)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_instance_visible(ob)) {
|
||||
if (!is_supported(ob) || !is_instance_visible(ob)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user