message: fix sg::Texture2D logic when loading textures from files (fixes obj loader)
diff: @@ -65,7 +65,7 @@ namespace ospray {
  auto type = osprayTextureFormat(depth, channels, preferLinear);
  if (data == nullptr)
  - data = texelData->base();
  + data = texelData.get() != nullptr ? texelData->base() : nullptr;
  else {
  const auto dataSize = size.x * size.y * channels * depth;
  texelData =
  @@ -111,6 +111,7 @@ namespace ospray {
  ImageInput *in = ImageInput::open(fileName.str().c_str());
  if (!in) {
  std::cerr << "#osp:sg: failed to load texture '"+fileName.str()+"'" << std::endl;
  + tex.reset();
  } else {
  const ImageSpec &spec = in->spec();
  @@ -224,6 +225,7 @@ namespace ospray {
  }
  } catch(const std::runtime_error &e) {
  std::cerr << e.what() << std::endl;
  + tex.reset();
  }
  } else if (ext == "pfm") {
  try {
  @@ -297,6 +299,7 @@ namespace ospray {
  }
  } catch(const std::runtime_error &e) {
  std::cerr << e.what() << std::endl;
  + tex.reset();
  }
  }
  else {
  @@ -315,6 +318,7 @@ namespace ospray {
  tex->nearestFilter = nearestFilter;
  if (!pixels) {
  std::cerr << "#osp:sg: failed to load texture '"+fileName.str()+"'" << std::endl;
  + tex.reset();
  } else {
  tex->data = alignedMalloc(sizeof(unsigned char) * tex->size.x*tex->size.y*tex->channels*tex->depth);
  // convert pixels and flip image (because OSPRay's textures have the origin at the lower left corner)
  @@ -336,7 +340,10 @@ namespace ospray {
  }
  }
  #endif
  +
  + if (tex.get() != nullptr)
  textureCache[fileName.str()] = tex;
  +
  return tex;
  }
  