From 7e19487ba033a8bc60da0f972fe5acac5aabbbd5 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 7 Jun 2023 15:22:21 +0300 Subject: [PATCH 1/2] Initial --- .../hydra/scene_delegate/blender_scene_delegate.cc | 4 ++++ .../hydra/scene_delegate/blender_scene_delegate.h | 3 ++- source/blender/render/hydra/scene_delegate/id.h | 7 +++++++ source/blender/render/hydra/scene_delegate/light.cc | 11 ++--------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index e1a6f0326707..e14bfc205cc6 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -3,6 +3,7 @@ #include +#include "BLI_set.hh" #include "BKE_object.h" #include "DEG_depsgraph_query.h" #include "DNA_scene_types.h" @@ -236,6 +237,9 @@ void BlenderSceneDelegate::set_setting(const std::string &key, const pxr::VtValu if (key == "MaterialXFilenameKey") { settings.mx_filename_key = pxr::TfToken(val.Get()); } + else { + settings.render_tokens.add_overwrite(pxr::TfToken(key), val); + } } pxr::SdfPath BlenderSceneDelegate::prim_id(ID *id, const char *prefix) const diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h index 16f659d99b3e..c7b1468408e4 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.h @@ -11,7 +11,7 @@ #include "CLG_log.h" -#include "BLI_set.hh" +#include "BLI_map.hh" #include "curves.h" #include "instancer.h" #include "light.h" @@ -34,6 +34,7 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate { public: struct Settings { pxr::TfToken mx_filename_key; + Map render_tokens; }; BlenderSceneDelegate(pxr::HdRenderIndex *parent_index, diff --git a/source/blender/render/hydra/scene_delegate/id.h b/source/blender/render/hydra/scene_delegate/id.h index c210236e2ba3..ccfba5a61584 100644 --- a/source/blender/render/hydra/scene_delegate/id.h +++ b/source/blender/render/hydra/scene_delegate/id.h @@ -17,6 +17,13 @@ template<> struct blender::DefaultHash { } }; +template<> struct blender::DefaultHash { + uint64_t operator()(const pxr::TfToken &value) const + { + return pxr::TfHash()(value); + } +}; + namespace blender::render::hydra { class BlenderSceneDelegate; diff --git a/source/blender/render/hydra/scene_delegate/light.cc b/source/blender/render/hydra/scene_delegate/light.cc index 5078ebcbe31e..bba89bb64760 100644 --- a/source/blender/render/hydra/scene_delegate/light.cc +++ b/source/blender/render/hydra/scene_delegate/light.cc @@ -145,15 +145,8 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key) const ret = it->second; } else { - std::string n = key.GetString(); - if (boost::algorithm::contains(n, "object:visibility:")) { - if (boost::algorithm::ends_with(n, "camera") || boost::algorithm::ends_with(n, "shadow")) { - ret = false; - } - else { - ret = true; - } - } + pxr::VtValue *ret_ptr = scene_delegate_->settings.render_tokens.lookup_ptr(key); + ret = ret_ptr ? *ret_ptr : pxr::VtValue(); } return ret; } -- 2.30.2 From 1daeb781f6a08d9d63e50cc97f181180741032d6 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Fri, 9 Jun 2023 01:14:23 +0300 Subject: [PATCH 2/2] Fixes after merge --- .../render/hydra/scene_delegate/blender_scene_delegate.cc | 2 +- source/blender/render/hydra/scene_delegate/light.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc index 311ebdc923a6..4326fc6bf008 100644 --- a/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc +++ b/source/blender/render/hydra/scene_delegate/blender_scene_delegate.cc @@ -3,8 +3,8 @@ #include -#include "BLI_set.hh" #include "BKE_object.h" +#include "BLI_set.hh" #include "DEG_depsgraph_query.h" #include "DNA_scene_types.h" diff --git a/source/blender/render/hydra/scene_delegate/light.cc b/source/blender/render/hydra/scene_delegate/light.cc index 05db02165cd7..b9952f2ddad2 100644 --- a/source/blender/render/hydra/scene_delegate/light.cc +++ b/source/blender/render/hydra/scene_delegate/light.cc @@ -149,6 +149,7 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key) const if (ret_ptr) { return *ret_ptr; } + return pxr::VtValue(); } -- 2.30.2