BLEN-359: Implement updates for instances in viewport #20

Merged
Bogdan Nagirniak merged 20 commits from BLEN-359_1 into hydra-render 2023-04-05 11:47:37 +02:00
8 changed files with 5 additions and 27 deletions
Showing only changes of commit a9a0e405a2 - Show all commits

View File

@ -114,17 +114,6 @@ pxr::GfMatrix4d BlenderSceneDelegate::get_instancer_transform(pxr::SdfPath const
return pxr::GfMatrix4d(1.0); return pxr::GfMatrix4d(1.0);
} }
size_t BlenderSceneDelegate::SampleInstancerTransform(pxr::SdfPath const &instancer_id,
size_t max_sample_count,
float *sample_times,
pxr::GfMatrix4d *sample_values)
{
size_t ret = 0;
MeshData *m_data = mesh_data(instancer_id.GetParentPath());
ret = m_data->sample_instancer_transform(max_sample_count, sample_times, sample_values);
return ret;
}
size_t BlenderSceneDelegate::SamplePrimvar(pxr::SdfPath const &id, size_t BlenderSceneDelegate::SamplePrimvar(pxr::SdfPath const &id,
pxr::TfToken const &key, pxr::TfToken const &key,
size_t max_sample_count, size_t max_sample_count,

View File

@ -45,10 +45,6 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id, pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id,
pxr::SdfPath const &prototype_id) override; pxr::SdfPath const &prototype_id) override;
pxr::GfMatrix4d get_instancer_transform(pxr::SdfPath const &instancer_id); pxr::GfMatrix4d get_instancer_transform(pxr::SdfPath const &instancer_id);
size_t SampleInstancerTransform(pxr::SdfPath const &instancer_id,
size_t max_sample_count,
float *sample_times,
pxr::GfMatrix4d *sample_values) override;
size_t SamplePrimvar(pxr::SdfPath const &id, size_t SamplePrimvar(pxr::SdfPath const &id,
pxr::TfToken const &key, pxr::TfToken const &key,
size_t max_sample_count, size_t max_sample_count,

View File

@ -31,6 +31,7 @@ class IdData {
protected: protected:
BlenderSceneDelegate *scene_delegate; BlenderSceneDelegate *scene_delegate;
ID *id; ID *id;
pxr::SdfPath p_id;
}; };
template<class T> const T IdData::get_data(pxr::TfToken const &key) template<class T> const T IdData::get_data(pxr::TfToken const &key)

View File

@ -135,14 +135,12 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key)
void LightData::insert_prim() void LightData::insert_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate, (Object *)id);
scene_delegate->GetRenderIndex().InsertSprim(prim_type(), scene_delegate, p_id); scene_delegate->GetRenderIndex().InsertSprim(prim_type(), scene_delegate, p_id);
CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str()); CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str());
} }
void LightData::remove_prim() void LightData::remove_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate, (Object *)id);
scene_delegate->GetRenderIndex().RemoveSprim(prim_type(), p_id); scene_delegate->GetRenderIndex().RemoveSprim(prim_type(), p_id);
CLOG_INFO(LOG_BSD, 2, "Remove: %s", name().c_str()); CLOG_INFO(LOG_BSD, 2, "Remove: %s", name().c_str());
} }
@ -165,7 +163,6 @@ void LightData::mark_prim_dirty(DirtyBits dirty_bits)
default: default:
break; break;
} }
pxr::SdfPath p_id = prim_id(scene_delegate, (Object *)id);
scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits); scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits);
CLOG_INFO(LOG_BSD, 2, "Update: [%d] %s", dirty_bits, name().c_str()); CLOG_INFO(LOG_BSD, 2, "Update: [%d] %s", dirty_bits, name().c_str());
} }

View File

@ -38,6 +38,7 @@ pxr::SdfPath MaterialData::prim_id(BlenderSceneDelegate *scene_delegate, Materia
MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate, Material *material) MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate, Material *material)
: IdData(scene_delegate, (ID *)material) : IdData(scene_delegate, (ID *)material)
{ {
p_id = prim_id(scene_delegate, material);
} }
pxr::VtValue MaterialData::get_data(pxr::TfToken const &key) pxr::VtValue MaterialData::get_data(pxr::TfToken const &key)
@ -110,7 +111,6 @@ void MaterialData::export_mtlx()
void MaterialData::insert_prim() void MaterialData::insert_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate, (Material *)id);
scene_delegate->GetRenderIndex().InsertSprim( scene_delegate->GetRenderIndex().InsertSprim(
pxr::HdPrimTypeTokens->material, scene_delegate, p_id); pxr::HdPrimTypeTokens->material, scene_delegate, p_id);
CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str()); CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str());
@ -118,7 +118,6 @@ void MaterialData::insert_prim()
void MaterialData::remove_prim() void MaterialData::remove_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate, (Material *)id);
scene_delegate->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->material, p_id); scene_delegate->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->material, p_id);
CLOG_INFO(LOG_BSD, 2, "Remove: %s", name().c_str()); CLOG_INFO(LOG_BSD, 2, "Remove: %s", name().c_str());
} }
@ -133,7 +132,6 @@ void MaterialData::mark_prim_dirty(DirtyBits dirty_bits)
default: default:
break; break;
} }
pxr::SdfPath p_id = prim_id(scene_delegate, (Material *)id);
scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits); scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits);
CLOG_INFO(LOG_BSD, 2, "Update: %s, mtlx=%s", name().c_str(), mtlx_path.GetResolvedPath().c_str()); CLOG_INFO(LOG_BSD, 2, "Update: %s, mtlx=%s", name().c_str(), mtlx_path.GetResolvedPath().c_str());
} }

