@@ -57,6 +57,8 @@ public class FreightAnimations
57
57
public bool DoubleStacker ;
58
58
public MSTSWagon Wagon ;
59
59
public List < LoadData > LoadDataList ;
60
+ public const float EmptySuperpositionTolerance = 0.10f ;
61
+ public const float FullSuperpositionTolerance = 0.2f ;
60
62
61
63
// additions to manage consequences of variable weight on friction and brake forces
62
64
public float EmptyORTSDavis_A = - 9999 ;
@@ -317,7 +319,7 @@ public void Load(MSTSWagon wagon, string loadFilePath, LoadPosition loadPosition
317
319
}
318
320
else
319
321
{
320
- container . LoadFromContainerFile ( loadFilePath ) ;
322
+ container . LoadFromContainerFile ( loadFilePath , wagon . Simulator . BasePath + @"\trains\trainset\" ) ;
321
323
ContainerManager . LoadedContainers . Add ( loadFilePath , container ) ;
322
324
}
323
325
Vector3 offset = new Vector3 ( 0 , 0 , 0 ) ;
@@ -487,66 +489,68 @@ public void UpdateEmptyFreightAnims(float containerLengthM)
487
489
if ( EmptyAnimations . Count == 0 )
488
490
{
489
491
if ( anim . LoadPosition == LoadPosition . Above ) return ;
490
- if ( containerLengthM >= LoadingAreaLength - 0.02 ) return ;
491
- Vector3 offset = anim . Offset ;
492
- switch ( anim . LoadPosition )
492
+ if ( containerLengthM < LoadingAreaLength - EmptySuperpositionTolerance )
493
493
{
494
- case LoadPosition . Center :
495
- if ( ( LoadingAreaLength + 0.02f - anim . Container . LengthM ) / 2 > 6.10f )
496
- {
497
- // one empty area behind, one in front
498
- var emptyLength = ( LoadingAreaLength - anim . Container . LengthM ) / 2 ;
499
- offset . Z = Offset . Z + LoadingAreaLength / 2 - ( LoadingAreaLength - anim . Container . LengthM ) / 4 ;
500
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Rear , offset , emptyLength ) ) ;
501
- offset . Z = Offset . Z - LoadingAreaLength / 2 + ( LoadingAreaLength - anim . Container . LengthM ) / 4 ;
502
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Front , offset , emptyLength ) ) ;
503
- }
504
- break ;
505
- case LoadPosition . CenterRear :
506
- // one empty area in front, check if enough place for the rear one
507
- offset = Offset ;
508
- offset . Z -= LoadingAreaLength / 4 ;
509
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , DoubleStacker ? LoadPosition . CenterFront : LoadPosition . Front ,
510
- offset , LoadingAreaLength / 2 ) ) ;
511
- if ( LoadingAreaLength / 2 + 0.01f - containerLengthM > 6.10 )
512
- {
513
- offset . Z = Offset . Z + anim . Container . LengthM / 2 + LoadingAreaLength / 4 ;
514
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Rear , offset ,
515
- LoadingAreaLength / 2 - containerLengthM ) ) ;
516
- }
517
- break ;
518
- case LoadPosition . CenterFront :
519
- offset = Offset ;
520
- offset . Z += LoadingAreaLength / 4 ;
521
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , DoubleStacker ? LoadPosition . CenterRear : LoadPosition . Rear ,
522
- offset , LoadingAreaLength / 2 ) ) ;
523
- if ( LoadingAreaLength / 2 + 0.01f - containerLengthM > 6.10 )
524
- {
525
- offset . Z = Offset . Z - containerLengthM / 2 - LoadingAreaLength / 4 ;
526
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Front , offset ,
527
- LoadingAreaLength / 2 - containerLengthM ) ) ;
528
- }
529
- break ;
530
- case LoadPosition . Rear :
531
- if ( LoadingAreaLength + 0.02f - containerLengthM > 6.10f )
532
- {
494
+ Vector3 offset = anim . Offset ;
495
+ switch ( anim . LoadPosition )
496
+ {
497
+ case LoadPosition . Center :
498
+ if ( ( LoadingAreaLength + EmptySuperpositionTolerance - anim . Container . LengthM ) / 2 > Container . Length20ftM )
499
+ {
500
+ // one empty area behind, one in front
501
+ var emptyLength = ( LoadingAreaLength - anim . Container . LengthM ) / 2 ;
502
+ offset . Z = Offset . Z + LoadingAreaLength / 2 - ( LoadingAreaLength - anim . Container . LengthM ) / 4 ;
503
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Rear , offset , emptyLength ) ) ;
504
+ offset . Z = Offset . Z - LoadingAreaLength / 2 + ( LoadingAreaLength - anim . Container . LengthM ) / 4 ;
505
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Front , offset , emptyLength ) ) ;
506
+ }
507
+ break ;
508
+ case LoadPosition . CenterRear :
509
+ // one empty area in front, check if enough place for the rear one
533
510
offset = Offset ;
534
- offset . Z -= anim . Container . LengthM / 2 ;
535
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Front , offset ,
536
- LoadingAreaLength - containerLengthM ) ) ;
537
- }
538
- break ;
539
- case LoadPosition . Front :
540
- if ( LoadingAreaLength + 0.02f - containerLengthM > 6.10f )
541
- {
511
+ offset . Z -= LoadingAreaLength / 4 ;
512
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , DoubleStacker ? LoadPosition . CenterFront : LoadPosition . Front ,
513
+ offset , LoadingAreaLength / 2 ) ) ;
514
+ if ( LoadingAreaLength / 2 + 0.01f - containerLengthM > 6.10 )
515
+ {
516
+ offset . Z = Offset . Z + anim . Container . LengthM / 2 + LoadingAreaLength / 4 ;
517
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Rear , offset ,
518
+ LoadingAreaLength / 2 - containerLengthM ) ) ;
519
+ }
520
+ break ;
521
+ case LoadPosition . CenterFront :
542
522
offset = Offset ;
543
- offset . Z += containerLengthM / 2 ;
544
- EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Rear , offset ,
545
- LoadingAreaLength - containerLengthM ) ) ;
546
- }
547
- break ;
548
- default :
549
- break ;
523
+ offset . Z += LoadingAreaLength / 4 ;
524
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , DoubleStacker ? LoadPosition . CenterRear : LoadPosition . Rear ,
525
+ offset , LoadingAreaLength / 2 ) ) ;
526
+ if ( LoadingAreaLength / 2 + EmptySuperpositionTolerance - containerLengthM > Container . Length20ftM )
527
+ {
528
+ offset . Z = Offset . Z - containerLengthM / 2 - LoadingAreaLength / 4 ;
529
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Front , offset ,
530
+ LoadingAreaLength / 2 - containerLengthM ) ) ;
531
+ }
532
+ break ;
533
+ case LoadPosition . Rear :
534
+ if ( LoadingAreaLength + EmptySuperpositionTolerance - containerLengthM > Container . Length20ftM )
535
+ {
536
+ offset = Offset ;
537
+ offset . Z -= anim . Container . LengthM / 2 ;
538
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Front , offset ,
539
+ LoadingAreaLength - containerLengthM ) ) ;
540
+ }
541
+ break ;
542
+ case LoadPosition . Front :
543
+ if ( LoadingAreaLength + EmptySuperpositionTolerance - containerLengthM > Container . Length20ftM )
544
+ {
545
+ offset = Offset ;
546
+ offset . Z += containerLengthM / 2 ;
547
+ EmptyAnimations . Add ( new FreightAnimationDiscrete ( this , null , LoadPosition . Rear , offset ,
548
+ LoadingAreaLength - containerLengthM ) ) ;
549
+ }
550
+ break ;
551
+ default :
552
+ break ;
553
+ }
550
554
}
551
555
}
552
556
else
@@ -688,8 +692,8 @@ public void UpdateEmptyFreightAnims(float containerLengthM)
688
692
emptyAnim . Offset . Z += multiplier * anim . LoadingAreaLength / 2 ;
689
693
emptyAnim . LinkedIntakePoint . OffsetM = - emptyAnim . Offset . Z ;
690
694
emptyAnim . LoadingAreaLength -= anim . LoadingAreaLength ;
691
- if ( Math . Abs ( emptyAnim . Offset . Z - Offset . Z ) < 0.02f ) emptyAnim . LoadPosition = LoadPosition . Center ;
692
- else if ( Math . Abs ( emptyAnim . LoadingAreaLength + anim . LoadingAreaLength - LoadingAreaLength / 2 ) < 0.02f )
695
+ if ( Math . Abs ( emptyAnim . Offset . Z - Offset . Z ) < FullSuperpositionTolerance ) emptyAnim . LoadPosition = LoadPosition . Center ;
696
+ else if ( Math . Abs ( emptyAnim . LoadingAreaLength + anim . LoadingAreaLength - LoadingAreaLength / 2 ) < FullSuperpositionTolerance )
693
697
emptyAnim . LoadPosition = anim . LoadPosition == LoadPosition . Front ? LoadPosition . CenterFront : LoadPosition . CenterRear ;
694
698
continue ;
695
699
}
0 commit comments