forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
@ -217,13 +217,11 @@ void BlenderSceneDelegate::clear()
|
||||
for (auto &it : instancers_) {
|
||||
it.second->remove();
|
||||
}
|
||||
for (auto &it : materials_) {
|
||||
it.second->remove();
|
||||
}
|
||||
|
||||
BogdanNagirniak marked this conversation as resolved
Outdated
|
||||
|
||||
objects_.clear();
|
||||
instancers_.clear();
|
||||
materials_.clear();
|
||||
materials_.clear_and_shrink();
|
||||
|
||||
depsgraph = nullptr;
|
||||
context = nullptr;
|
||||
@ -297,11 +295,11 @@ LightData *BlenderSceneDelegate::light_data(pxr::SdfPath const &id) const
|
||||
|
||||
MaterialData *BlenderSceneDelegate::material_data(pxr::SdfPath const &id) const
|
||||
{
|
||||
auto it = materials_.find(id);
|
||||
if (it == materials_.end()) {
|
||||
const std::unique_ptr<MaterialData> *value = materials_.lookup_ptr(id);
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return it->second.get();
|
||||
return value->get();
|
||||
}
|
||||
|
||||
InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool child_id) const
|
||||
@ -585,14 +583,14 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
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;
|
||||
}
|
||||
it->second->remove();
|
||||
materials_.erase(it);
|
||||
it = materials_.begin();
|
||||
|
||||
materials_.remove_if([&](auto item) {
|
||||
bool ret = available_materials.find(item.key) == available_materials.end();
|
||||
if (ret){
|
||||
item.value->remove();
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_visibility()
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "BLI_hash.hh"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
@ -18,6 +19,13 @@
|
||||
#include "object.h"
|
||||
#include "world.h"
|
||||
|
||||
template<> struct blender::DefaultHash<pxr::SdfPath> {
|
||||
uint64_t operator()(const pxr::SdfPath &value) const
|
||||
{
|
||||
return pxr::SdfPath::Hash()(value);
|
||||
}
|
||||
};
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <pxr/usd/sdf/path.h>
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
#include "BLI_map.hh"
|
||||
|
||||
#include "id.h"
|
||||
|
||||
@ -37,7 +38,6 @@ class MaterialData : public IdData {
|
||||
pxr::VtValue material_network_map_;
|
||||
};
|
||||
|
||||
using MaterialDataMap =
|
||||
pxr::TfHashMap<pxr::SdfPath, std::unique_ptr<MaterialData>, pxr::SdfPath::Hash>;
|
||||
using MaterialDataMap = Map<pxr::SdfPath, std::unique_ptr<MaterialData>>;
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -304,8 +304,8 @@ void MeshData::write_materials()
|
||||
pxr::SdfPath p_id = scene_delegate_->material_prim_id(mat);
|
||||
m.mat_data = scene_delegate_->material_data(p_id);
|
||||
if (!m.mat_data) {
|
||||
scene_delegate_->materials_[p_id] = std::make_unique<MaterialData>(
|
||||
scene_delegate_, mat, p_id);
|
||||
scene_delegate_->materials_.add_overwrite(p_id,
|
||||
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
`lookup_or_add_default`
Vasyl Pidhirskyi
commented
implemented via implemented via `lookup_or_add`
|
||||
std::make_unique<MaterialData>(scene_delegate_, mat, p_id));
|
||||
m.mat_data = scene_delegate_->material_data(p_id);
|
||||
m.mat_data->init();
|
||||
m.mat_data->insert();
|
||||
|
Loading…
Reference in New Issue
Block a user
rename
val
->obj_data
,i_data
,m_data