forked from blender/blender
BLEN-359: Implement updates for instances in viewport #20
@ -170,6 +170,11 @@ 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);
|
||||||
|
if (i_data) {
|
||||||
|
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);
|
||||||
if (obj_data) {
|
if (obj_data) {
|
||||||
@ -233,6 +238,18 @@ InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool
|
|||||||
return dynamic_cast<InstancerData *>(object_data(id.GetParentPath()));
|
return dynamic_cast<InstancerData *>(object_data(id.GetParentPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InstancerData *BlenderSceneDelegate::instancer_data(Object *object)
|
||||||
|
{
|
||||||
|
InstancerData *i_data;
|
||||||
|
for (auto &it : objects) {
|
||||||
|
i_data = dynamic_cast<InstancerData *>(it.second.get());
|
||||||
|
if (i_data && i_data->is_base(object)) {
|
||||||
|
return i_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||||
{
|
{
|
||||||
bool is_populated = depsgraph != nullptr;
|
bool is_populated = depsgraph != nullptr;
|
||||||
|
@ -58,6 +58,7 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
|||||||
LightData *light_data(pxr::SdfPath const &id);
|
LightData *light_data(pxr::SdfPath const &id);
|
||||||
MaterialData *material_data(pxr::SdfPath const &id);
|
MaterialData *material_data(pxr::SdfPath const &id);
|
||||||
InstancerData *instancer_data(pxr::SdfPath const &id, bool base_prim = false);
|
InstancerData *instancer_data(pxr::SdfPath const &id, bool base_prim = false);
|
||||||
|
InstancerData *instancer_data(Object *object);
|
||||||
|
|
||||||
void add_update_object(Object *object);
|
void add_update_object(Object *object);
|
||||||
void add_update_instancer(Object *object);
|
void add_update_instancer(Object *object);
|
||||||
|
@ -121,6 +121,11 @@ VtIntArray InstancerData::instance_indices()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InstancerData::is_base(Object *object) const
|
||||||
|
{
|
||||||
|
return (ID *)object == id;
|
||||||
|
}
|
||||||
|
|
||||||
void InstancerData::insert()
|
void InstancerData::insert()
|
||||||
{
|
{
|
||||||
CLOG_INFO(LOG_BSD, 2, "%s", ((ID *)parent_obj)->name);
|
CLOG_INFO(LOG_BSD, 2, "%s", ((ID *)parent_obj)->name);
|
||||||
@ -151,6 +156,14 @@ void InstancerData::update()
|
|||||||
pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean;
|
pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean;
|
||||||
unsigned int recalc = ((ID *)parent_obj)->recalc;
|
unsigned int recalc = ((ID *)parent_obj)->recalc;
|
||||||
|
|
||||||
|
Object *object = (Object *)id;
|
||||||
|
if ((id->recalc & ID_RECALC_GEOMETRY) || (((ID *)object->data)->recalc & ID_RECALC_GEOMETRY)) {
|
||||||
|
init();
|
||||||
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
|
||||||
|
p_id, pxr::HdChangeTracker::AllDirty);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((recalc & ID_RECALC_GEOMETRY) || (((ID *)parent_obj->data)->recalc & ID_RECALC_GEOMETRY)) {
|
if ((recalc & ID_RECALC_GEOMETRY) || (((ID *)parent_obj->data)->recalc & ID_RECALC_GEOMETRY)) {
|
||||||
init();
|
init();
|
||||||
bits = pxr::HdChangeTracker::AllDirty;
|
bits = pxr::HdChangeTracker::AllDirty;
|
||||||
@ -168,7 +181,6 @@ void InstancerData::update()
|
|||||||
if (bits != pxr::HdChangeTracker::Clean) {
|
if (bits != pxr::HdChangeTracker::Clean) {
|
||||||
scene_delegate->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(instancer_id, bits);
|
scene_delegate->GetRenderIndex().GetChangeTracker().MarkInstancerDirty(instancer_id, bits);
|
||||||
}
|
}
|
||||||
//scene_delegate->GetRenderIndex().GetChangeTracker().MarkRprimDirty(p_id, bits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -29,6 +29,7 @@ class InstancerData : public MeshData {
|
|||||||
pxr::HdPrimvarDescriptorVector instancer_primvar_descriptors(pxr::HdInterpolation interpolation);
|
pxr::HdPrimvarDescriptorVector instancer_primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||||
pxr::VtIntArray instance_indices();
|
pxr::VtIntArray instance_indices();
|
||||||
|
|
||||||
|
bool is_base(Object *object) const;
|
||||||
pxr::SdfPath instancer_id;
|
pxr::SdfPath instancer_id;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user