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