Support instancing for other objects: curves and volumes #74

Merged
Bogdan Nagirniak merged 4 commits from BLEN-449 into hydra-render 2023-07-26 10:27:51 +02:00
3 changed files with 9 additions and 11 deletions
Showing only changes of commit 7ebf19ade1 - Show all commits

View File

@ -53,7 +53,7 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetTransform(pxr::SdfPath const &id)
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
InstancerData *i_data = instancer_data(id, true);
if (i_data) {
return i_data->get_transform(id);
return i_data->transform(id);
}
ObjectData *obj_data = object_data(id);
if (obj_data) {
@ -161,11 +161,9 @@ pxr::HdCullStyle BlenderSceneDelegate::GetCullStyle(pxr::SdfPath const &id)
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
{
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", prim_id.GetText());
if (mesh_data(prim_id)) {
InstancerData *i_data = instancer_data(prim_id, true);
if (i_data) {
return i_data->prim_id;
}
InstancerData *i_data = instancer_data(prim_id, true);
if (i_data && mesh_data(prim_id)) {
return i_data->prim_id;
}
return pxr::SdfPath();
}
@ -189,7 +187,7 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetInstancerTransform(pxr::SdfPath const &
{
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText());
InstancerData *i_data = instancer_data(instancer_id);
return i_data->get_transform(instancer_id);
return i_data->transform(instancer_id);
}
pxr::HdVolumeFieldDescriptorVector BlenderSceneDelegate::GetVolumeFieldDescriptors(

View File

@ -49,7 +49,7 @@ pxr::VtValue InstancerData::get_data(pxr::TfToken const &key) const
return pxr::VtValue();
}
pxr::GfMatrix4d InstancerData::get_transform(pxr::SdfPath const &id) const
pxr::GfMatrix4d InstancerData::transform(pxr::SdfPath const &id) const
{
NonmeshInstance *nm_inst = nonmesh_instance(id);
if (nm_inst) {
@ -207,14 +207,14 @@ pxr::SdfPath InstancerData::object_prim_id(Object *object) const
pxr::SdfPath InstancerData::nonmesh_prim_id(pxr::SdfPath const &prim_id, int index) const
{
char name[16];
snprintf(name, sizeof(name), "L_%08x", index);
snprintf(name, sizeof(name), "NM_%08x", index);
return prim_id.AppendElementString(name);
}
int InstancerData::nonmesh_prim_id_index(pxr::SdfPath const &id) const
{
int index;
sscanf(id.GetName().c_str(), "L_%x", &index);
sscanf(id.GetName().c_str(), "NM_%x", &index);
return index;
}

View File

@ -32,7 +32,7 @@ class InstancerData : public IdData {
void update() override;
pxr::VtValue get_data(pxr::TfToken const &key) const override;
pxr::GfMatrix4d get_transform(pxr::SdfPath const &id) const;
pxr::GfMatrix4d transform(pxr::SdfPath const &id) const;
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
pxr::VtIntArray indices(pxr::SdfPath const &id) const;
ObjectData *object_data(pxr::SdfPath const &id) const;