forked from blender/blender
Support several instancers on one object #24
@ -147,8 +147,8 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
|
||||
/* remove unused materials */
|
||||
std::set<pxr::SdfPath> available_materials;
|
||||
for (auto &obj : objects) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(obj.second.get());
|
||||
for (auto &it : objects) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(it.second.get());
|
||||
if (!m_data) {
|
||||
continue;
|
||||
}
|
||||
@ -157,6 +157,9 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
available_materials.insert(mat_id);
|
||||
}
|
||||
}
|
||||
for (auto &it : instancers) {
|
||||
it.second->available_materials(available_materials);
|
||||
}
|
||||
for (auto it = materials.begin(); it != materials.end(); ++it) {
|
||||
if (available_materials.find(it->first) != available_materials.end()) {
|
||||
continue;
|
||||
|
@ -152,6 +152,16 @@ void InstancerData::check_remove(pxr::SdfPath const &obj_id)
|
||||
p_id, pxr::HdChangeTracker::AllDirty);
|
||||
}
|
||||
|
||||
void InstancerData::available_materials(std::set<pxr::SdfPath> &paths)
|
||||
{
|
||||
for (auto &it : instances) {
|
||||
pxr::SdfPath mat_id = ((MeshData *)it.second.obj_data.get())->material_id();
|
||||
if (!mat_id.IsEmpty()) {
|
||||
paths.insert(mat_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InstancerData::set_instances()
|
||||
{
|
||||
transforms.clear();
|
||||
|
@ -37,6 +37,7 @@ class InstancerData : public ObjectData {
|
||||
pxr::SdfPathVector prototypes();
|
||||
void check_update(Object *object);
|
||||
void check_remove(pxr::SdfPath const &obj_id);
|
||||
void available_materials(std::set<pxr::SdfPath> &paths);
|
||||
|
||||
private:
|
||||
void set_instances();
|
||||
|
Loading…
Reference in New Issue
Block a user