View File

@ -206,14 +206,12 @@ void MeshData::insert_prim()
return; return;
} }
pxr::SdfPath p_id = prim_id(scene_delegate, (Object *)id);
scene_delegate->GetRenderIndex().InsertRprim(pxr::HdPrimTypeTokens->mesh, scene_delegate, p_id); scene_delegate->GetRenderIndex().InsertRprim(pxr::HdPrimTypeTokens->mesh, scene_delegate, p_id);
CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str()); CLOG_INFO(LOG_BSD, 2, "Add: %s id=%s", name().c_str(), p_id.GetString().c_str());
} }
void MeshData::remove_prim() void MeshData::remove_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate, (Object *)id);
if (!scene_delegate->GetRenderIndex().HasRprim(p_id)) { if (!scene_delegate->GetRenderIndex().HasRprim(p_id)) {
return; return;
} }
@ -224,7 +222,6 @@ void MeshData::remove_prim()
void MeshData::mark_prim_dirty(DirtyBits dirty_bits) void MeshData::mark_prim_dirty(DirtyBits dirty_bits)
{ {
pxr::SdfPath p_id = prim_id(scene_delegate, (Object *)id);
if (!scene_delegate->GetRenderIndex().HasRprim(p_id)) { if (!scene_delegate->GetRenderIndex().HasRprim(p_id)) {
/* Trying to insert prim */ /* Trying to insert prim */
insert_prim(); insert_prim();

View File

@ -60,6 +60,7 @@ pxr::SdfPath ObjectData::prim_id(BlenderSceneDelegate *scene_delegate, Object *o
ObjectData::ObjectData(BlenderSceneDelegate *scene_delegate, Object *object) ObjectData::ObjectData(BlenderSceneDelegate *scene_delegate, Object *object)
: IdData(scene_delegate, (ID *)object), visible(true) : IdData(scene_delegate, (ID *)object), visible(true)
{ {
p_id = prim_id(scene_delegate, object);
} }
int ObjectData::type() int ObjectData::type()

View File

@ -43,6 +43,8 @@ pxr::SdfPath WorldData::prim_id(BlenderSceneDelegate *scene_delegate)
WorldData::WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContext *context) WorldData::WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContext *context)
: IdData(scene_delegate, (ID *)world) : IdData(scene_delegate, (ID *)world)
{ {
p_id = prim_id(scene_delegate);
data[pxr::UsdLuxTokens->orientToStageUpAxis] = true; data[pxr::UsdLuxTokens->orientToStageUpAxis] = true;
if (world->use_nodes) { if (world->use_nodes) {
@ -125,7 +127,6 @@ pxr::VtValue WorldData::get_data(pxr::TfToken const &key)
void WorldData::insert_prim() void WorldData::insert_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate);
scene_delegate->GetRenderIndex().InsertSprim( scene_delegate->GetRenderIndex().InsertSprim(
pxr::HdPrimTypeTokens->domeLight, scene_delegate, p_id); pxr::HdPrimTypeTokens->domeLight, scene_delegate, p_id);
CLOG_INFO(LOG_BSD, 2, "Add: id=%s", p_id.GetText()); CLOG_INFO(LOG_BSD, 2, "Add: id=%s", p_id.GetText());
@ -133,7 +134,6 @@ void WorldData::insert_prim()
void WorldData::remove_prim() void WorldData::remove_prim()
{ {
pxr::SdfPath p_id = prim_id(scene_delegate);
scene_delegate->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->domeLight, p_id); scene_delegate->GetRenderIndex().RemoveSprim(pxr::HdPrimTypeTokens->domeLight, p_id);
CLOG_INFO(LOG_BSD, 2, "Remove"); CLOG_INFO(LOG_BSD, 2, "Remove");
} }
@ -148,7 +148,6 @@ void WorldData::mark_prim_dirty(DirtyBits dirty_bits)
default: default:
break; break;
} }
pxr::SdfPath p_id = prim_id(scene_delegate);
scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits); scene_delegate->GetRenderIndex().GetChangeTracker().MarkSprimDirty(p_id, bits);
CLOG_INFO(LOG_BSD, 2, "Update"); CLOG_INFO(LOG_BSD, 2, "Update");
} }