Immersive Railroading

Immersive Railroading

3M Downloads

Incorrect physics on slopes. Help allowed?

CelestiaTheDryad opened this issue ยท 2 comments

commented

https://github.com/cam72cam/ImmersiveRailroading/blob/a8cca6a5573c9acff2d81a9f0aaab92e2ee3a028/src/main/java/cam72cam/immersiverailroading/physics/PhysicsAccummulator.java#L44-L46

The above calculation is incorrect physics for calculating acceleration due to gravity on slopes. This is easy to see as the slope becomes large. As the slope approaches 90 degrees (vertical), grade approaches infinity. By this calculation, the acceleration would approach infinity in the same manner when it should instead be limited to gravity (9.8 m/s^2).

I don't know exactly what code it should be replaced with, as I don't understand the relationship between real time, PhysicsAccumulator.accumulate(), and PhysicsAccumulator.getVelocity(). It should be replaced by something of the form: gravity * mass of train * sin(pitch).

Are you open to pull requests from outside sources? If so I'll set up a dev environment and get a full solution made out.

I noticed this when I built a rail with some steep grades (4%) and the trains I put on it were accelerating wildly (~6x more than real life) on default configs. This fit into other questions I had about train acceleration (seems fast overall) though this issue was the only one where I could find a clear enough issue to raise.

commented

All the physics are being reworked currently to be more realistic. However, if you can figure out a nice implementation of this, feel free to make a fork and submit a pull request. It would be very helpful and would ease some of our load.

commented

Implemented in #505.