Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize USD paths to prevent having dashes #57

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion glue_ar/common/usd_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def __init__(self, filepath: str):
self._create_stage(filepath)
self._material_map: Dict[MaterialInfo, UsdShade.Shader] = {}

def _sanitize(self, identifier: str) -> str:
return identifier.replace("-", "_")

def _create_stage(self, filepath: str):
self.stage = Usd.Stage.CreateNew(filepath)
self.stage = Usd.Stage.CreateNew(self._sanitize(filepath))

# TODO: Do we want to make changing this an option?
UsdGeom.SetStageUpAxis(self.stage, UsdGeom.Tokens.y)
Expand Down Expand Up @@ -63,6 +66,7 @@ def add_mesh(self,
for other meshes that we create.
"""
identifier = identifier or unique_id()
identifier = self._sanitize(identifier)
count = self._mesh_counts[identifier]
xform_key = f"{self.default_prim_key}/xform_{identifier}_{count}"
UsdGeom.Xform.Define(self.stage, xform_key)
Expand All @@ -87,6 +91,7 @@ def add_translated_reference(self,
identifier: Optional[str] = None) -> UsdGeom.Mesh:
prim = mesh.GetPrim()
identifier = identifier or unique_id()
identifier = self._sanitize(identifier)
count = self._mesh_counts[identifier]
xform_key = f"{self.default_prim_key}/xform_{identifier}_{count}"
UsdGeom.Xform.Define(self.stage, xform_key)
Expand Down