Skip to content

Commit

Permalink
Minor cleanup in hdPrman
Browse files Browse the repository at this point in the history
- Fixed warnings that caused strict builds to fail
- Guarded some debug code with a TfDebug::IsEnabled check
  to avoid for-loops that do nothing otherwise.
- Avoid unnecessary copies of values from VtValue

(Internal change: 2049404)
  • Loading branch information
sunyab authored and pixar-oss committed Mar 20, 2020
1 parent 54446e1 commit 4f4d841
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
48 changes: 28 additions & 20 deletions third_party/renderman-23/plugin/hdPrman/lightFilterUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,15 @@ HdPrmanLightFilterPopulateParams(
pval = sceneDelegate->GetLightParamValue(filterPath,
_tokens->falloffKnots);
if (pval.IsHolding<std::vector<float>>()) {
const std::vector<float> v =
const std::vector<float>& v =
pval.UncheckedGet<std::vector<float>>();
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" falloff:knots size %d\n", (int)(v.size()));
for(int ii = 0; ii < v.size(); ii++)
if (TfDebug::IsEnabled(HDPRMAN_LIGHT_FILTER_LINKING)) {
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2d: %f\n", ii, v[ii]);
.Msg(" falloff:knots size %d\n", (int)(v.size()));
for(size_t ii = 0; ii < v.size(); ii++)
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2zu: %f\n", ii, v[ii]);
}
filter->params.SetFloatArray(RtUString("falloff_Knots"),
&v[0], v.size());
// XXX -- extra param to hold the size of the spline
Expand All @@ -659,11 +661,13 @@ HdPrmanLightFilterPopulateParams(
if (pval.IsHolding<std::vector<float>>()) {
const std::vector<float>& v =
pval.UncheckedGet<std::vector<float>>();
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" falloff:floats size %d\n", (int)(v.size()));
for(int ii = 0; ii < v.size(); ii++)
if (TfDebug::IsEnabled(HDPRMAN_LIGHT_FILTER_LINKING)) {
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2d: %f\n", ii, v[ii]);
.Msg(" falloff:floats size %d\n", (int)(v.size()));
for(size_t ii = 0; ii < v.size(); ii++)
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2zu: %f\n", ii, v[ii]);
}
filter->params.SetFloatArray(RtUString("falloff_Floats"),
&v[0], v.size());
}
Expand All @@ -680,13 +684,15 @@ HdPrmanLightFilterPopulateParams(
pval = sceneDelegate->GetLightParamValue(filterPath,
_tokens->colorRampKnots);
if (pval.IsHolding<std::vector<float>>()) {
const std::vector<float> v =
const std::vector<float>& v =
pval.UncheckedGet<std::vector<float>>();
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" colorRamp:knots size %d\n", (int)(v.size()));
for(int ii = 0; ii < v.size(); ii++)
if (TfDebug::IsEnabled(HDPRMAN_LIGHT_FILTER_LINKING)) {
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2d: %f\n", ii, v[ii]);
.Msg(" colorRamp:knots size %d\n", (int)(v.size()));
for(size_t ii = 0; ii < v.size(); ii++)
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2zu: %f\n", ii, v[ii]);
}
filter->params.SetFloatArray(RtUString("colorRamp_Knots"),
&v[0], v.size());
// XXX -- extra param to hold the size of the spline
Expand All @@ -695,14 +701,16 @@ HdPrmanLightFilterPopulateParams(
pval = sceneDelegate->GetLightParamValue(filterPath,
_tokens->colorRampColors);
if (pval.IsHolding<std::vector<GfVec3f>>()) {
const std::vector<GfVec3f> v =
const std::vector<GfVec3f>& v =
pval.UncheckedGet<std::vector<GfVec3f>>();
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" colorRamp:colors size %d\n", (int)(v.size()));
for(int ii = 0; ii < v.size(); ii++)
if (TfDebug::IsEnabled(HDPRMAN_LIGHT_FILTER_LINKING)) {
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2d: %f %f %f\n",
ii, v[ii][0], v[ii][1], v[ii][2]);
.Msg(" colorRamp:colors size %d\n", (int)(v.size()));
for(size_t ii = 0; ii < v.size(); ii++)
TF_DEBUG(HDPRMAN_LIGHT_FILTER_LINKING)
.Msg(" %2zu: %f %f %f\n",
ii, v[ii][0], v[ii][1], v[ii][2]);
}
filter->params.SetColorArray(RtUString("colorRamp_Colors"),
reinterpret_cast<const RtColorRGB*>(&v[0]), v.size());
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/renderman-23/plugin/hdPrman/volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ HdPrman_Volume::_ConvertGeometry(HdPrman_Context *context,
// here without reading directly from the grid which would require
// opening the file (linking with openvdb) or getting the vdb ptr from
// houdini (linking with the hdk)
for (int i = 0; i < fields.size(); ++i)
for (size_t i = 0; i < fields.size(); ++i)
{
HdVolumeFieldDescriptor const& field = fields[i];
RtUString fieldName = RtUString(field.fieldName.GetText());
Expand Down

0 comments on commit 4f4d841

Please sign in to comment.