Support multimaterials on one mesh #44

Merged
Bogdan Nagirniak merged 11 commits from BLEN-417 into hydra-render 2023-05-24 07:07:39 +02:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit de7e393e70 - Show all commits

View File

@ -236,11 +236,12 @@ pxr::SdfPath BlenderSceneDelegate::world_prim_id() const
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const
{ {
auto it = objects_.find(id); pxr::SdfPath p_id = (id.GetName().find("SM_", 0) == 0) ? id.GetParentPath() : id;
auto it = objects_.find(p_id);
if (it != objects_.end()) { if (it != objects_.end()) {
return it->second.get(); return it->second.get();
} }
InstancerData *i_data = instancer_data(id, true); InstancerData *i_data = instancer_data(p_id, true);
if (i_data) { if (i_data) {
return i_data->object_data(id); return i_data->object_data(id);
} }

View File

@ -262,14 +262,14 @@ void MeshData::write_normals(Mesh *mesh)
pxr::SdfPath MeshData::submesh_prim_id(int index) const pxr::SdfPath MeshData::submesh_prim_id(int index) const
{ {
char name[16]; char name[16];
snprintf(name, 16, "M_%04x", index); snprintf(name, 16, "SM_%04x", index);
return prim_id.AppendElementString(name); return prim_id.AppendElementString(name);
} }
const MeshData::SubMesh &MeshData::submesh(pxr::SdfPath const &id) const const MeshData::SubMesh &MeshData::submesh(pxr::SdfPath const &id) const
{ {
int index; int index;
sscanf(id.GetName().c_str(), "M_%x", &index); sscanf(id.GetName().c_str(), "SM_%x", &index);
return submeshes_[index]; return submeshes_[index];
} }