mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-04-22 05:59:55 +08:00
Merge branch 'master' of github.com:syoyo/tinygltf
This commit is contained in:
commit
ec45334d3d
16
tiny_gltf.h
16
tiny_gltf.h
@ -2712,12 +2712,14 @@ static void UpdateImageObject(Image &image, std::string &baseDir, int index,
|
|||||||
void *user_data = nullptr) {
|
void *user_data = nullptr) {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string ext;
|
std::string ext;
|
||||||
|
// If image has uri, use it it as a filename
|
||||||
// If image have uri. Use it it as a filename
|
|
||||||
if (image.uri.size()) {
|
if (image.uri.size()) {
|
||||||
filename = GetBaseFilename(image.uri);
|
filename = GetBaseFilename(image.uri);
|
||||||
ext = GetFilePathExtension(filename);
|
ext = GetFilePathExtension(filename);
|
||||||
|
}
|
||||||
|
else if (image.bufferView != -1) {
|
||||||
|
//If there's no URI and the data exists in a buffer,
|
||||||
|
//don't change properties or write images
|
||||||
} else if (image.name.size()) {
|
} else if (image.name.size()) {
|
||||||
ext = MimeToExt(image.mimeType);
|
ext = MimeToExt(image.mimeType);
|
||||||
// Otherwise use name as filename
|
// Otherwise use name as filename
|
||||||
@ -2729,7 +2731,7 @@ static void UpdateImageObject(Image &image, std::string &baseDir, int index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If callback is set, modify image data object
|
// If callback is set, modify image data object
|
||||||
if (*WriteImageData != nullptr) {
|
if (*WriteImageData != nullptr && !filename.empty()) {
|
||||||
std::string uri;
|
std::string uri;
|
||||||
(*WriteImageData)(&baseDir, &filename, &image, embedImages, user_data);
|
(*WriteImageData)(&baseDir, &filename, &image, embedImages, user_data);
|
||||||
}
|
}
|
||||||
@ -6500,6 +6502,7 @@ static void SerializeExtensionMap(const ExtensionMap &extensions, json &o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SerializeGltfAccessor(Accessor &accessor, json &o) {
|
static void SerializeGltfAccessor(Accessor &accessor, json &o) {
|
||||||
|
if (accessor.bufferView >= 0)
|
||||||
SerializeNumberProperty<int>("bufferView", accessor.bufferView, o);
|
SerializeNumberProperty<int>("bufferView", accessor.bufferView, o);
|
||||||
|
|
||||||
if (accessor.byteOffset != 0.0)
|
if (accessor.byteOffset != 0.0)
|
||||||
@ -7452,9 +7455,8 @@ bool TinyGLTF::WriteGltfSceneToStream(Model *model, std::ostream &stream,
|
|||||||
json image;
|
json image;
|
||||||
|
|
||||||
std::string dummystring = "";
|
std::string dummystring = "";
|
||||||
// UpdateImageObject need baseDir but only uses it if embededImages is
|
// UpdateImageObject need baseDir but only uses it if embeddedImages is
|
||||||
// enable, since we won't write separte images when writing to a stream we
|
// enabled, since we won't write separate images when writing to a stream we
|
||||||
// use a dummystring
|
|
||||||
UpdateImageObject(model->images[i], dummystring, int(i), false,
|
UpdateImageObject(model->images[i], dummystring, int(i), false,
|
||||||
&this->WriteImageData, this->write_image_user_data_);
|
&this->WriteImageData, this->write_image_user_data_);
|
||||||
SerializeGltfImage(model->images[i], image);
|
SerializeGltfImage(model->images[i], image);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user