diff --git a/src/tinyusdz.cc b/src/tinyusdz.cc index 329da318..1c186996 100644 --- a/src/tinyusdz.cc +++ b/src/tinyusdz.cc @@ -648,9 +648,10 @@ bool LoadUSDAFromMemory(const uint8_t *addr, const size_t length, tinyusdz::StreamReader sr(addr, length, /* swap endian */ false); tinyusdz::usda::USDAReader reader(&sr); - + tinyusdz::usda::USDAReaderConfig config; config.strict_allowedToken_check = options.strict_allowedToken_check; + config.allow_unknown_apiSchema = !options.strict_apiSchema_check; reader.set_reader_config(config); reader.SetBaseDir(base_dir); @@ -987,6 +988,7 @@ bool LoadUSDCLayerFromMemory(const uint8_t *addr, const size_t length, usdc::USDCReaderConfig config; config.numThreads = options.num_threads; config.strict_allowedToken_check = options.strict_allowedToken_check; + config.allow_unknown_apiSchemas = !options.strict_apiSchema_check; usdc::USDCReader reader(&sr, config); if (!reader.ReadUSDC()) { @@ -1250,7 +1252,7 @@ int USDZResolveAsset(const char *asset_name, const std::vector &sea std::string asset_path = asset_name; - // Remove relative path prefix './' + // Remove relative path prefix './' if (tinyusdz::startsWith(asset_path, "./")) { asset_path = tinyusdz::removePrefix(asset_path, "./"); } @@ -1391,11 +1393,11 @@ bool SetupUSDZAssetResolution( // https://openusd.org/release/spec_usdz.html // // [x] Image: png, jpeg(jpg), exr - // + // // TODO(LTE): // - // [ ] USD: usda, usdc, usd - // [ ] Audio: m4a, mp3, wav + // [ ] USD: usda, usdc, usd + // [ ] Audio: m4a, mp3, wav if (!pusdzAsset) { return false; @@ -1406,9 +1408,9 @@ bool SetupUSDZAssetResolution( handler.resolve_fun = USDZResolveAsset; handler.size_fun = USDZSizeAsset; handler.read_fun = USDZReadAsset; - handler.write_fun = nullptr; + handler.write_fun = nullptr; handler.userdata = reinterpret_cast(const_cast(pusdzAsset)); - + resolver.register_asset_resolution_handler("png", handler); resolver.register_asset_resolution_handler("PNG", handler); resolver.register_asset_resolution_handler("JPG", handler); @@ -1417,7 +1419,7 @@ bool SetupUSDZAssetResolution( resolver.register_asset_resolution_handler("JPEG", handler); resolver.register_asset_resolution_handler("exr", handler); resolver.register_asset_resolution_handler("EXR", handler); - + return true; } diff --git a/src/usda-reader.cc b/src/usda-reader.cc index bc98e8d6..b2d6e302 100644 --- a/src/usda-reader.cc +++ b/src/usda-reader.cc @@ -1069,8 +1069,10 @@ class USDAReader::Impl { auto ret = ApiSchemaHandler(item.str()); if (ret) { apiSchemas.names.push_back({ret.value(), /* instanceName */""}); - } else { + } else if (_config.allow_unknown_apiSchema) { PUSH_WARN("(PrimMeta) " << ret.error()); + } else { + PUSH_ERROR_AND_RETURN("Unknown or invalid apiSchema: " + ret.error()); } } } else { diff --git a/tests/usda/apishcema-002.usda b/tests/usda/apishcema-002.usda new file mode 100644 index 00000000..0ca46331 --- /dev/null +++ b/tests/usda/apishcema-002.usda @@ -0,0 +1,16 @@ +#usda 1.0 +( + metersPerUnit = 1 + upAxis = "Y" + defaultPrim = "hello" +) + +def Cone "hello" +( + # would report warning for HoudiniViewportGuideAPI + prepend apiSchemas = ["HoudiniViewportGuideAPI", "GeomModelAPI", "MotionAPI", "ListAPI", "LightListAPI"] +) +{ + uniform token axis = "X" + double height = 1.2 +} diff --git a/tests/usdc/apischema-002.usdc b/tests/usdc/apischema-002.usdc new file mode 100644 index 00000000..bdb0fa7d Binary files /dev/null and b/tests/usdc/apischema-002.usdc differ