Skip to content

Commit 3160d13

Browse files
committed
Fix incorrect material map passing
1 parent 8901b4f commit 3160d13

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build/
22
.vscode/
33
.vs/
4-
.idea/
4+
.idea/
5+
.clangd

cli/model_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void LoadMaterials(
3636
Scene& scene,
3737
tinygltf::Model& model,
3838
const std::string& base_path,
39-
std::vector<std::pair<const Material*, const SpectrumTexture*>> materials
39+
std::vector<std::pair<const Material*, const SpectrumTexture*>>& materials
4040
)
4141
{
4242
for (int32 i = 0; i < int32(model.materials.size()); i++)

src/util/image.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ Image1 ReadImage1(
2323
int32 components_per_pixel;
2424
float* data = stbi_loadf(filename.string().c_str(), &width, &height, &components_per_pixel, STBI_rgb_alpha);
2525

26-
if (!data || channel < 0 || channel >= components_per_pixel)
26+
if (!data)
2727
{
2828
std::cerr << "Failed to read image1: " << filename.string().c_str() << std::endl;
2929
return {};
3030
}
3131

32+
if (channel < 0 || channel >= components_per_pixel)
33+
{
34+
return {};
35+
}
36+
3237
constexpr int32 stride = STBI_rgb_alpha;
3338
Image1 image(width, height);
3439

0 commit comments

Comments
 (0)