Skip to content

Commit

Permalink
Remove arnold:global: prefix (#308)
Browse files Browse the repository at this point in the history
* Remove arnold:global: prefix
* Use utility function for string removal
* Fix crash in OSX

Fixes #302


Co-authored-by: Julian Hodgson <julian@solidangle.com>
  • Loading branch information
jhodgson and Julian Hodgson authored Mar 30, 2020
1 parent 74aaa47 commit eeffc95
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ if env['COMPILER'] in ['gcc', 'clang']:
if env['WARN_LEVEL'] == 'none':
env.Append(CCFLAGS = Split('-w'))
else:
env.Append(CCFLAGS = Split('-Wall -Wsign-compare'))
env.Append(CCFLAGS = Split('-Wall -Wsign-compare -Wno-deprecated-register -Wno-undefined-var-template -Wno-unused-local-typedef'))
if env['WARN_LEVEL'] == 'strict':
env.Append(CCFLAGS = Split('-Werror'))

Expand Down
18 changes: 15 additions & 3 deletions render_delegate/render_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ PXR_NAMESPACE_OPEN_SCOPE
TF_DEFINE_PRIVATE_TOKENS(_tokens,
(arnold)
(openvdbAsset)
((arnoldGlobal, "arnold:global:"))
);
// clang-format on

Expand Down Expand Up @@ -295,6 +296,11 @@ void _CheckForIntValue(const VtValue& value, F&& f)
}
}

void _RemoveArnoldGlobalPrefix(const TfToken& key, TfToken& key_new)
{
key_new = TfStringStartsWith(key, _tokens->arnoldGlobal) ? TfToken{key.GetText() + _tokens->arnoldGlobal.size()} : key;
}

} // namespace

std::mutex HdArnoldRenderDelegate::_mutexResourceRegistry;
Expand Down Expand Up @@ -378,8 +384,11 @@ const TfTokenVector& HdArnoldRenderDelegate::GetSupportedSprimTypes() const { re

const TfTokenVector& HdArnoldRenderDelegate::GetSupportedBprimTypes() const { return _SupportedBprimTypes(); }

void HdArnoldRenderDelegate::_SetRenderSetting(const TfToken& key, const VtValue& _value)
void HdArnoldRenderDelegate::_SetRenderSetting(const TfToken& _key, const VtValue& _value)
{
TfToken key;
_RemoveArnoldGlobalPrefix(_key, key);

// Currently usdview can return double for floats, so until it's fixed
// we have to convert doubles to float.
auto value = _value.IsHolding<double>() ? VtValue(static_cast<float>(_value.UncheckedGet<double>())) : _value;
Expand Down Expand Up @@ -441,15 +450,18 @@ void HdArnoldRenderDelegate::SetRenderSetting(const TfToken& key, const VtValue&
_SetRenderSetting(key, value);
}

VtValue HdArnoldRenderDelegate::GetRenderSetting(const TfToken& key) const
VtValue HdArnoldRenderDelegate::GetRenderSetting(const TfToken& _key) const
{
TfToken key;
_RemoveArnoldGlobalPrefix(_key, key);

if (key == str::t_enable_gpu_rendering) {
return VtValue(AiNodeGetStr(_options, str::render_device) == str::GPU);
} else if (key == str::t_enable_progressive_render) {
bool v = true;
AiRenderGetHintBool(str::progressive, v);
return VtValue(v);
} else if (key == str::progressive_min_AA_samples) {
} else if (key == str::t_progressive_min_AA_samples) {
int v = -4;
AiRenderGetHintInt(str::progressive_min_AA_samples, v);
return VtValue(v);
Expand Down
6 changes: 3 additions & 3 deletions render_delegate/render_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
/// @param key Name of the Render Setting to get.
/// @return Value of the Render Setting.
HDARNOLD_API
VtValue GetRenderSetting(const TfToken& key) const override;
VtValue GetRenderSetting(const TfToken& _key) const override;
/// Gets the list of Render Setting descriptors.
///
/// @return std::vector holding HdRenderSettingDescriptor for all the
Expand Down Expand Up @@ -198,7 +198,7 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
///
/// @return Name of the preferred material network.
HDARNOLD_API
TfToken GetMaterialNetworkSelector() const;
TfToken GetMaterialNetworkSelector() const override;
/// Suffixes Node names with the Render Delegate's paths.
///
/// @param name Name of the Node.
Expand Down Expand Up @@ -240,7 +240,7 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
HdArnoldRenderDelegate(const HdArnoldRenderDelegate&) = delete;
HdArnoldRenderDelegate& operator=(const HdArnoldRenderDelegate&) = delete;

void _SetRenderSetting(const TfToken& key, const VtValue& value);
void _SetRenderSetting(const TfToken& _key, const VtValue& value);

/// Mutex for the shared Resource Registry.
static std::mutex _mutexResourceRegistry;
Expand Down
2 changes: 1 addition & 1 deletion render_delegate/render_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class HdArnoldRenderPass : public HdRenderPass {
/// Returns true if the render has converged.
///
/// @return True if the render has converged.
bool IsConverged() const { return _isConverged; }
bool IsConverged() const override { return _isConverged; }

protected:
/// Executing the Render Pass.
Expand Down

0 comments on commit eeffc95

Please sign in to comment.