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