Skip to content

Commit

Permalink
Sanitize USD paths to prevent having dashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Sep 19, 2024
1 parent 0294cad commit 54bdf57
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 54bdf57

Please sign in to comment.