forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
No reviewers
Labels
No Label
No Milestone
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: BogdanNagirniak/blender#47
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Vasyl-Pidhirskyi/blender_bn:BLEN-418"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose
Move to use blender::Map container instead std::unordered_map.
Move to use blender::Set container instead std::set.
Technical steps
Adjusted code according to
BLI_map.hh
,BLI_set.hh
andBLI_hash.hh
implementations.Refactored
InstancerDataMap
,ObjectDataMap
,MaterialDataMap
,mesh_instances_
,light_instances_
,available_objects
, andavailable_materials
.see comments
@ -350,3 +350,3 @@
}
objects_[id] = ObjectData::create(this, object, id);
objects_.add_overwrite(id, ObjectData::create(this, object, id));
seems like here should be
add_new
.@ -387,3 +387,3 @@
}
instancers_[id] = std::make_unique<InstancerData>(this, object, id);
instancers_.add_overwrite(id, std::make_unique<InstancerData>(this, object, id));
seems like here should be
add_new
.@ -200,3 +200,3 @@
mat_data_ = scene_delegate_->material_data(p_id);
if (!mat_data_) {
scene_delegate_->materials_[p_id] = std::make_unique<MaterialData>(scene_delegate_, mat, p_id);
scene_delegate_->materials_.add_overwrite(
seems like here should be
add_new
.@ -393,3 +389,1 @@
mesh_instances_.erase(it);
it = mesh_instances_.begin();
}
mesh_instances_.remove_if([&](auto item) { return item.value.indices.empty(); });
missed
.data->remove()
?@ -306,3 +306,2 @@
if (!m.mat_data) {
scene_delegate_->materials_[p_id] = std::make_unique<MaterialData>(
scene_delegate_, mat, p_id);
scene_delegate_->materials_.add_overwrite(
seems like here should be
add_new
.@ -363,3 +362,3 @@
LightInstance *inst = light_instance(p_id);
if (!inst) {
inst = &light_instances_[p_id];
inst = light_instances_.lookup_ptr(p_id);
lookup
instead oflookup_ptr
also crash here due toinst
is empty@ -376,3 +374,1 @@
inst->data = std::make_unique<MeshData>(scene_delegate_, ob, p_id);
inst->data->init();
inst->data->insert();
inst = mesh_instances_.lookup_ptr(p_id);
lookup
instead oflookup_ptr
@ -377,2 +374,2 @@
inst->data->init();
inst->data->insert();
inst = mesh_instances_.lookup_ptr(p_id);
if (inst) {
check logic here
@ -464,2 +459,2 @@
auto it = mesh_instances_.find(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
if (it == mesh_instances_.end()) {
auto it = mesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
if (it == nullptr) {
if (!it) {
}
@ -473,2 +468,2 @@
auto it = light_instances_.find(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
if (it == light_instances_.end()) {
auto it = light_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
if (it == nullptr) {
if (!it) {
}
@ -213,3 +213,2 @@
{
for (auto &it : objects_) {
it.second->remove();
for (auto &it : objects_.values()) {
rename please
it
->val
as it misleads becausevalues()
doesn't return iterator.Works good, but requires some renamings and improvements in using functions
@ -213,3 +213,2 @@
{
for (auto &it : objects_) {
it.second->remove();
for (auto &val : objects_.values()) {
rename
val
->data
@ -219,3 +219,2 @@
}
for (auto &it : materials_) {
it.second->remove();
for (auto &val : materials_.values()) {
rename
val
->obj_data
,i_data
,m_data
@ -273,2 +272,2 @@
if (it != objects_.end()) {
return it->second.get();
const std::unique_ptr<ObjectData> *val = objects_.lookup_ptr(p_id);
if (val != nullptr) {
@ -361,3 +361,2 @@
/* Check object inside instancers */
for (auto &it : instancers_) {
it.second->check_update(object);
for (auto &val : instancers_.values()) {
val
->i_data
@ -387,3 +387,3 @@
}
instancers_[id] = std::make_unique<InstancerData>(this, object, id);
instancers_.add_new(id, std::make_unique<InstancerData>(this, object, id));
use
lookup_or_add_default
implemented via
lookup_or_add
@ -572,3 +570,4 @@
});
/* Remove unused materials */
std::set<pxr::SdfPath> available_materials;
Try to use
blender::Set
here@ -306,3 +306,2 @@
if (!m.mat_data) {
scene_delegate_->materials_[p_id] = std::make_unique<MaterialData>(
scene_delegate_, mat, p_id);
scene_delegate_->materials_.add_new(
lookup_or_add_default
implemented via
lookup_or_add
Works fine
Tested - works good