forked from blender/blender
Support several instancers on one object #24
@ -170,10 +170,9 @@ void BlenderSceneDelegate::add_update_object(Object *object)
|
|||||||
if ((object->transflag & OB_DUPLI) && InstancerData::supported(object)) {
|
if ((object->transflag & OB_DUPLI) && InstancerData::supported(object)) {
|
||||||
add_update_instancer(object);
|
add_update_instancer(object);
|
||||||
}
|
}
|
||||||
//InstancerData *i_data = instancer_data(object);
|
for (auto &it : instancers) {
|
||||||
//if (i_data) {
|
it.second->check_update(object);
|
||||||
// i_data->update();
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
pxr::SdfPath id = ObjectData::prim_id(this, object);
|
pxr::SdfPath id = ObjectData::prim_id(this, object);
|
||||||
ObjectData *obj_data = object_data(id);
|
ObjectData *obj_data = object_data(id);
|
||||||
|
@ -114,7 +114,7 @@ pxr::SdfPathVector InstancerData::prototypes()
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstancerData::update(Object *object)
|
void InstancerData::check_update(Object *object)
|
||||||
{
|
{
|
||||||
pxr::SdfPath path = ObjectData::prim_id(scene_delegate, object);
|
pxr::SdfPath path = ObjectData::prim_id(scene_delegate, object);
|
||||||
path = p_id.AppendElementString(path.GetName());
|
path = p_id.AppendElementString(path.GetName());
|
||||||
@ -124,6 +124,28 @@ void InstancerData::update(Object *object)
|
|||||||
}
|
}
|
||||||
ObjectData *obj_data = it->second.obj_data.get();
|
ObjectData *obj_data = it->second.obj_data.get();
|
||||||
obj_data->update();
|
obj_data->update();
|
||||||
|
|
||||||
|
pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean;
|
||||||
|
if (object->id.recalc & ID_RECALC_TRANSFORM) {
|
||||||
|
set_instances();
|
||||||
|
bits |= pxr::HdChangeTracker::DirtyTransform;
|
||||||
|
}
|
||||||
|
if (bits != pxr::HdChangeTracker::Clean) {
|
||||||
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(p_id, bits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstancerData::check_remove(Object *object)
|
||||||
|
{
|
||||||
|
pxr::SdfPath path = ObjectData::prim_id(scene_delegate, object);
|
||||||
|
path = p_id.AppendElementString(path.GetName());
|
||||||
|
auto it = instances.find(path);
|
||||||
|
if (it == instances.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
set_instances();
|
||||||
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(
|
||||||
|
p_id, pxr::HdChangeTracker::AllDirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstancerData::set_instances()
|
void InstancerData::set_instances()
|
||||||
@ -197,7 +219,7 @@ void InstancerData::update()
|
|||||||
|
|
||||||
Object *object = (Object *)id;
|
Object *object = (Object *)id;
|
||||||
if ((id->recalc & ID_RECALC_GEOMETRY) || (((ID *)object->data)->recalc & ID_RECALC_GEOMETRY)) {
|
if ((id->recalc & ID_RECALC_GEOMETRY) || (((ID *)object->data)->recalc & ID_RECALC_GEOMETRY)) {
|
||||||
init();
|
set_instances();
|
||||||
bits |= pxr::HdChangeTracker::AllDirty;
|
bits |= pxr::HdChangeTracker::AllDirty;
|
||||||
}
|
}
|
||||||
else if (id->recalc & ID_RECALC_TRANSFORM) {
|
else if (id->recalc & ID_RECALC_TRANSFORM) {
|
||||||
|
@ -35,7 +35,8 @@ class InstancerData : public ObjectData {
|
|||||||
pxr::VtIntArray indices(pxr::SdfPath const &id);
|
pxr::VtIntArray indices(pxr::SdfPath const &id);
|
||||||
ObjectData *object_data(pxr::SdfPath const &id);
|
ObjectData *object_data(pxr::SdfPath const &id);
|
||||||
pxr::SdfPathVector prototypes();
|
pxr::SdfPathVector prototypes();
|
||||||
void update(Object *object);
|
void check_update(Object *object);
|
||||||
|
void check_remove(Object *object);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_instances();
|
void set_instances();
|
||||||
|
Loading…
Reference in New Issue
Block a user