forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
@ -214,8 +214,8 @@ void BlenderSceneDelegate::clear()
|
||||
for (auto &it : objects_.values()) {
|
||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
|
||||
it->remove();
|
||||
}
|
||||
for (auto &it : instancers_) {
|
||||
it.second->remove();
|
||||
for (auto &it : instancers_.values()) {
|
||||
it->remove();
|
||||
}
|
||||
|
||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
rename rename `val` -> `obj_data`, `i_data`, `m_data`
|
||||
|
||||
@ -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);
|
||||
}
|
||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
`val` -> `i_data`
|
||||
|
||||
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();
|
||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
Georgiy Markelov
commented
seems like here should be seems like here should be `add_new`.
Bogdan Nagirniak
commented
use use `lookup_or_add_default`
Vasyl Pidhirskyi
commented
implemented via implemented via `lookup_or_add`
|
||||
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;
|
||||
instancers_.remove_if([&](auto item) {
|
||||
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||
if (ret){
|
||||
item.value->remove();
|
||||
}
|
||||
it->second->remove();
|
||||
instancers_.erase(it);
|
||||
it = instancers_.begin();
|
||||
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 */
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user
rename please
it
->val
as it misleads becausevalues()
doesn't return iterator.rename
val
->data