Skip to content

Commit

Permalink
Merge pull request #2863 from dgovil/cleanup-arkit-checks
Browse files Browse the repository at this point in the history
Cleanup arkit checks

(Internal change: 2309099)
  • Loading branch information
pixar-oss committed Dec 15, 2023
2 parents 14b5d32 + c3ad8dd commit 15ebd4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 45 deletions.
2 changes: 1 addition & 1 deletion pxr/usd/bin/usdchecker/usdchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main():
'aggregate stages.')
parser.add_argument('--arkit', dest='arkit', action='store_true',
help='Check if the given USD stage is compatible with '
'ARKit\'s initial implementation of usdz. These assets '
'RealityKit\'s implementation of USDZ as of 2023. These assets '
'operate under greater constraints that usdz files for '
'more general in-house uses, and this option attempts '
'to ensure that these constraints are met.')
Expand Down
58 changes: 14 additions & 44 deletions pxr/usd/usdUtils/complianceChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

from __future__ import print_function

import warnings

from pxr import Ar

from pxr.UsdUtils.constantsGroup import ConstantsGroup
Expand Down Expand Up @@ -718,7 +720,9 @@ class ARKitPrimTypeChecker(BaseRuleChecker):
'Mesh', 'Sphere', 'Cube', 'Cylinder', 'Cone',
'Capsule', 'GeomSubset', 'Points',
'SkelRoot', 'Skeleton', 'SkelAnimation',
'BlendShape', 'SpatialAudio')
'BlendShape', 'SpatialAudio', 'PhysicsScene',
'Preliminary_ReferenceImage', 'Preliminary_Text',
'Preliminary_Trigger')

@staticmethod
def GetDescription():
Expand All @@ -733,16 +737,18 @@ def __init__(self, verbose, consumerLevelChecks, assetLevelChecks):

def CheckPrim(self, prim):
self._Msg("Checking prim <%s>." % prim.GetPath())
if prim.GetTypeName() not in \
ARKitPrimTypeChecker._allowedPrimTypeNames:
if (
(prim.GetTypeName() not in ARKitPrimTypeChecker._allowedPrimTypeNames) and
(not prim.GetTypeName().startswith("RealityKit"))
):
self._AddFailedCheck("Prim <%s> has unsupported type '%s'." %
(prim.GetPath(), prim.GetTypeName()))

class ARKitShaderChecker(BaseRuleChecker):
@staticmethod
def GetDescription():
return "Shader nodes must have \"id\" as the implementationSource, " \
"with id values that begin with \"Usd*\". Also, shader inputs "\
"with id values that begin with \"Usd*|ND_*\". Also, shader inputs "\
"with connections must each have a single, valid connection " \
"source."

Expand Down Expand Up @@ -773,7 +779,8 @@ def CheckPrim(self, prim):
not (shaderId in [NodeTypes.UsdPreviewSurface,
NodeTypes.UsdUVTexture,
NodeTypes.UsdTransform2d] or
shaderId.startswith(NodeTypes.UsdPrimvarReader)) :
shaderId.startswith(NodeTypes.UsdPrimvarReader) or
shaderId.startswith("ND_")) :
self._AddFailedCheck("Shader <%s> has unsupported info:id '%s'."
% (prim.GetPath(), shaderId))

Expand Down Expand Up @@ -863,44 +870,6 @@ def CheckZipFile(self, zipFile, packagePath):
"unknown or unsupported extension '%s'." %
(fileName, packagePath, fileExt))

class ARKitRootLayerChecker(BaseRuleChecker):
@staticmethod
def GetDescription():
return "The root layer of the package must be a usdc file and " \
"must not include any external dependencies that participate in "\
"stage composition."

def __init__(self, verbose, consumerLevelChecks, assetLevelChecks):
super(ARKitRootLayerChecker, self).__init__(verbose,
consumerLevelChecks,
assetLevelChecks)

def CheckStage(self, usdStage):
usedLayers = usdStage.GetUsedLayers()
# This list excludes any session layers.
usedLayersOnDisk = [i for i in usedLayers if i.realPath]
if len(usedLayersOnDisk) > 1:
self._AddFailedCheck("The stage uses %s layers. It should "
"contain a single usdc layer to be compatible with ARKit's "
"implementation of usdz." % len(usedLayersOnDisk))

rootLayerRealPath = usdStage.GetRootLayer().realPath
if rootLayerRealPath.endswith(".usdz"):
# Check if the root layer in the package is a usdc.
from pxr import Usd
zipFile = Usd.ZipFile.Open(rootLayerRealPath)
if not zipFile:
self._AddError("Could not open package at path '%s'." %
resolvedPath)
return
fileNames = zipFile.GetFileNames()
if not fileNames[0].endswith(".usdc"):
self._AddFailedCheck("First file (%s) in usdz package '%s' "
"does not have the .usdc extension." % (fileNames[0],
rootLayerRealPath))
elif not rootLayerRealPath.endswith(".usdc"):
self._AddFailedCheck("Root layer of the stage '%s' does not "
"have the '.usdc' extension." % (rootLayerRealPath))

class ComplianceChecker(object):
""" A utility class for checking compliance of a given USD asset or a USDZ
Expand Down Expand Up @@ -938,7 +907,8 @@ def GetARKitRules(skipARKitRootLayerCheck=False):
ARKitFileExtensionChecker,
ARKitPackageEncapsulationChecker]
if not skipARKitRootLayerCheck:
arkitRules.append(ARKitRootLayerChecker)
warnings.warn("skipARKitRootLayerCheck is no longer supported. It will be removed in a future version",
PendingDeprecationWarning)
return arkitRules

@staticmethod
Expand Down

0 comments on commit 15ebd4b

Please sign in to comment.