forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
@ -211,8 +211,8 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
|
||||
void BlenderSceneDelegate::clear()
|
||||
{
|
||||
for (auto &it : objects_) {
|
||||
it.second->remove();
|
||||
for (auto &it : objects_.values()) {
|
||||
it->remove();
|
||||
}
|
||||
for (auto &it : instancers_) {
|
||||
it.second->remove();
|
||||
@ -267,9 +267,9 @@ pxr::SdfPath BlenderSceneDelegate::world_prim_id() const
|
||||
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const
|
||||
{
|
||||
pxr::SdfPath p_id = (id.GetName().find("SM_") == 0) ? id.GetParentPath() : id;
|
||||
auto it = objects_.find(p_id);
|
||||
if (it != objects_.end()) {
|
||||
return it->second.get();
|
||||
const std::unique_ptr<ObjectData> *value = objects_.lookup_ptr(p_id);
|
||||
if (value != nullptr) {
|
||||
return value->get();
|
||||
}
|
||||
InstancerData *i_data = instancer_data(p_id, true);
|
||||
if (i_data) {
|
||||
@ -347,7 +347,7 @@ void BlenderSceneDelegate::update_objects(Object *object)
|
||||
return;
|
||||
}
|
||||
|
||||
objects_[id] = ObjectData::create(this, object, id);
|
||||
objects_.add_overwrite(id, ObjectData::create(this, object, id));
|
||||
obj_data = object_data(id);
|
||||
obj_data->update_parent();
|
||||
obj_data->init();
|
||||
@ -559,23 +559,23 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
}
|
||||
|
||||
/* Remove unused objects */
|
||||
for (auto it = objects_.begin(); it != objects_.end(); ++it) {
|
||||
if (available_objects.find(it->first.GetName()) != available_objects.end()) {
|
||||
continue;
|
||||
}
|
||||
it->second->remove();
|
||||
objects_.erase(it);
|
||||
it = objects_.begin();
|
||||
objects_.remove_if([&](auto item) {
|
||||
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||
if (ret){
|
||||
item.value->remove();
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
|
||||
|
||||
/* Remove unused materials */
|
||||
std::set<pxr::SdfPath> available_materials;
|
||||
for (auto &it : objects_) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(it.second.get());
|
||||
for (auto &it : objects_.values()) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(it.get());
|
||||
if (m_data) {
|
||||
m_data->available_materials(available_materials);
|
||||
}
|
||||
CurvesData *c_data = dynamic_cast<CurvesData *>(it.second.get());
|
||||
CurvesData *c_data = dynamic_cast<CurvesData *>(it.get());
|
||||
if (c_data) {
|
||||
c_data->available_materials(available_materials);
|
||||
}
|
||||
@ -596,8 +596,8 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
void BlenderSceneDelegate::update_visibility()
|
||||
{
|
||||
/* Updating visibility of existing objects/instancers */
|
||||
for (auto &it : objects_) {
|
||||
it.second->update_visibility();
|
||||
for (auto &it : objects_.values()) {
|
||||
it->update_visibility();
|
||||
}
|
||||
for (auto &it : instancers_) {
|
||||
it.second->update_visibility();
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "BKE_layer.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "BLI_map.hh"
|
||||
|
||||
#include "id.h"
|
||||
#include "material.h"
|
||||
@ -37,7 +38,7 @@ class ObjectData : public IdData {
|
||||
};
|
||||
|
||||
using ObjectDataMap =
|
||||
pxr::TfHashMap<pxr::SdfPath, std::unique_ptr<ObjectData>, pxr::SdfPath::Hash>;
|
||||
Map<pxr::SdfPath, std::unique_ptr<ObjectData>>;
|
||||
|
||||
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user