BLEN-299: Export instances #11

Merged
Bogdan Nagirniak merged 7 commits from BLEN-299 into hydra-render 2023-03-05 09:37:12 +01:00
4 changed files with 35 additions and 16 deletions
Showing only changes of commit c8c0b781f5 - Show all commits

View File

@ -78,41 +78,48 @@ bool BlenderSceneDelegate::GetVisible(SdfPath const &id)
return object_data(id)->visible;
}
pxr::GfRange3d BlenderSceneDelegate::GetExtent(pxr::SdfPath const &id)
GfRange3d BlenderSceneDelegate::GetExtent(SdfPath const &id)
{
LOG(INFO) << "GetExtent: " << id.GetString();
return pxr::GfRange3d();
return GfRange3d();
}
bool BlenderSceneDelegate::GetDoubleSided(pxr::SdfPath const &id)
bool BlenderSceneDelegate::GetDoubleSided(SdfPath const &id)
{
LOG(INFO) << "GetDoubleSided: " << id.GetString();
return false;
}
pxr::HdCullStyle BlenderSceneDelegate::GetCullStyle(pxr::SdfPath const &id)
HdCullStyle BlenderSceneDelegate::GetCullStyle(SdfPath const &id)
{
LOG(INFO) << "GetCullStyle: " << id.GetString();
return pxr::HdCullStyle();
return HdCullStyle();
}
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &primId)
SdfPath BlenderSceneDelegate::GetInstancerId(SdfPath const &primId)
{
LOG(INFO) << "GetInstancerId: " << primId.GetString();
return pxr::SdfPath();
ObjectData *obj_data = object_data(primId);
LOG(INFO) << "GetInstancerId: " << primId.GetAsString();
if (obj_data && obj_data->name() == "Cube") {
return GetDelegateID().AppendElementString("Instancer");
}
return SdfPath();
}
pxr::SdfPathVector BlenderSceneDelegate::GetInstancerPrototypes(pxr::SdfPath const &instancerId)
SdfPathVector BlenderSceneDelegate::GetInstancerPrototypes(SdfPath const &instancerId)
{
LOG(INFO) << "GetInstancerPrototypes: " << instancerId.GetString();
return pxr::SdfPathVector();
SdfPathVector paths;
paths.push_back(GetDelegateID().AppendElementString("Inst1"));
paths.push_back(GetDelegateID().AppendElementString("Inst2"));
return paths;
}
pxr::VtIntArray BlenderSceneDelegate::GetInstanceIndices(pxr::SdfPath const &instancerId,
pxr::SdfPath const &prototypeId)
VtIntArray BlenderSceneDelegate::GetInstanceIndices(SdfPath const &instancerId,
SdfPath const &prototypeId)
{
LOG(INFO) << "GetInstanceIndices: " << instancerId.GetString() << " " << prototypeId.GetString();
return pxr::VtIntArray();
return VtIntArray();
}
void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
@ -294,6 +301,7 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
/* Export initial objects */
update_collection(false, false);
update_world();
GetRenderIndex().InsertInstancer(this, GetDelegateID().AppendElementString("Instancer"));
return;
}
@ -374,12 +382,14 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
HdMeshTopology BlenderSceneDelegate::GetMeshTopology(SdfPath const& id)
{
LOG(INFO) << "GetMeshTopology: " << id.GetString();
MeshData *m_data = mesh_data(id);
return m_data->mesh_topology();
}
VtValue BlenderSceneDelegate::Get(SdfPath const& id, TfToken const& key)
{
LOG(INFO) << "Get: " << id.GetString() << " " << key.GetString();
ObjectData *obj_data = object_data(id);
if (obj_data) {
return obj_data->get_data(key);
@ -394,7 +404,12 @@ VtValue BlenderSceneDelegate::Get(SdfPath const& id, TfToken const& key)
HdPrimvarDescriptorVector BlenderSceneDelegate::GetPrimvarDescriptors(SdfPath const& id, HdInterpolation interpolation)
{
return mesh_data(id)->primvar_descriptors(interpolation);
LOG(INFO) << "GetPrimvarDescriptors: " << id.GetString() << " " << interpolation;
if (mesh_data(id)) {
return mesh_data(id)->primvar_descriptors(interpolation);
}
HdPrimvarDescriptorVector primvars;
return primvars;
}
SdfPath BlenderSceneDelegate::GetMaterialId(SdfPath const & rprimId)
@ -413,6 +428,7 @@ VtValue BlenderSceneDelegate::GetMaterialResource(SdfPath const& id)
GfMatrix4d BlenderSceneDelegate::GetTransform(SdfPath const& id)
{
LOG(INFO) << "GetTransform: " << id.GetString();
ObjectData *obj_data = object_data(id);
if (obj_data) {
return obj_data->transform();

View File

@ -28,7 +28,8 @@ pxr::SdfPath MaterialData::prim_id(pxr::HdSceneDelegate *scene_delegate, Materia
* Example: M_000002074e812088 */
char str[32];
snprintf(str, 32, "M_%016llx", (uint64_t)material);
return scene_delegate->GetDelegateID().AppendElementString(str);
//return scene_delegate->GetDelegateID().AppendElementString(str);
return scene_delegate->GetDelegateID().AppendElementString(((ID *)material)->name);
}
MaterialData::MaterialData(pxr::HdSceneDelegate *scene_delegate, Material *material)

View File

@ -25,6 +25,7 @@ public:
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation);
pxr::SdfPath material_id;
pxr::SdfPath instancer_id;
private:
void set_mesh(Mesh *mesh);

View File

@ -56,7 +56,8 @@ pxr::SdfPath ObjectData::prim_id(pxr::HdSceneDelegate *scene_delegate, Object *o
* O_000002073e369608 */
char str[32];
snprintf(str, 32, "O_%016llx", (uint64_t)object);
return scene_delegate->GetDelegateID().AppendElementString(str);
//return scene_delegate->GetDelegateID().AppendElementString(str);
return scene_delegate->GetDelegateID().AppendElementString(((ID *)object)->name);
}
ObjectData::ObjectData(pxr::HdSceneDelegate *scene_delegate, Object *object)