Skip to content

Commit

Permalink
Change: Use defaulted MimeType for every data source type
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Mar 6, 2024
1 parent 30a6ab9 commit 3352fd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 6 additions & 6 deletions include/fastgltf/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,34 +1406,34 @@ namespace fastgltf {
namespace sources {
struct BufferView {
std::size_t bufferViewIndex;
MimeType mimeType;
MimeType mimeType = MimeType::None;
};

struct URI {
std::size_t fileByteOffset;
fastgltf::URI uri;
MimeType mimeType;
MimeType mimeType = MimeType::None;
};

struct Array {
StaticVector<std::uint8_t> bytes;
MimeType mimeType;
MimeType mimeType = MimeType::None;
};

/** @note This type is not used by the fastgltf parser and is only used for exporting. Use sources::Array instead when importing intead. */
struct Vector {
std::vector<std::uint8_t> bytes;
MimeType mimeType;
MimeType mimeType = MimeType::None;
};

struct CustomBuffer {
CustomBufferId id;
MimeType mimeType;
MimeType mimeType = MimeType::None;
};

struct ByteView {
span<const std::byte> bytes;
MimeType mimeType;
MimeType mimeType = MimeType::None;
};

struct Fallback {};
Expand Down
7 changes: 2 additions & 5 deletions src/fastgltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ fg::Expected<fg::DataSource> fg::Parser::loadFileFromUri(URIView& uri) const noe
if (config.mapCallback != nullptr) {
auto info = config.mapCallback(static_cast<std::uint64_t>(length), config.userPointer);
if (info.mappedMemory != nullptr) {
const sources::CustomBuffer customBufferSource = { info.customId, MimeType::None };
const sources::CustomBuffer customBufferSource = { info.customId };
file.read(reinterpret_cast<char*>(info.mappedMemory), length);
if (config.unmapCallback != nullptr) {
config.unmapCallback(&info, config.userPointer);
Expand All @@ -743,7 +743,6 @@ fg::Expected<fg::DataSource> fg::Parser::loadFileFromUri(URIView& uri) const noe
file.read(reinterpret_cast<char*>(data.data()), length);
sources::Array vectorSource = {
std::move(data),
MimeType::None,
};
return Expected<DataSource> { std::move(vectorSource) };
}
Expand Down Expand Up @@ -1840,7 +1839,6 @@ fg::Error fg::Parser::parseBuffers(simdjson::dom::array& buffers, Asset& asset)
sources::URI filePath;
filePath.fileByteOffset = 0;
filePath.uri = uriView;
filePath.mimeType = MimeType::None;
buffer.data = std::move(filePath);
}
} else if (bufferIndex == 0 && !std::holds_alternative<std::monostate>(glbBuffer)) {
Expand Down Expand Up @@ -2231,7 +2229,6 @@ fg::Error fg::Parser::parseImages(simdjson::dom::array& images, Asset& asset) {
sources::URI filePath;
filePath.fileByteOffset = 0;
filePath.uri = uriView;
filePath.mimeType = MimeType::None;
image.data = std::move(filePath);
}

Expand Down Expand Up @@ -3985,7 +3982,7 @@ fg::Expected<fg::Asset> fg::Parser::loadGltfBinary(GltfDataBuffer* buffer, fs::p
if (config.unmapCallback != nullptr) {
config.unmapCallback(&info, config.userPointer);
}
glbBuffer = sources::CustomBuffer{info.customId, MimeType::None};
glbBuffer = sources::CustomBuffer{info.customId};
}
} else {
StaticVector<std::uint8_t> binaryData(binaryChunk.chunkLength);
Expand Down

0 comments on commit 3352fd5

Please sign in to comment.