Move to use blender::Map container instead std::unordered_map #47

Merged
Bogdan Nagirniak merged 17 commits from Vasyl-Pidhirskyi/blender_bn:BLEN-418 into hydra-render 2023-06-02 12:02:46 +02:00
3 changed files with 26 additions and 25 deletions
Showing only changes of commit e999ebdaf2 - Show all commits

View File

@ -214,8 +214,8 @@ void BlenderSceneDelegate::clear()
for (auto &it : objects_.values()) {
it->remove();
}
for (auto &it : instancers_) {
it.second->remove();
for (auto &it : instancers_.values()) {
it->remove();
}
@ -320,9 +320,9 @@ InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool
p_id = id;
}
auto it = instancers_.find(p_id);
if (it != instancers_.end()) {
return it->second.get();
const std::unique_ptr<InstancerData> *value = instancers_.lookup_ptr(p_id);
if (value != nullptr) {
return value->get();
}
return nullptr;
}
@ -357,8 +357,8 @@ void BlenderSceneDelegate::update_objects(Object *object)
void BlenderSceneDelegate::update_instancers(Object *object)
{
/* Check object inside instancers */
for (auto &it : instancers_) {
it.second->check_update(object);
for (auto &it : instancers_.values()) {
it->check_update(object);
}
pxr::SdfPath id = instancer_prim_id(object);
@ -367,7 +367,7 @@ void BlenderSceneDelegate::update_instancers(Object *object)
if ((object->transflag & OB_DUPLI) == 0) {
/* Object isn't instancer anymore and should be removed */
i_data->remove();
instancers_.erase(id);
instancers_.remove(id);
return;
}
@ -384,7 +384,7 @@ void BlenderSceneDelegate::update_instancers(Object *object)
return;
}
instancers_[id] = std::make_unique<InstancerData>(this, object, id);
instancers_.add_overwrite(id, std::make_unique<InstancerData>(this, object, id));
i_data = instancer_data(id);
i_data->init();
i_data->insert();
@ -547,16 +547,16 @@ void BlenderSceneDelegate::remove_unused_objects()
ITER_END;
/* Remove unused instancers */
for (auto it = instancers_.begin(); it != instancers_.end(); ++it) {
if (available_objects.find(it->first.GetName()) != available_objects.end()) {
/* Remove objects from instancers */
it->second->check_remove(available_objects);
continue;
}
it->second->remove();
instancers_.erase(it);
it = instancers_.begin();
instancers_.remove_if([&](auto item) {
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
if (ret){
item.value->remove();
}
else{
item.value->check_remove(available_objects);
}
return ret;
});
/* Remove unused objects */
objects_.remove_if([&](auto item) {
@ -580,8 +580,8 @@ void BlenderSceneDelegate::remove_unused_objects()
c_data->available_materials(available_materials);
}
}
for (auto &it : instancers_) {
it.second->available_materials(available_materials);
for (auto &it : instancers_.values()) {
it->available_materials(available_materials);
}
materials_.remove_if([&](auto item) {
@ -599,8 +599,8 @@ void BlenderSceneDelegate::update_visibility()
for (auto &it : objects_.values()) {
it->update_visibility();
}
for (auto &it : instancers_) {
it.second->update_visibility();
for (auto &it : instancers_.values()) {
it->update_visibility();
}
/* Add objects/instancers which were invisible before and not added yet */

View File

@ -4,6 +4,7 @@
#pragma once
#include "BKE_duplilist.h"
#include "BLI_map.hh"
#include "light.h"
#include "mesh.h"
@ -62,6 +63,6 @@ class InstancerData : public ObjectData {
};
using InstancerDataMap =
pxr::TfHashMap<pxr::SdfPath, std::unique_ptr<InstancerData>, pxr::SdfPath::Hash>;
Map<pxr::SdfPath, std::unique_ptr<InstancerData>>;
} // namespace blender::render::hydra

View File

@ -66,8 +66,8 @@ void MaterialData::update()
m_data->update_double_sided(this);
}
}
for (auto &it : scene_delegate_->instancers_) {
it.second->update_double_sided(this);
for (auto &it : scene_delegate_->instancers_.values()) {
it->update_double_sided(this);
}
}
}