Skip to content

Commit c70b867

Browse files
authored
Merge pull request #520 from gonsolo/dim
Remove a warning about dim 0.
2 parents 970fee0 + 82efbd5 commit c70b867

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

src/pbrt/util/sampling.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,23 +1653,25 @@ class PiecewiseLinear2D {
16531653
float param_weight[2 * ArraySize];
16541654
uint32_t slice_offset = 0u;
16551655

1656-
for (size_t dim = 0; dim < Dimension; ++dim) {
1657-
if (m_param_size[dim] == 1) {
1658-
param_weight[2 * dim] = 1.f;
1659-
param_weight[2 * dim + 1] = 0.f;
1660-
continue;
1661-
}
1656+
if constexpr (Dimension > 0) {
1657+
for (size_t dim = 0; dim < Dimension; ++dim) {
1658+
if (m_param_size[dim] == 1) {
1659+
param_weight[2 * dim] = 1.f;
1660+
param_weight[2 * dim + 1] = 0.f;
1661+
continue;
1662+
}
16621663

1663-
uint32_t param_index = FindInterval(m_param_size[dim], [&](uint32_t idx) {
1664-
return m_param_values[dim][idx] <= param[dim];
1665-
});
1664+
uint32_t param_index = FindInterval(m_param_size[dim], [&](uint32_t idx) {
1665+
return m_param_values[dim][idx] <= param[dim];
1666+
});
16661667

1667-
float p0 = m_param_values[dim][param_index],
1668-
p1 = m_param_values[dim][param_index + 1];
1668+
float p0 = m_param_values[dim][param_index],
1669+
p1 = m_param_values[dim][param_index + 1];
16691670

1670-
param_weight[2 * dim + 1] = Clamp((param[dim] - p0) / (p1 - p0), 0.f, 1.f);
1671-
param_weight[2 * dim] = 1.f - param_weight[2 * dim + 1];
1672-
slice_offset += m_param_strides[dim] * param_index;
1671+
param_weight[2 * dim + 1] = Clamp((param[dim] - p0) / (p1 - p0), 0.f, 1.f);
1672+
param_weight[2 * dim] = 1.f - param_weight[2 * dim + 1];
1673+
slice_offset += m_param_strides[dim] * param_index;
1674+
}
16731675
}
16741676

16751677
/* Compute linear interpolation weights */

0 commit comments

Comments
 (0)