Skip to content

Commit bac5a1d

Browse files
committed
Fix bug in bump map introduced when adapting to last version of OIIO
1 parent 4930c1c commit bac5a1d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

include/slg/imagemap/imagemap.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <Imath/half.h>
2323

24+
#include <initializer_list>
2425
#include <string>
2526
#include <limits>
2627
#include <unordered_map>
@@ -60,12 +61,17 @@ class ImageMapPixel : std::array<T, CHANNELS> {
6061
public:
6162
using BaseType = std::array<T, CHANNELS>;
6263

63-
ImageMapPixel(T v = 0) : BaseType{v} {}
64+
explicit ImageMapPixel(T v = 0) : BaseType{v} {}
6465

65-
ImageMapPixel(T cs[CHANNELS]) {
66+
explicit ImageMapPixel(T cs[CHANNELS]) {
6667
std::copy(std::begin(cs), std::end(cs), this->begin());
6768
}
6869

70+
explicit ImageMapPixel(std::initializer_list<T> init) {
71+
assert(init.size() == CHANNELS);
72+
std::copy(init.begin(), init.end(), this->begin());
73+
}
74+
6975
~ImageMapPixel() { }
7076

7177
u_int GetChannelCount() const { return CHANNELS; }

src/slg/imagemap/imagemap.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,9 @@ ImageMapStorageUPtr ImageMapStorageImpl<T, CHANNELS>::SelectChannel(
712712
std::vector<ImageMapPixel<T, 3>> newPixels;
713713
newPixels.reserve(pixelCount);
714714
for (auto& p: pixels) {
715-
newPixels.emplace_back(p[0]);
715+
newPixels.emplace_back(
716+
(std::initializer_list<T>){p[0], p[1], p[2]}
717+
);
716718
}
717719
return std::make_unique<ImageMapStorageImpl<T, 3>>(
718720
width, height, wrapType, filterType, std::move(newPixels)
@@ -896,7 +898,7 @@ void ImageMap::Init(
896898

897899
ImageSpec config;
898900
config.attribute ("oiio:UnassociatedAlpha", 1);
899-
std::unique_ptr<ImageInput> in(ImageInput::open(resolvedFileName, &config));
901+
auto in = ImageInput::open(resolvedFileName, &config);
900902

901903
if (!in)
902904
throw runtime_error(

0 commit comments

Comments
 (0)