Elvas Tower: Possible Issue with Articulated Wagons with 0 Axles - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Possible Issue with Articulated Wagons with 0 Axles Rate Topic: -----

#1 User is offline   pschlik 

  • Conductor
  • Group: Status: Active Member
  • Posts: 333
  • Joined: 04-March 15
  • Gender:Male
  • Simulator:OpenRails - Unstable
  • Country:

Posted 19 August 2023 - 07:59 PM

While experimenting with the 48 foot spine cars included in the TrainSimulations SP Shasta Route, I noticed some alignment issues between the articulated units going around corners. Some of these units (specifically the 2nd and 4th units in each 5 unit set) have no wheels or bogies in the model, but the way they were going around corners made it appear that some dummy bogies were being added to the train car. Upon investigation, I see that there is a function in TrainCar.cs, SetUpWheelsArticulation, to add dummy bogies to the very ends of the wagon if they are otherwise missing, but I could tell the dummy bogies were not being placed at the very end of the wagons. If a wagon fails to process axle locations, the bogies are then assumed to have some other default spacing partway along the wagon (which is exactly what I was observing). Oddly enough, it also seems that a failure to detect axles will prevent the Z offset of CentreOfGravity from applying, preventing the player from changing the longitudinal offset of a 0-axle wagon (this is particularly annoying for articulated trainsets, where changing the Z offset is often key in getting the correct alignment).

Turns out, SetUpWheelsArticulation is only called for wagons that already have 2 or more axles, which is not the case for these particular wagons.
            //Certain locomotives are testing as articulated wagons for some reason.
            if (WagonType != WagonTypes.Engine)
                if (WheelAxles.Count >= 2) // <-- This prevents 0-axle train cars from having articulation set up
                    if (articulatedFront || articulatedRear)
                    {
                        WheelAxlesLoaded = true;
                        SetUpWheelsArticulation(carIndex);
                    }


I changed this check to also pass for things with no wheels...
            //Certain locomotives are testing as articulated wagons for some reason.
            if (WagonType != WagonTypes.Engine)
                if (WheelAxles.Count >= 0) // <-- Will now process things with 0 axles, could probably remove this line entirely
                    if (articulatedFront || articulatedRear)
                    {
                        WheelAxlesLoaded = true;
                        SetUpWheelsArticulation(carIndex);
                    }

And the articulation works suddenly. Here are a couple of screenshots on very tight curves for comparison. Top screenshot is with my modification to the code allowing articulation with 0 axles, bottom is the original.
https://i.imgur.com/pSRqxra.jpg
https://i.imgur.com/XSYCEmE.jpg

As I hope is pretty clear, excluding this 0-axle train car from the articulation fix leads to a much worse-looking result than applying the articulation fix to it. I see no downsides, and this was trivially easy to fix.

Now this isn't a part of the code I know much about, and before I go off and make this official I wanted to see if anyone knew why the articulation fix would only happen for train cars that already have 2 wheels at least (this would be a train car that has a bogie at one end of the 3D model, but not at the other end-these work flawlessly as-is). This bit of code has been there for years, so I doubt anyone would know off the top of their head, but I'm not seeing any justification for this beyond the original writer failing to consider that someone could simulate an articulated train car by giving it no axles and no bogies. Maybe there's something out there that has 0 axles and 0 bogies in the 3D model but would rather use the default bogie location than be articulated...but I doubt that considering the only example of 0 axle stuff I ever see is articulated cars.

#2 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,868
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 26 August 2023 - 01:09 AM

Some great detective work here. Thanks Phillip.

I've added the for-unstable label so this change is now part of the Unstable Version. Perhaps we should leave it there for a while to see if anyone spots bad behaviour.

#3 User is offline   pschlik 

  • Conductor
  • Group: Status: Active Member
  • Posts: 333
  • Joined: 04-March 15
  • Gender:Male
  • Simulator:OpenRails - Unstable
  • Country:

Posted 26 August 2023 - 08:31 AM

View Postcjakeman, on 26 August 2023 - 01:09 AM, said:

Some great detective work here. Thanks Phillip.

I've added the for-unstable label so this change is now part of the Unstable Version. Perhaps we should leave it there for a while to see if anyone spots bad behaviour.


Agreed, there's so much stuff out there that anything could happen, best to give folks some time to try out their trains and see what difference this makes.

#4 User is online   Weter 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 6,945
  • Joined: 01-June 20
  • Gender:Not Telling
  • Simulator:ORTS
  • Country:

Posted 27 August 2023 - 03:05 AM

Hello.
Imo, every car needs at least two axles (either, virtual, or real), for standing on rails stable.
For articulated cars, these axles are pivots of "own", and adjacent bogeys, defining curve negotiation.
So every of these pivots follows track vector, while train is moving, and defines position of car's body.
Please, think about that.

#5 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,000
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 01 September 2023 - 05:06 AM

A Spanish trainsimmer pointed me out this:
Attached Image: BrokenTalgo.jpg
This occurs after the code change described in this thread.
The code change consisted in removing a condition that executes some code lines only if there are two or more axles.
I locally tried reintroducing the condition and modifying it, that is executing the code lines only if there is a number of axles different from 1. This way the problem disappeared.
The trainset may be freely downloaded from here http://www.trensim.c...ct=view&id=1276 .
This post is a suggestion to Phillip.

#6 User is offline   pschlik 

  • Conductor
  • Group: Status: Active Member
  • Posts: 333
  • Joined: 04-March 15
  • Gender:Male
  • Simulator:OpenRails - Unstable
  • Country:

Posted 01 September 2023 - 06:07 AM

Interesting, preventing the code from executing if there is exactly 1 axle in the model would still solve the issue with the articulated intermodal cars, so that's a good compromise. But I'm surprised a model of a power car would be built with only one axle in the 3D model. I'll have to take a look at that to understand what is going on.

#7 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,000
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 01 September 2023 - 08:47 AM

Phillip, what looks like a single locomotive has been modeled as a wagon + an engine + a wagon. The consist has these three elements.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users