@@ -49,7 +49,7 @@ public class OpenPLXUnityMapper
4949 Options = options ;
5050
5151 InteractionMapper = new InteractionMapper ( Data ) ;
52- VehicleMapper = new VehicleMapper ( Data ) ;
52+ VehicleMapper = new VehicleMapper ( Data , InteractionMapper ) ;
5353 SensorMapper = new SensorMapper ( Data ) ;
5454 }
5555
@@ -851,6 +851,8 @@ GameObject MapSystem( openplx.Physics3D.System system )
851851 {
852852 var s = MapSystemPass1 ( system ) ;
853853 MapSystemPass2 ( system ) ;
854+ // This method performs actual mapping of previously discovered tracks and is not recursive
855+ VehicleMapper . MapTrackSystems ( ) ;
854856 MapSystemPass3 ( system ) ;
855857 MapSystemPass4 ( system ) ;
856858 MapSystemPass5 ( system ) ;
@@ -884,14 +886,8 @@ GameObject MapSystemPass1( openplx.Physics3D.System system )
884886 Data . MaterialCache [ geometry . material ( ) ] = Data . DefaultMaterial ;
885887 }
886888 }
887- foreach ( var trackSystem in system . getNonReferenceValues < openplx . Vehicles . Tracks . System > ( ) ) {
888- if ( trackSystem . belt ( ) . link_description ( ) is openplx . Vehicles . Tracks . BoxLinkDescription desc ) {
889- var mat = desc . contact_geometry ( ) . material ( ) ;
890- if ( ! Data . MaterialCache . ContainsKey ( mat ) ) {
891- Data . MaterialCache [ mat ] = InteractionMapper . MapMaterial ( mat ) ;
892- }
893- }
894- }
889+
890+ VehicleMapper . MapSystemPass1 ( system ) ;
895891
896892 return s ;
897893 }
@@ -919,6 +915,8 @@ void MapSystemPass2( openplx.Physics3D.System system )
919915
920916 foreach ( var terr in system . getNonReferenceValues < openplx . Terrain . Terrain > ( ) )
921917 Utils . AddChild ( s , MapTerrain ( terr ) , Data . ErrorReporter , terr ) ;
918+
919+ VehicleMapper . MapSystemPass2 ( system ) ;
922920 }
923921
924922 void MapSystemPass3 ( openplx . Physics3D . System system )
@@ -928,9 +926,6 @@ void MapSystemPass3( openplx.Physics3D.System system )
928926 foreach ( var subSystem in system . getNonReferenceValues < openplx . Physics3D . System > ( ) )
929927 MapSystemPass3 ( subSystem ) ;
930928
931- foreach ( var trackSystem in system . getNonReferenceValues < openplx . Vehicles . Tracks . System > ( ) )
932- VehicleMapper . MapTrackSystem ( trackSystem ) ;
933-
934929 foreach ( var mateConnector in system . getNonReferenceValues < openplx . Physics3D . Interactions . MateConnector > ( ) )
935930 InteractionMapper . MapMateConnector ( mateConnector ) ;
936931
@@ -946,8 +941,7 @@ void MapSystemPass4( openplx.Physics3D.System system )
946941 foreach ( var subSystem in system . getNonReferenceValues < openplx . Physics3D . System > ( ) )
947942 MapSystemPass4 ( subSystem ) ;
948943
949- if ( system is openplx . Vehicles . Suspensions . SingleMate . Base suspension )
950- VehicleMapper . MapSingleMateSuspensionOnto ( suspension , s ) ;
944+ VehicleMapper . MapSystemPass4 ( system ) ;
951945
952946 foreach ( var lidar in system . getNonReferenceValues < openplx . Sensors . LidarLogic > ( ) )
953947 Utils . AddChild ( s , SensorMapper . MapLidar ( lidar ) , Data . ErrorReporter , lidar ) ;
@@ -985,11 +979,7 @@ void MapSystemPass5( openplx.Physics3D.System system )
985979 foreach ( var subSystem in system . getNonReferenceValues < openplx . Physics3D . System > ( ) )
986980 MapSystemPass5 ( subSystem ) ;
987981
988- if ( system is openplx . Vehicles . Steering . Kinematic . Base steering )
989- VehicleMapper . MapSteeringOnto ( steering , s ) ;
990-
991- foreach ( var wheel in system . getNonReferenceValues < openplx . Vehicles . Wheels . ElasticWheel > ( ) )
992- VehicleMapper . MapElasticWheel ( wheel ) ;
982+ VehicleMapper . MapSystemPass5 ( system ) ;
993983 }
994984 }
995985}
0 commit comments