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()
|
void BlenderSceneDelegate::clear()
|
||||||
{
|
{
|
||||||
for (auto &it : objects_) {
|
for (auto &it : objects_.values()) {
|
||||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
|
|||||||
it.second->remove();
|
it->remove();
|
||||||
}
|
}
|
||||||
for (auto &it : instancers_) {
|
for (auto &it : instancers_) {
|
||||||
it.second->remove();
|
it.second->remove();
|
||||||
@ -267,9 +267,9 @@ pxr::SdfPath BlenderSceneDelegate::world_prim_id() const
|
|||||||
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const
|
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id) const
|
||||||
{
|
{
|
||||||
pxr::SdfPath p_id = (id.GetName().find("SM_") == 0) ? id.GetParentPath() : id;
|
pxr::SdfPath p_id = (id.GetName().find("SM_") == 0) ? id.GetParentPath() : id;
|
||||||
auto it = objects_.find(p_id);
|
const std::unique_ptr<ObjectData> *value = objects_.lookup_ptr(p_id);
|
||||||
if (it != objects_.end()) {
|
if (value != nullptr) {
|
||||||
return it->second.get();
|
return value->get();
|
||||||
}
|
}
|
||||||
BogdanNagirniak marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
```
auto obj_data = objects_.lookup_ptr(p_id);
if (obj_data) {
```
|
|||||||
InstancerData *i_data = instancer_data(p_id, true);
|
InstancerData *i_data = instancer_data(p_id, true);
|
||||||
if (i_data) {
|
if (i_data) {
|
||||||
@ -347,7 +347,7 @@ void BlenderSceneDelegate::update_objects(Object *object)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
objects_[id] = ObjectData::create(this, object, id);
|
objects_.add_overwrite(id, ObjectData::create(this, object, id));
|
||||||
obj_data = object_data(id);
|
obj_data = object_data(id);
|
||||||
obj_data->update_parent();
|
obj_data->update_parent();
|
||||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
Georgiy Markelov
commented
seems like here should be seems like here should be `add_new`.
|
|||||||
obj_data->init();
|
obj_data->init();
|
||||||
@ -559,23 +559,23 @@ void BlenderSceneDelegate::remove_unused_objects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove unused objects */
|
/* Remove unused objects */
|
||||||
for (auto it = objects_.begin(); it != objects_.end(); ++it) {
|
objects_.remove_if([&](auto item) {
|
||||||
if (available_objects.find(it->first.GetName()) != available_objects.end()) {
|
bool ret = available_objects.find(item.key.GetName()) == available_objects.end();
|
||||||
continue;
|
if (ret){
|
||||||
}
|
item.value->remove();
|
||||||
it->second->remove();
|
|
||||||
objects_.erase(it);
|
|
||||||
it = objects_.begin();
|
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Remove unused materials */
|
/* Remove unused materials */
|
||||||
std::set<pxr::SdfPath> available_materials;
|
std::set<pxr::SdfPath> available_materials;
|
||||||
for (auto &it : objects_) {
|
for (auto &it : objects_.values()) {
|
||||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
Try to use Try to use `blender::Set` here
|
|||||||
MeshData *m_data = dynamic_cast<MeshData *>(it.second.get());
|
MeshData *m_data = dynamic_cast<MeshData *>(it.get());
|
||||||
if (m_data) {
|
if (m_data) {
|
||||||
m_data->available_materials(available_materials);
|
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) {
|
if (c_data) {
|
||||||
c_data->available_materials(available_materials);
|
c_data->available_materials(available_materials);
|
||||||
}
|
}
|
||||||
@ -596,8 +596,8 @@ void BlenderSceneDelegate::remove_unused_objects()
|
|||||||
void BlenderSceneDelegate::update_visibility()
|
void BlenderSceneDelegate::update_visibility()
|
||||||
{
|
{
|
||||||
/* Updating visibility of existing objects/instancers */
|
/* Updating visibility of existing objects/instancers */
|
||||||
for (auto &it : objects_) {
|
for (auto &it : objects_.values()) {
|
||||||
it.second->update_visibility();
|
it->update_visibility();
|
||||||
}
|
}
|
||||||
for (auto &it : instancers_) {
|
for (auto &it : instancers_) {
|
||||||
it.second->update_visibility();
|
it.second->update_visibility();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "BKE_layer.h"
|
#include "BKE_layer.h"
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
|
#include "BLI_map.hh"
|
||||||
|
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
@ -37,7 +38,7 @@ class ObjectData : public IdData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
using ObjectDataMap =
|
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]);
|
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user
rename please
it
->val
as it misleads becausevalues()
doesn't return iterator.rename
val
->data