@@ -488,8 +488,8 @@ class MeshtoUSDConverter(AssetConverterBase):
488488
489489 DEFAULT_BIND_APIS = [
490490 "MaterialBindingAPI" ,
491- # "PhysicsMeshCollisionAPI",
492- "PhysxDecompositionCollisionAPI " ,
491+ "PhysicsMeshCollisionAPI" ,
492+ "PhysxConvexDecompositionCollisionAPI " ,
493493 "PhysicsCollisionAPI" ,
494494 "PhysxCollisionAPI" ,
495495 "PhysicsMassAPI" ,
@@ -515,10 +515,10 @@ def __init__(
515515 if simulation_app is not None :
516516 self .simulation_app = simulation_app
517517
518- if "exit_close" in kwargs :
519- self .exit_close = kwargs .pop ("exit_close" )
520- else :
521- self .exit_close = True
518+ self . exit_close = kwargs . pop ( "exit_close" , True )
519+ self .physx_max_convex_hulls = kwargs .pop ("physx_max_convex_hulls" , 32 )
520+ self . physx_max_vertices = kwargs . pop ( "physx_max_vertices" , 16 )
521+ self .physx_max_voxel_res = kwargs . pop ( "physx_max_voxel_res" , 10000 )
522522
523523 self .usd_parms = dict (
524524 force_usd_conversion = force_usd_conversion ,
@@ -548,12 +548,12 @@ def __enter__(self):
548548 def __exit__ (self , exc_type , exc_val , exc_tb ):
549549 """Context manager exit, closes simulation app if created."""
550550 # Close the simulation app if it was created here
551- if hasattr (self , "app_launcher" ) and self .exit_close :
552- self .simulation_app .close ()
553-
554551 if exc_val is not None :
555552 logger .error (f"Exception occurred: { exc_val } ." )
556553
554+ if hasattr (self , "app_launcher" ) and self .exit_close :
555+ self .simulation_app .close ()
556+
557557 return False
558558
559559 def convert (self , urdf_path : str , output_file : str ):
@@ -601,18 +601,25 @@ def convert(self, urdf_path: str, output_file: str):
601601
602602 # Add convex decomposition collision and set ShrinkWrap.
603603 elif prim .GetName () == "mesh" :
604- approx_attr = prim .GetAttribute ("physics:approximation" )
605- if not approx_attr :
606- approx_attr = prim .CreateAttribute (
607- "physics:approximation" , Sdf .ValueTypeNames .Token
608- )
604+ approx_attr = prim .CreateAttribute (
605+ "physics:approximation" , Sdf .ValueTypeNames .Token
606+ )
609607 approx_attr .Set ("convexDecomposition" )
610608
611609 physx_conv_api = (
612610 PhysxSchema .PhysxConvexDecompositionCollisionAPI .Apply (
613611 prim
614612 )
615613 )
614+ physx_conv_api .GetMaxConvexHullsAttr ().Set (
615+ self .physx_max_convex_hulls
616+ )
617+ physx_conv_api .GetHullVertexLimitAttr ().Set (
618+ self .physx_max_vertices
619+ )
620+ physx_conv_api .GetVoxelResolutionAttr ().Set (
621+ self .physx_max_voxel_res
622+ )
616623 physx_conv_api .GetShrinkWrapAttr ().Set (True )
617624
618625 api_schemas = prim .GetMetadata ("apiSchemas" )
@@ -639,8 +646,8 @@ class PhysicsUSDAdder(MeshtoUSDConverter):
639646
640647 DEFAULT_BIND_APIS = [
641648 "MaterialBindingAPI" ,
642- # "PhysicsMeshCollisionAPI",
643- "PhysxDecompositionCollisionAPI " ,
649+ "PhysicsMeshCollisionAPI" ,
650+ "PhysxConvexDecompositionCollisionAPI " ,
644651 "PhysicsCollisionAPI" ,
645652 "PhysxCollisionAPI" ,
646653 "PhysicsRigidBodyAPI" ,
@@ -675,18 +682,23 @@ def convert(self, usd_path: str, output_file: str = None):
675682 if "lightfactory" in prim .GetName ().lower ():
676683 continue
677684
678- approx_attr = prim .GetAttribute (
679- "physics:approximation"
685+ approx_attr = prim .CreateAttribute (
686+ "physics:approximation" , Sdf . ValueTypeNames . Token
680687 )
681- if not approx_attr :
682- approx_attr = prim .CreateAttribute (
683- "physics:approximation" ,
684- Sdf .ValueTypeNames .Token ,
685- )
686688 approx_attr .Set ("convexDecomposition" )
689+
687690 physx_conv_api = PhysxSchema .PhysxConvexDecompositionCollisionAPI .Apply (
688691 prim
689692 )
693+ physx_conv_api .GetMaxConvexHullsAttr ().Set (
694+ self .physx_max_convex_hulls
695+ )
696+ physx_conv_api .GetHullVertexLimitAttr ().Set (
697+ self .physx_max_vertices
698+ )
699+ physx_conv_api .GetVoxelResolutionAttr ().Set (
700+ self .physx_max_voxel_res
701+ )
690702 physx_conv_api .GetShrinkWrapAttr ().Set (True )
691703
692704 rigid_body_api = UsdPhysics .RigidBodyAPI .Apply (prim )
@@ -790,18 +802,19 @@ def convert(self, urdf_path: str, output_file: str):
790802 with Usd .EditContext (stage , layer ):
791803 for prim in stage .Traverse ():
792804 if prim .GetName () == "collisions" :
793- approx_attr = prim .GetAttribute ("physics:approximation" )
794- if not approx_attr :
795- approx_attr = prim .CreateAttribute (
796- "physics:approximation" , Sdf .ValueTypeNames .Token
797- )
805+ approx_attr = prim .CreateAttribute (
806+ "physics:approximation" , Sdf .ValueTypeNames .Token
807+ )
798808 approx_attr .Set ("convexDecomposition" )
799809
800810 physx_conv_api = (
801811 PhysxSchema .PhysxConvexDecompositionCollisionAPI .Apply (
802812 prim
803813 )
804814 )
815+ physx_conv_api .GetMaxConvexHullsAttr ().Set (32 )
816+ physx_conv_api .GetHullVertexLimitAttr ().Set (16 )
817+ physx_conv_api .GetVoxelResolutionAttr ().Set (10000 )
805818 physx_conv_api .GetShrinkWrapAttr ().Set (True )
806819
807820 api_schemas = prim .GetMetadata ("apiSchemas" )
0 commit comments