Add possibility to provide render delegate specific tokens to scene delegate #52

Merged
Bogdan Nagirniak merged 3 commits from BLEN-431 into hydra-render 2023-06-09 00:16:38 +02:00
4 changed files with 18 additions and 11 deletions

View File

@ -4,6 +4,7 @@
#include <bitset>
#include "BKE_object.h"
#include "BLI_set.hh"
#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<std::string>());
}
else {
settings.render_tokens.add_overwrite(pxr::TfToken(key), val);
}
}
pxr::SdfPath BlenderSceneDelegate::prim_id(ID *id, const char *prefix) const

View File

@ -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<pxr::TfToken, pxr::VtValue> render_tokens;
};
BlenderSceneDelegate(pxr::HdRenderIndex *parent_index,

View File

@ -17,6 +17,13 @@ template<> struct blender::DefaultHash<pxr::SdfPath> {
}
};
template<> struct blender::DefaultHash<pxr::TfToken> {
uint64_t operator()(const pxr::TfToken &value) const
{
return pxr::TfHash()(value);
}
};
namespace blender::render::hydra {
class BlenderSceneDelegate;

View File

@ -144,17 +144,12 @@ pxr::VtValue LightData::get_data(pxr::TfToken const &key) const
if (it != data_.end()) {
return pxr::VtValue(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")) {
return pxr::VtValue(false);
}
else {
return pxr::VtValue(true);
}
}
pxr::VtValue *ret_ptr = scene_delegate_->settings.render_tokens.lookup_ptr(key);
if (ret_ptr) {
return *ret_ptr;
}
return pxr::VtValue();
}