forked from blender/blender
Move to use blender::Map container instead std::unordered_map #47
@ -211,14 +211,14 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
|
||||
void BlenderSceneDelegate::clear()
|
||||
{
|
||||
for (auto &it : objects_.values()) {
|
||||
it->remove();
|
||||
for (auto &val : objects_.values()) {
|
||||
val->remove();
|
||||
}
|
||||
for (auto &it : instancers_.values()) {
|
||||
it->remove();
|
||||
for (auto &val : instancers_.values()) {
|
||||
val->remove();
|
||||
}
|
||||
for (auto &it : materials_.values()) {
|
||||
it->remove();
|
||||
for (auto &val : materials_.values()) {
|
||||
val->remove();
|
||||
}
|
||||
|
||||
objects_.clear();
|
||||
@ -269,9 +269,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;
|
||||
const std::unique_ptr<ObjectData> *value = objects_.lookup_ptr(p_id);
|
||||
if (value != nullptr) {
|
||||
return value->get();
|
||||
const std::unique_ptr<ObjectData> *val = objects_.lookup_ptr(p_id);
|
||||
if (val != nullptr) {
|
||||
return val->get();
|
||||
}
|
||||
InstancerData *i_data = instancer_data(p_id, true);
|
||||
if (i_data) {
|
||||
@ -297,11 +297,11 @@ LightData *BlenderSceneDelegate::light_data(pxr::SdfPath const &id) const
|
||||
|
||||
MaterialData *BlenderSceneDelegate::material_data(pxr::SdfPath const &id) const
|
||||
{
|
||||
const std::unique_ptr<MaterialData> *value = materials_.lookup_ptr(id);
|
||||
if (value == nullptr) {
|
||||
const std::unique_ptr<MaterialData> *val = materials_.lookup_ptr(id);
|
||||
if (!val) {
|
||||
return nullptr;
|
||||
}
|
||||
return value->get();
|
||||
return val->get();
|
||||
}
|
||||
|
||||
InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool child_id) const
|
||||
@ -322,9 +322,9 @@ InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool
|
||||
p_id = id;
|
||||
}
|
||||
|
||||
const std::unique_ptr<InstancerData> *value = instancers_.lookup_ptr(p_id);
|
||||
if (value != nullptr) {
|
||||
return value->get();
|
||||
const std::unique_ptr<InstancerData> *val = instancers_.lookup_ptr(p_id);
|
||||
if (val != nullptr) {
|
||||
return val->get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -359,8 +359,8 @@ void BlenderSceneDelegate::update_objects(Object *object)
|
||||
void BlenderSceneDelegate::update_instancers(Object *object)
|
||||
{
|
||||
/* Check object inside instancers */
|
||||
for (auto &it : instancers_.values()) {
|
||||
it->check_update(object);
|
||||
for (auto &val : instancers_.values()) {
|
||||
val->check_update(object);
|
||||
}
|
||||
|
||||
pxr::SdfPath id = instancer_prim_id(object);
|
||||
@ -571,18 +571,18 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
|
||||
/* Remove unused materials */
|
||||
std::set<pxr::SdfPath> available_materials;
|
||||
for (auto &it : objects_.values()) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(it.get());
|
||||
for (auto &val : objects_.values()) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(val.get());
|
||||
if (m_data) {
|
||||
m_data->available_materials(available_materials);
|
||||
}
|
||||
CurvesData *c_data = dynamic_cast<CurvesData *>(it.get());
|
||||
CurvesData *c_data = dynamic_cast<CurvesData *>(val.get());
|
||||
if (c_data) {
|
||||
c_data->available_materials(available_materials);
|
||||
}
|
||||
}
|
||||
for (auto &it : instancers_.values()) {
|
||||
it->available_materials(available_materials);
|
||||
for (auto &val : instancers_.values()) {
|
||||
val->available_materials(available_materials);
|
||||
}
|
||||
|
||||
materials_.remove_if([&](auto item) {
|
||||
@ -597,11 +597,11 @@ void BlenderSceneDelegate::remove_unused_objects()
|
||||
void BlenderSceneDelegate::update_visibility()
|
||||
{
|
||||
/* Updating visibility of existing objects/instancers */
|
||||
for (auto &it : objects_.values()) {
|
||||
it->update_visibility();
|
||||
for (auto &val : objects_.values()) {
|
||||
val->update_visibility();
|
||||
}
|
||||
for (auto &it : instancers_.values()) {
|
||||
it->update_visibility();
|
||||
for (auto &val : instancers_.values()) {
|
||||
val->update_visibility();
|
||||
}
|
||||
|
||||
/* Add objects/instancers which were invisible before and not added yet */
|
||||
|
@ -74,14 +74,14 @@ void InstancerData::insert()
|
||||
void InstancerData::remove()
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", prim_id.GetText());
|
||||
for (auto &it : mesh_instances_.values()) {
|
||||
it.data->remove();
|
||||
for (auto &val : mesh_instances_.values()) {
|
||||
val.data->remove();
|
||||
}
|
||||
scene_delegate_->GetRenderIndex().RemoveInstancer(prim_id);
|
||||
|
||||
for (auto &it : light_instances_.values()) {
|
||||
it.transforms.clear();
|
||||
update_light_instance(it);
|
||||
for (auto &val : light_instances_.values()) {
|
||||
val.transforms.clear();
|
||||
update_light_instance(val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,17 +118,17 @@ bool InstancerData::update_visibility()
|
||||
if (ret) {
|
||||
auto &change_tracker = scene_delegate_->GetRenderIndex().GetChangeTracker();
|
||||
change_tracker.MarkInstancerDirty(prim_id, pxr::HdChangeTracker::DirtyVisibility);
|
||||
for (auto &it : mesh_instances_.values()) {
|
||||
it.data->visible = visible;
|
||||
for (auto &p : it.data->submesh_paths()) {
|
||||
for (auto &val : mesh_instances_.values()) {
|
||||
val.data->visible = visible;
|
||||
for (auto &p : val.data->submesh_paths()) {
|
||||
change_tracker.MarkRprimDirty(p, pxr::HdChangeTracker::DirtyVisibility);
|
||||
}
|
||||
}
|
||||
char name[16];
|
||||
for (auto &it : light_instances_.values()) {
|
||||
for (int i = 0; i < it.count; ++i) {
|
||||
for (auto &val : light_instances_.values()) {
|
||||
for (int i = 0; i < val.count; ++i) {
|
||||
snprintf(name, 16, "L_%08x", i);
|
||||
change_tracker.MarkRprimDirty(it.data->prim_id.AppendElementString(name),
|
||||
change_tracker.MarkRprimDirty(val.data->prim_id.AppendElementString(name),
|
||||
pxr::HdChangeTracker::DirtyVisibility);
|
||||
}
|
||||
}
|
||||
@ -179,8 +179,8 @@ ObjectData *InstancerData::object_data(pxr::SdfPath const &id) const
|
||||
pxr::SdfPathVector InstancerData::prototypes() const
|
||||
{
|
||||
pxr::SdfPathVector paths;
|
||||
for (auto &it : mesh_instances_.values()) {
|
||||
for (auto &p : it.data->submesh_paths()) {
|
||||
for (auto &val : mesh_instances_.values()) {
|
||||
for (auto &p : val.data->submesh_paths()) {
|
||||
paths.push_back(p);
|
||||
}
|
||||
}
|
||||
@ -282,8 +282,8 @@ void InstancerData::check_remove(std::set<std::string> &available_objects)
|
||||
|
||||
void InstancerData::available_materials(std::set<pxr::SdfPath> &paths) const
|
||||
{
|
||||
for (auto &it : mesh_instances_.values()) {
|
||||
((MeshData *)it.data.get())->available_materials(paths);
|
||||
for (auto &val : mesh_instances_.values()) {
|
||||
((MeshData *)val.data.get())->available_materials(paths);
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,8 +296,8 @@ void InstancerData::update_as_parent()
|
||||
|
||||
void InstancerData::update_double_sided(MaterialData *mat_data)
|
||||
{
|
||||
for (auto &it : mesh_instances_.values()) {
|
||||
it.data->update_double_sided(mat_data);
|
||||
for (auto &val : mesh_instances_.values()) {
|
||||
val.data->update_double_sided(mat_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,11 +342,11 @@ int InstancerData::light_prim_id_index(pxr::SdfPath const &id) const
|
||||
void InstancerData::write_instances()
|
||||
{
|
||||
mesh_transforms_.clear();
|
||||
for (auto &it : mesh_instances_.values()) {
|
||||
it.indices.clear();
|
||||
for (auto &val : mesh_instances_.values()) {
|
||||
val.indices.clear();
|
||||
}
|
||||
for (auto &it : light_instances_.values()) {
|
||||
it.transforms.clear();
|
||||
for (auto &val : light_instances_.values()) {
|
||||
val.transforms.clear();
|
||||
}
|
||||
|
||||
ListBase *lb = object_duplilist(
|
||||
@ -456,20 +456,20 @@ void InstancerData::update_light_instance(LightInstance &inst)
|
||||
|
||||
InstancerData::MeshInstance *InstancerData::mesh_instance(pxr::SdfPath const &id) const
|
||||
{
|
||||
auto it = mesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
|
||||
if (it == nullptr) {
|
||||
auto val = mesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
|
||||
if (!val) {
|
||||
return nullptr;
|
||||
}
|
||||
return const_cast<MeshInstance *>(it);
|
||||
return const_cast<MeshInstance *>(val);
|
||||
}
|
||||
|
||||
InstancerData::LightInstance *InstancerData::light_instance(pxr::SdfPath const &id) const
|
||||
{
|
||||
auto it = light_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
|
||||
if (it == nullptr) {
|
||||
auto val = light_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : id);
|
||||
if (!val) {
|
||||
return nullptr;
|
||||
}
|
||||
return const_cast<LightInstance *>(it);
|
||||
return const_cast<LightInstance *>(val);
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -60,14 +60,14 @@ void MaterialData::update()
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(prim_id,
|
||||
pxr::HdMaterial::AllDirty);
|
||||
if (prev_double_sided != double_sided) {
|
||||
for (auto &it : scene_delegate_->objects_.values()) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(it.get());
|
||||
for (auto &val : scene_delegate_->objects_.values()) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(val.get());
|
||||
if (m_data) {
|
||||
m_data->update_double_sided(this);
|
||||
}
|
||||
}
|
||||
for (auto &it : scene_delegate_->instancers_.values()) {
|
||||
it->update_double_sided(this);
|
||||
for (auto &val : scene_delegate_->instancers_.values()) {
|
||||
val->update_double_sided(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user