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