Skip to content

Commit

Permalink
Merge pull request #57 from Carifio24/usd-path
Browse files Browse the repository at this point in the history
Sanitize USD paths to prevent having dashes
  • Loading branch information
Carifio24 authored Sep 19, 2024
2 parents 0294cad + 54bdf57 commit ba0321c
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 ba0321c

Please sign in to comment.