Skip to content

Commit

Permalink
Make materials unique
Browse files Browse the repository at this point in the history
Convert materials to ordered set instead of list to prevent duplication and .mjcf compile errors
  • Loading branch information
AlexKaravaev committed Mar 14, 2024
1 parent 98b7a4d commit 85f689f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion obj2mjcf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def process_obj(filename: Path, args: Args) -> None:
break
sub_mtls = [smtl]
mtls = [Material.from_string(smtl)]


mtls = list(dict.fromkeys(mtls))

# Delete any MTL files that were created during trimesh processing, if any.
for file in [
x for x in work_dir.glob("**/*") if x.is_file() and "material_0" in x.name
Expand Down
2 changes: 1 addition & 1 deletion obj2mjcf/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from obj2mjcf import constants


@dataclass
@dataclass(frozen=True)
class Material:
"""A convenience class for constructing MuJoCo materials from MTL files."""

Expand Down

0 comments on commit 85f689f

Please sign in to comment.