forked from blender/blender
Implement Viewport render with material preview #56
@ -205,6 +205,8 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
check_updates();
|
||||
}
|
||||
else {
|
||||
use_scene_lights = V3D_USES_SCENE_LIGHTS(view3d);
|
||||
shading_flag_ = view3d->shading.flag;
|
||||
add_new_objects();
|
||||
update_world();
|
||||
}
|
||||
@ -418,36 +420,6 @@ void BlenderSceneDelegate::update_world()
|
||||
}
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_scene_lights() {
|
||||
DEGObjectIterSettings settings = {0};
|
||||
settings.depsgraph = depsgraph;
|
||||
settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
||||
DEGObjectIterData data = {0};
|
||||
data.settings = &settings;
|
||||
data.graph = settings.depsgraph;
|
||||
data.flag = settings.flags;
|
||||
eEvaluationMode deg_mode = DEG_get_mode(depsgraph);
|
||||
|
||||
ITER_BEGIN (DEG_iterator_objects_begin,
|
||||
DEG_iterator_objects_next,
|
||||
DEG_iterator_objects_end,
|
||||
&data,
|
||||
Object *,
|
||||
object)
|
||||
{
|
||||
if (object->type == OB_LAMP) {
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
||||
2,
|
||||
"Visibility: %s [%s]",
|
||||
object->id.name,
|
||||
std::bitset<3>(BKE_object_visibility(object, deg_mode)).to_string().c_str());
|
||||
update_objects(object);
|
||||
update_instancers(object);
|
||||
}
|
||||
}
|
||||
ITER_END;
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::check_updates()
|
||||
{
|
||||
bool do_update_collection = false;
|
||||
@ -458,15 +430,16 @@ void BlenderSceneDelegate::check_updates()
|
||||
shading_flag_ = view3d->shading.flag;
|
||||
do_update_world = true;
|
||||
}
|
||||
|
||||
bool use_scene_lights_changed = false;
|
||||
auto a = V3D_USES_SCENE_LIGHTS(view3d);
|
||||
|
||||
if (use_scene_lights != V3D_USES_SCENE_LIGHTS(view3d)) {
|
||||
use_scene_lights = V3D_USES_SCENE_LIGHTS(view3d);
|
||||
use_scene_lights_changed = true;
|
||||
}
|
||||
if (use_scene_lights_changed) {
|
||||
if (use_scene_lights) {
|
||||
update_scene_lights();
|
||||
add_new_objects(true);
|
||||
}
|
||||
else {
|
||||
remove_unused_objects();
|
||||
@ -552,7 +525,7 @@ void BlenderSceneDelegate::check_updates()
|
||||
}
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::add_new_objects()
|
||||
void BlenderSceneDelegate::add_new_objects(bool only_lights)
|
||||
{
|
||||
DEGObjectIterSettings settings = {0};
|
||||
settings.depsgraph = depsgraph;
|
||||
@ -575,8 +548,16 @@ void BlenderSceneDelegate::add_new_objects()
|
||||
"Visibility: %s [%s]",
|
||||
object->id.name,
|
||||
std::bitset<3>(BKE_object_visibility(object, deg_mode)).to_string().c_str());
|
||||
update_objects(object);
|
||||
update_instancers(object);
|
||||
if (only_lights) {
|
||||
if (object->type == OB_LAMP) {
|
||||
update_objects(object);
|
||||
update_instancers(object);
|
||||
}
|
||||
}
|
||||
else {
|
||||
update_objects(object);
|
||||
update_instancers(object);
|
||||
}
|
||||
}
|
||||
ITER_END;
|
||||
}
|
||||
|
@ -89,9 +89,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
void update_objects(Object *object);
|
||||
void update_instancers(Object *object);
|
||||
void update_world();
|
||||
void update_scene_lights();
|
||||
void check_updates();
|
||||
void add_new_objects();
|
||||
void add_new_objects(bool only_lights = false);
|
||||
void remove_unused_objects();
|
||||
void update_visibility();
|
||||
|
||||
@ -101,7 +100,7 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
std::unique_ptr<WorldData> world_data_;
|
||||
|
||||
short shading_flag_;
|
||||
bool use_scene_lights = true;
|
||||
bool use_scene_lights = false;
|
||||
};
|
||||
|
||||
#define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) \
|
||||
|
Loading…
Reference in New Issue
Block a user