Skip to content

Commit

Permalink
Fix material:binding:PURPOSE decompose.
Browse files Browse the repository at this point in the history
More expressive error report for Asset size error(size/width/height).
USDZ.
  • Loading branch information
syoyo committed Apr 6, 2024
1 parent e74d1d8 commit b622782
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/prim-reconstruct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2159,13 +2159,13 @@ bool ReconstructMaterialBindingProperties(
PUSH_ERROR_AND_RETURN(fmt::format("`{}` must be a Relationship", prop.first));
}

std::string purpose_name = removePrefix(prop.first, kMaterialBindingCollection + std::string(":"));
std::string purpose_name = removePrefix(prop.first, kMaterialBinding + std::string(":"));
if (purpose_name.empty()) {
PUSH_ERROR_AND_RETURN("empty PURPOSE is not allowed for 'mateirial:binding:'");
}
std::vector<std::string> names = split(purpose_name, ":");
if (names.size() > 1) {
PUSH_ERROR_AND_RETURN("PURPOSE must not have nested namespaces for 'mateirial:binding'");
PUSH_ERROR_AND_RETURN(fmt::format("PURPOSE `{}` must not have nested namespaces for 'mateirial:binding'", purpose_name));
}
value::token mat_purpose = value::token(names[0]);

Expand Down
15 changes: 8 additions & 7 deletions src/tinyusdz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,9 @@ bool LoadUSDZFromMemory(const uint8_t *addr, const size_t length,
return false;
}

if (asset_size > (options.max_allowed_asset_size_in_mb * 1024 * 1024)) {
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, "Asset file size too large.");
if (asset_size > (options.max_allowed_asset_size_in_mb * 1024ull * 1024ull)) {
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, fmt::format("Asset no[{}] file size too large. {} bytes (max_allowed_asset_size {})",
i, asset_size, options.max_allowed_asset_size_in_mb * 1024ull * 1024ull));
}

DCOUT("Image asset size: " << asset_size);
Expand All @@ -537,26 +538,26 @@ bool LoadUSDZFromMemory(const uint8_t *addr, const size_t length,

if (info) {
if (info->width == 0) {
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, "Image has zero width.");
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, fmt::format("Assset no[{}] Image has zero width.", i));
}

if (info->width > options.max_image_width) {
PUSH_ERROR_AND_RETURN_TAG(
kTagUSDZ, fmt::format("Asset no[{}] Image width too large", i));
kTagUSDZ, fmt::format("Asset no[{}] Image width too large. {} (max_image_width {})", i, info->width, options.max_image_width));
}

if (info->height == 0) {
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, "Image has zero height.");
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, fmt::format("Asset no[{}] Image has zero height.", i));
}

if (info->height > options.max_image_height) {
PUSH_ERROR_AND_RETURN_TAG(
kTagUSDZ,
fmt::format("Asset no[{}] Image height too large", i));
fmt::format("Asset no[{}] Image height too large. {} (max_image_height {})", i, info->height, options.max_image_height));
}

if (info->channels == 0) {
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, "Image has zero channels.");
PUSH_ERROR_AND_RETURN_TAG(kTagUSDZ, fmt::format("Asset no[{}] Image has zero channels.", i));
}

if (info->channels > options.max_image_channels) {
Expand Down

0 comments on commit b622782

Please sign in to comment.