Skip to content

Commit 1ed629e

Browse files
authored
Merge pull request #183 from KhronosGroup/fix-no-image-reference
Don't make textures if there is no image backing it
2 parents 08447f5 + fccd8a5 commit 1ed629e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Change Log
66
##### Fixes :wrench:
77
* Upgrade to Draco 1.2.5 [#179](https://github.com/KhronosGroup/COLLADA2GLTF/pull/179)
88
* Fix issue with exporting normal maps [#182](https://github.com/KhronosGroup/COLLADA2GLTF/pull/182)
9+
* Fix issue with COLLADA textures with no backing image [#183](https://github.com/KhronosGroup/COLLADA2GLTF/pull/183)
910

1011
### v2.1.1 - 2018-04-04
1112

src/COLLADA2GLTFWriter.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,15 @@ void packColladaColor(COLLADAFW::Color color, float* packArray) {
883883
}
884884

885885
GLTF::Texture* COLLADA2GLTF::Writer::fromColladaTexture(const COLLADAFW::EffectCommon* effectCommon, COLLADAFW::SamplerID samplerId) {
886-
GLTF::Texture* texture = new GLTF::Texture();
887886
const COLLADAFW::SamplerPointerArray& samplers = effectCommon->getSamplerPointerArray();
888887
COLLADAFW::Sampler* colladaSampler = (COLLADAFW::Sampler*)samplers[samplerId];
889-
GLTF::Image* image = _images[colladaSampler->getSourceImage()];
888+
std::map<COLLADAFW::UniqueId, GLTF::Image*>::iterator findImage = _images.find(colladaSampler->getSourceImage());
889+
if (findImage == _images.end()) {
890+
return NULL;
891+
}
892+
GLTF::Texture* texture = new GLTF::Texture();
893+
GLTF::Image* image = findImage->second;
894+
890895
texture->source = image;
891896
texture->sampler = _asset->globalSampler;
892897
return texture;

0 commit comments

Comments
 (0)