forked from blender/blender
Make object visibility and instancing creation to be calculated via depsgraph #57
@ -438,8 +438,7 @@ void BlenderSceneDelegate::update_collection()
|
|||||||
|
|
||||||
DEGObjectIterSettings settings = {0};
|
DEGObjectIterSettings settings = {0};
|
||||||
settings.depsgraph = depsgraph;
|
settings.depsgraph = depsgraph;
|
||||||
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
|
settings.flags = DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS;
|
||||||
DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI;
|
|
||||||
DEGObjectIterData data = {0};
|
DEGObjectIterData data = {0};
|
||||||
data.settings = &settings;
|
data.settings = &settings;
|
||||||
data.graph = settings.depsgraph;
|
data.graph = settings.depsgraph;
|
||||||
|
@ -45,7 +45,7 @@ static std::string cache_image_file(Image *image,
|
|||||||
BKE_image_path_ext_from_imformat(&scene->r.im_format, &r_ext);
|
BKE_image_path_ext_from_imformat(&scene->r.im_format, &r_ext);
|
||||||
opts.im_format = scene->r.im_format;
|
opts.im_format = scene->r.im_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(file_name, sizeof(file_name), "img_%016llx%s", (uintptr_t)image, r_ext);
|
snprintf(file_name, sizeof(file_name), "img_%016llx%s", (uintptr_t)image, r_ext);
|
||||||
|
|
||||||
file_path = get_cache_file(file_name);
|
file_path = get_cache_file(file_name);
|
||||||
|
@ -194,10 +194,17 @@ void InstancerData::post_update()
|
|||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Update light intances and remove instances without transforms */
|
||||||
|
for (auto &l_inst : light_instances_.values()) {
|
||||||
|
update_light_instance(l_inst);
|
||||||
|
}
|
||||||
|
light_instances_.remove_if([&](auto item) { return item.value.transforms.empty(); });
|
||||||
|
|
||||||
/* Insert/remove/update instancer in RenderIndex */
|
/* Insert/remove/update instancer in RenderIndex */
|
||||||
pxr::HdRenderIndex &index = scene_delegate_->GetRenderIndex();
|
pxr::HdRenderIndex &index = scene_delegate_->GetRenderIndex();
|
||||||
if (mesh_instances_.is_empty()) {
|
if (mesh_instances_.is_empty()) {
|
||||||
if (index.HasInstancer(prim_id)) {
|
/* Important: removing instancer when light_instances_ are empty too */
|
||||||
|
if (index.HasInstancer(prim_id) && light_instances_.is_empty()) {
|
||||||
index.RemoveInstancer(prim_id);
|
index.RemoveInstancer(prim_id);
|
||||||
ID_LOG(1, "Remove instancer");
|
ID_LOG(1, "Remove instancer");
|
||||||
}
|
}
|
||||||
@ -212,12 +219,6 @@ void InstancerData::post_update()
|
|||||||
ID_LOG(1, "Insert instancer");
|
ID_LOG(1, "Insert instancer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update light intances and remove instances without transforms */
|
|
||||||
for (auto &l_inst : light_instances_.values()) {
|
|
||||||
update_light_instance(l_inst);
|
|
||||||
}
|
|
||||||
light_instances_.remove_if([&](auto item) { return item.value.transforms.empty(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pxr::SdfPath InstancerData::object_prim_id(Object *object) const
|
pxr::SdfPath InstancerData::object_prim_id(Object *object) const
|
||||||
|
@ -42,6 +42,12 @@ class InstancerData : public IdData {
|
|||||||
void available_materials(Set<pxr::SdfPath> &paths) const;
|
void available_materials(Set<pxr::SdfPath> &paths) const;
|
||||||
void update_double_sided(MaterialData *mat_data);
|
void update_double_sided(MaterialData *mat_data);
|
||||||
|
|
||||||
|
/* Following update functions are working together:
|
||||||
|
pre_update()
|
||||||
|
update_instance()
|
||||||
|
update_instance()
|
||||||
|
...
|
||||||
|
post_update() */
|
||||||
void pre_update();
|
void pre_update();
|
||||||
void update_instance(Object *parent_ob, DupliObject *dupli);
|
void update_instance(Object *parent_ob, DupliObject *dupli);
|
||||||
void post_update();
|
void post_update();
|
||||||
|
@ -176,11 +176,8 @@ void WorldData::write_transform()
|
|||||||
{
|
{
|
||||||
transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
|
transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
|
||||||
|
|
||||||
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
|
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180), pxr::GfVec3d());
|
||||||
pxr::GfVec3d());
|
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0), pxr::GfVec3d());
|
||||||
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),
|
|
||||||
pxr::GfVec3d());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
Loading…
Reference in New Issue
Block a user