forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
@ -524,7 +524,7 @@ void BlenderSceneDelegate::add_new_objects()
|
||||
void BlenderSceneDelegate::remove_unused_objects()
|
||||
{
|
||||
/* Get available objects */
|
||||
std::set<std::string> available_objects;
|
||||
Set<std::string> available_objects;
|
||||
|
||||
DEGObjectIterSettings settings = {0};
|
||||
settings.depsgraph = depsgraph;
|
||||
@ -542,15 +542,15 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
object)
|
||||
{
|
||||
if (ObjectData::is_supported(object)) {
|
||||
available_objects.insert(object_prim_id(object).GetName());
|
||||
available_objects.add(object_prim_id(object).GetName());
|
||||
}
|
||||
available_objects.insert(instancer_prim_id(object).GetName());
|
||||
available_objects.add(instancer_prim_id(object).GetName());
|
||||
}
|
||||
ITER_END;
|
||||
|
||||
/* Remove unused instancers */
|
||||
instancers_.remove_if([&](auto item) {
|
||||
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||
bool ret = !available_objects.contains(item.key.GetName());
|
||||
if (ret) {
|
||||
item.value->remove();
|
||||
}
|
||||
@ -562,7 +562,7 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
|
||||
/* Remove unused objects */
|
||||
objects_.remove_if([&](auto item) {
|
||||
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||
bool ret = !available_objects.contains(item.key.GetName());
|
||||
if (ret) {
|
||||
item.value->remove();
|
||||
}
|
||||
@ -570,7 +570,7 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
});
|
||||
|
||||
/* Remove unused materials */
|
||||
std::set<pxr::SdfPath> available_materials;
|
||||
Set<pxr::SdfPath> available_materials;
|
||||
for (auto &val : objects_.values()) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(val.get());
|
||||
if (m_data) {
|
||||
@ -586,7 +586,7 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
}
|
||||
|
||||
materials_.remove_if([&](auto item) {
|
||||
bool ret = available_materials.find(item.key) == available_materials.end();
|
||||
bool ret = !available_materials.contains(item.key);
|
||||
if (ret) {
|
||||
item.value->remove();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "BLI_set.hh"
|
||||
#include "curves.h"
|
||||
#include "instancer.h"
|
||||
#include "light.h"
|
||||
|
@ -134,10 +134,10 @@ pxr::SdfPath CurvesData::material_id() const
|
||||
return mat_data_->prim_id;
|
||||
}
|
||||
|
||||
void CurvesData::available_materials(std::set<pxr::SdfPath> &paths) const
|
||||
void CurvesData::available_materials(Set<pxr::SdfPath> &paths) const
|
||||
{
|
||||
if (mat_data_ && !mat_data_->prim_id.IsEmpty()) {
|
||||
paths.insert(mat_data_->prim_id);
|
||||
paths.add(mat_data_->prim_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "BKE_duplilist.h"
|
||||
#include "DNA_Curves_types.h"
|
||||
|
||||
#include "BLI_set.hh"
|
||||
#include "material.h"
|
||||
#include "object.h"
|
||||
|
||||
@ -29,7 +30,7 @@ class CurvesData : public ObjectData {
|
||||
pxr::HdBasisCurvesTopology curves_topology(pxr::SdfPath const &id) const;
|
||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
|
||||
pxr::SdfPath material_id() const;
|
||||
void available_materials(std::set<pxr::SdfPath> &paths) const;
|
||||
void available_materials(Set<pxr::SdfPath> &paths) const;
|
||||
|
||||
private:
|
||||
void write_curves(Curves *curves);
|
||||
|
@ -251,12 +251,12 @@ void InstancerData::check_update(Object *object)
|
||||
}
|
||||
}
|
||||
|
||||
void InstancerData::check_remove(std::set<std::string> &available_objects)
|
||||
void InstancerData::check_remove(Set<std::string> &available_objects)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
mesh_instances_.remove_if([&](auto item) {
|
||||
bool res = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||
bool res = !available_objects.contains(item.key.GetName());
|
||||
if (res) {
|
||||
item.value.data->remove();
|
||||
ret = true;
|
||||
@ -271,7 +271,7 @@ void InstancerData::check_remove(std::set<std::string> &available_objects)
|
||||
}
|
||||
|
||||
light_instances_.remove_if([&](auto item) {
|
||||
bool res = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||
bool res = !available_objects.contains(item.key.GetName());
|
||||
if (res) {
|
||||
item.value.transforms.clear();
|
||||
update_light_instance(item.value);
|
||||
@ -280,7 +280,7 @@ void InstancerData::check_remove(std::set<std::string> &available_objects)
|
||||
});
|
||||
}
|
||||
|
||||
void InstancerData::available_materials(std::set<pxr::SdfPath> &paths) const
|
||||
void InstancerData::available_materials(Set<pxr::SdfPath> &paths) const
|
||||
{
|
||||
for (auto &m_inst : mesh_instances_.values()) {
|
||||
((MeshData *)m_inst.data.get())->available_materials(paths);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "BKE_duplilist.h"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_set.hh"
|
||||
|
||||
#include "light.h"
|
||||
#include "mesh.h"
|
||||
@ -42,8 +43,8 @@ class InstancerData : public ObjectData {
|
||||
ObjectData *object_data(pxr::SdfPath const &id) const;
|
||||
pxr::SdfPathVector prototypes() const;
|
||||
void check_update(Object *object);
|
||||
void check_remove(std::set<std::string> &available_objects);
|
||||
void available_materials(std::set<pxr::SdfPath> &paths) const;
|
||||
void check_remove(Set<std::string> &available_objects);
|
||||
void available_materials(Set<pxr::SdfPath> &paths) const;
|
||||
void update_as_parent();
|
||||
void update_double_sided(MaterialData *mat_data);
|
||||
|
||||
|
@ -173,11 +173,11 @@ void MeshData::update_double_sided(MaterialData *mat_data)
|
||||
}
|
||||
}
|
||||
|
||||
void MeshData::available_materials(std::set<pxr::SdfPath> &paths) const
|
||||
void MeshData::available_materials(Set<pxr::SdfPath> &paths) const
|
||||
{
|
||||
for (auto &sm : submeshes_) {
|
||||
if (sm.mat_data && !sm.mat_data->prim_id.IsEmpty()) {
|
||||
paths.insert(sm.mat_data->prim_id);
|
||||
paths.add(sm.mat_data->prim_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <pxr/imaging/hd/sceneDelegate.h>
|
||||
|
||||
#include "BKE_duplilist.h"
|
||||
#include "BLI_set.hh"
|
||||
|
||||
#include "material.h"
|
||||
#include "object.h"
|
||||
@ -39,7 +40,7 @@ class MeshData : public ObjectData {
|
||||
pxr::SdfPath material_id(pxr::SdfPath const &id) const;
|
||||
bool double_sided(pxr::SdfPath const &id) const;
|
||||
void update_double_sided(MaterialData *mat_data);
|
||||
void available_materials(std::set<pxr::SdfPath> &paths) const;
|
||||
void available_materials(Set<pxr::SdfPath> &paths) const;
|
||||
pxr::SdfPathVector submesh_paths() const;
|
||||
|
||||
pxr::HdCullStyle cull_style = pxr::HdCullStyleBackUnlessDoubleSided;
|
||||
|
Loading…
Reference in New Issue
Block a user