Skip to content

Commit

Permalink
fix backslash texture paths in mtllib not being loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisenwave committed Feb 6, 2021
1 parent 2e2561e commit 82bef62
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "voxelio/stringmanip.hpp"
#include "voxelio/voxelio.hpp"

#include <algorithm>

namespace obj2voxel {

// INPUT ===============================================================================================================
Expand Down Expand Up @@ -119,7 +121,9 @@ std::vector<f32> loadStl(const std::string &inFile)

std::optional<Texture> loadTexture(const std::string &name, const std::string &material)
{
std::optional<FileInputStream> stream = FileInputStream::open(name);
std::string sanitizedName = name;
std::replace(sanitizedName.begin(), sanitizedName.end(), '\\', '/');
std::optional<FileInputStream> stream = FileInputStream::open(sanitizedName);
if (not stream.has_value()) {
VXIO_LOG(WARNING, "Failed to open texture file \"" + name + "\" of material \"" + material + '"');
return std::nullopt;
Expand Down

0 comments on commit 82bef62

Please sign in to comment.