Skip to content

Commit

Permalink
Merge pull request #75 from wsw0108/update
Browse files Browse the repository at this point in the history
Change: fix type of clearcoatNormalTexture, add missing mime type image/webp
  • Loading branch information
spnda authored Oct 16, 2024
2 parents 85c401f + 6a9dc9a commit 1ce0249
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion include/fastgltf/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ namespace fastgltf {
DDS = 4,
GltfBuffer = 5,
OctetStream = 6,
WEBP = 7,
};

FASTGLTF_EXPORT enum class AnimationInterpolation : std::uint8_t {
Expand Down Expand Up @@ -458,6 +459,7 @@ namespace fastgltf {
constexpr std::string_view mimeTypeDds = "image/vnd-ms.dds";
constexpr std::string_view mimeTypeGltfBuffer = "application/gltf-buffer";
constexpr std::string_view mimeTypeOctetStream = "application/octet-stream";
constexpr std::string_view mimeTypeWebp = "image/webp";

constexpr std::string_view getMimeTypeString(MimeType mimeType) noexcept {
switch (mimeType) {
Expand All @@ -473,6 +475,8 @@ namespace fastgltf {
return mimeTypeGltfBuffer;
case MimeType::OctetStream:
return mimeTypeOctetStream;
case MimeType::WEBP:
return mimeTypeWebp;
default:
return "";
}
Expand Down Expand Up @@ -1925,7 +1929,7 @@ namespace fastgltf {
Optional<TextureInfo> clearcoatTexture;
num clearcoatRoughnessFactor = 0.0f;
Optional<TextureInfo> clearcoatRoughnessTexture;
Optional<TextureInfo> clearcoatNormalTexture;
Optional<NormalTextureInfo> clearcoatNormalTexture;
};

FASTGLTF_EXPORT struct MaterialSheen {
Expand Down
9 changes: 6 additions & 3 deletions src/fastgltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ fg::MimeType fg::Parser::getMimeTypeFromString(std::string_view mime) {
case force_consteval<crc32c(mimeTypeOctetStream)>: {
return MimeType::OctetStream;
}
case force_consteval<crc32c(mimeTypeWebp)>: {
return MimeType::WEBP;
}
default: {
return MimeType::None;
}
Expand Down Expand Up @@ -2634,9 +2637,9 @@ fg::Error fg::Parser::parseMaterialExtensions(simdjson::dom::object &object, fas
return error;
}

TextureInfo clearcoatNormalTexture;
NormalTextureInfo clearcoatNormalTexture;
if (auto error = parseTextureInfo(clearcoatObject, "clearcoatNormalTexture",
&clearcoatNormalTexture, config.extensions); error ==
&clearcoatNormalTexture, config.extensions, TextureInfoType::NormalTexture); error ==
Error::None) {
clearcoat->clearcoatNormalTexture = std::move(clearcoatNormalTexture);
} else if (error != Error::MissingField) {
Expand Down Expand Up @@ -4735,7 +4738,7 @@ void fg::Exporter::writeMaterials(const Asset& asset, std::string& json) {
if (it->clearcoat->clearcoatNormalTexture.has_value()) {
if (json.back() != '{') json += ',';
json += "\"clearcoatNormalTexture\":";
writeTextureInfo(json, &it->clearcoat->clearcoatNormalTexture.value());
writeTextureInfo(json, &it->clearcoat->clearcoatNormalTexture.value(), TextureInfoType::NormalTexture);
}
json += '}';
}
Expand Down

0 comments on commit 1ce0249

Please sign in to comment.