forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
@ -218,7 +218,6 @@ void BlenderSceneDelegate::clear()
|
|||||||
it->remove();
|
it->remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
objects_.clear();
|
objects_.clear();
|
||||||
instancers_.clear();
|
instancers_.clear();
|
||||||
materials_.clear_and_shrink();
|
materials_.clear_and_shrink();
|
||||||
@ -548,26 +547,25 @@ void BlenderSceneDelegate::remove_unused_objects()
|
|||||||
|
|
||||||
/* Remove unused instancers */
|
/* Remove unused instancers */
|
||||||
instancers_.remove_if([&](auto item) {
|
instancers_.remove_if([&](auto item) {
|
||||||
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||||
if (ret){
|
if (ret) {
|
||||||
item.value->remove();
|
item.value->remove();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
item.value->check_remove(available_objects);
|
item.value->check_remove(available_objects);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Remove unused objects */
|
/* Remove unused objects */
|
||||||
objects_.remove_if([&](auto item) {
|
objects_.remove_if([&](auto item) {
|
||||||
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||||
if (ret){
|
if (ret) {
|
||||||
item.value->remove();
|
item.value->remove();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Remove unused materials */
|
/* Remove unused materials */
|
||||||
std::set<pxr::SdfPath> available_materials;
|
std::set<pxr::SdfPath> available_materials;
|
||||||
for (auto &it : objects_.values()) {
|
for (auto &it : objects_.values()) {
|
||||||
@ -586,10 +584,10 @@ void BlenderSceneDelegate::remove_unused_objects()
|
|||||||
|
|
||||||
materials_.remove_if([&](auto item) {
|
materials_.remove_if([&](auto item) {
|
||||||
bool ret = available_materials.find(item.key) == available_materials.end();
|
bool ret = available_materials.find(item.key) == available_materials.end();
|
||||||
if (ret){
|
if (ret) {
|
||||||
item.value->remove();
|
item.value->remove();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,8 @@ void CurvesData::write_material()
|
|||||||
pxr::SdfPath p_id = scene_delegate_->material_prim_id(mat);
|
pxr::SdfPath p_id = scene_delegate_->material_prim_id(mat);
|
||||||
mat_data_ = scene_delegate_->material_data(p_id);
|
mat_data_ = scene_delegate_->material_data(p_id);
|
||||||
if (!mat_data_) {
|
if (!mat_data_) {
|
||||||
scene_delegate_->materials_.add_overwrite(p_id, std::make_unique<MaterialData>(scene_delegate_, mat, p_id));
|
scene_delegate_->materials_.add_overwrite(
|
||||||
|
p_id, std::make_unique<MaterialData>(scene_delegate_, mat, p_id));
|
||||||
mat_data_ = scene_delegate_->material_data(p_id);
|
mat_data_ = scene_delegate_->material_data(p_id);
|
||||||
mat_data_->init();
|
mat_data_->init();
|
||||||
mat_data_->insert();
|
mat_data_->insert();
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <pxr/base/vt/value.h>
|
#include <pxr/base/vt/value.h>
|
||||||
#include <pxr/usd/sdf/path.h>
|
#include <pxr/usd/sdf/path.h>
|
||||||
|
|
||||||
#include "DNA_ID.h"
|
|
||||||
#include "BLI_hash.hh"
|
#include "BLI_hash.hh"
|
||||||
|
#include "DNA_ID.h"
|
||||||
|
|
||||||
template<> struct blender::DefaultHash<pxr::SdfPath> {
|
template<> struct blender::DefaultHash<pxr::SdfPath> {
|
||||||
uint64_t operator()(const pxr::SdfPath &value) const
|
uint64_t operator()(const pxr::SdfPath &value) const
|
||||||
|
@ -257,11 +257,11 @@ void InstancerData::check_remove(std::set<std::string> &available_objects)
|
|||||||
|
|
||||||
mesh_instances_.remove_if([&](auto item) {
|
mesh_instances_.remove_if([&](auto item) {
|
||||||
bool res = available_objects.find(item.key.GetName()) == available_objects.end();
|
bool res = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||||
if (res){
|
if (res) {
|
||||||
item.value.data->remove();
|
item.value.data->remove();
|
||||||
ret = true;
|
ret = true;
|
||||||
};
|
};
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -272,11 +272,11 @@ void InstancerData::check_remove(std::set<std::string> &available_objects)
|
|||||||
|
|
||||||
light_instances_.remove_if([&](auto item) {
|
light_instances_.remove_if([&](auto item) {
|
||||||
bool res = available_objects.find(item.key.GetName()) == available_objects.end();
|
bool res = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||||
if (res){
|
if (res) {
|
||||||
item.value.transforms.clear();
|
item.value.transforms.clear();
|
||||||
update_light_instance(item.value);
|
update_light_instance(item.value);
|
||||||
};
|
};
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,12 +386,12 @@ void InstancerData::write_instances()
|
|||||||
free_object_duplilist(lb);
|
free_object_duplilist(lb);
|
||||||
|
|
||||||
/* Remove mesh intances without indices */
|
/* Remove mesh intances without indices */
|
||||||
mesh_instances_.remove_if([&](auto item) {return item.value.indices.empty();});
|
mesh_instances_.remove_if([&](auto item) { return item.value.indices.empty(); });
|
||||||
|
|
||||||
/* Update light intances and remove instances without transforms */
|
/* Update light intances and remove instances without transforms */
|
||||||
light_instances_.remove_if([&](auto item) {
|
light_instances_.remove_if([&](auto item) {
|
||||||
update_light_instance(item.value);
|
update_light_instance(item.value);
|
||||||
return item.value.transforms.empty();
|
return item.value.transforms.empty();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,6 @@ class InstancerData : public ObjectData {
|
|||||||
pxr::VtMatrix4dArray mesh_transforms_;
|
pxr::VtMatrix4dArray mesh_transforms_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using InstancerDataMap =
|
using InstancerDataMap = Map<pxr::SdfPath, std::unique_ptr<InstancerData>>;
|
||||||
Map<pxr::SdfPath, std::unique_ptr<InstancerData>>;
|
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <pxr/usd/sdf/assetPath.h>
|
#include <pxr/usd/sdf/assetPath.h>
|
||||||
#include <pxr/usd/sdf/path.h>
|
#include <pxr/usd/sdf/path.h>
|
||||||
|
|
||||||
#include "DNA_material_types.h"
|
|
||||||
#include "BLI_map.hh"
|
#include "BLI_map.hh"
|
||||||
|
#include "DNA_material_types.h"
|
||||||
|
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
|
|
||||||
|
@ -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_.add_overwrite(p_id,
|
scene_delegate_->materials_.add_overwrite(
|
||||||
std::make_unique<MaterialData>(scene_delegate_, mat, p_id));
|
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();
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <pxr/base/gf/matrix4d.h>
|
#include <pxr/base/gf/matrix4d.h>
|
||||||
|
|
||||||
#include "BKE_layer.h"
|
#include "BKE_layer.h"
|
||||||
#include "DNA_object_types.h"
|
|
||||||
#include "BLI_map.hh"
|
#include "BLI_map.hh"
|
||||||
|
#include "DNA_object_types.h"
|
||||||
|
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
@ -37,8 +37,7 @@ class ObjectData : public IdData {
|
|||||||
Object *parent_ = nullptr;
|
Object *parent_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ObjectDataMap =
|
using ObjectDataMap = Map<pxr::SdfPath, std::unique_ptr<ObjectData>>;
|
||||||
Map<pxr::SdfPath, std::unique_ptr<ObjectData>>;
|
|
||||||
|
|
||||||
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]);
|
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user