Physics patches

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

Is there any reason why this isn't included in the main tree?
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Post by Michi_cc »

madman2003 wrote:Is there any reason why this isn't included in the main tree?
Might I make some suggestings to raise the chance it'll be trunk one day?

Post your patch on http://bugs.openttd.org/ as patch to be proofread.

Try to make some smaller pices.
  • Split road vehicles and trains into seperate patches.
  • Make another patch for real_airspeed.
  • An finally a patch for those GUI and code improvements.
Repeat: make small pieces, increases the chance of inclusion a lot.

If you've done all that, go to #openttd and bug a dev until he looks at the patches.

-- Michael Lutz
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

Michi_cc wrote: If you've done all that, go to #openttd and bug a dev until he looks at the patches.

-- Michael Lutz
err... until he says "Stop buggiiiing meeeeeee" like the ork grunt in Warcraft 2 :D
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

There is one major problem stopping the inclusion (i had a talk with peter1138):

max speed calculation accuracy, it's done with integer calculations, but deviding a km/h by 3.6 will give inaccurate results:

example:

150/3.6=41 --> it should be 41.6666666
10/3.6=2 --> should be 2.777777777

There are maybe more conversions which cause similar problems, together they create low accuracy. The solution is to increase the scale during certain calculations so accuracy is improved, not a 100% sure (because of almost no c knowledge) what is possible without going into the floating point realm.

Floating point is a no go, because different computers make slightly different calculations, which won't work in multiplayer.
Last edited by madman2003 on 06 Apr 2006 07:02, edited 2 times in total.
User avatar
Brianetta
Tycoon
Tycoon
Posts: 2567
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

You can make use of fixed point by multiplying all numbers not used as multipliers by (ten raised to the number of decimal places required) and then dividing the ultimate result by that number.
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Post by Michi_cc »

madman2003 wrote:There is one major problem stopping the inclusion (i had a talk with peter1138):

max speed calculation accuracy, it's done with integer calculations, but deviding a km/h by 3.6 will give inaccurate results:

example:

150/3.6=41 --> it should be 41.6666666
10/3.6=2 --> should be 2.777777777
Actually, the current code correctly rounds those results to 42 and 3.
Of course, if that's not enough accuracy, fixed-point arithmetics would be an option.

Two links:
http://www.bookofhook.com/Article/GameD ... dPoin.html
http://hometown.aol.com/form1/fixed.htm.

-- Michael Lutz
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

I had something similar in mind (working on a *10^-5 (or higher) scale, essentially moving the . to get better accuracy).
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

I've modified the patch to become a bit more accurate (as far as i could see from the sourcecode). Only train stuff is modified, because the realistic truck acceleration seems ok (i don't understand some of what's happening there yet though). Moving up the resolution made some values too big for int32, so i used int64, i'd be curious to hear how it performs on a 32bits system. Compare the beheaviour of this and the original patch if you can. The airplane speed thing is gone, because it has nothing to do with this patch.

This was made against the 32bpp tree, but i think it will work for the normal one too.
Attachments
physics_modified_08-04-2006.patch
Modified patch against r4297 of the 32bpp branch.
(130.36 KiB) Downloaded 277 times
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Post by Michi_cc »

madman2003 wrote:This was made against the 32bpp tree, but i think it will work for the normal one too.
Probably yes, but you have some stray files in your patch, namely Makefile.config and rev.c.

And you should check if r4322 has any effect on the patch. Looking at that revision I'd say no, but I can be wrong.


-- Michael Lutz
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

I'll look at that too, found out it is a bit broken against current trunk. I'm working on it :-)
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

This should apply to current trunk.
Attachments
physics_modified_trunk_08-04-2006.patch
Should apply to current trunk.
(127.45 KiB) Downloaded 289 times
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

Discovered a minor flaw, will try to fix.

This will take longer, the problem with realistic truck accel on manually stopping the vehicle will be instant and later it will resume at old speed.
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

There turned out to be more problems, so i fixed them. This should apply against current svn, let me know if there any speed displaying issues (there was a change in trunk to km/h instead of several conversions from mph to km/h), masses of vehicles that seem too large, stuff like that. And if it works for you too.
Attachments
physics_modified_trunk_09-04-2006.patch
Physics patches. Should be more accurate now (the train part). Compiles against current revision 4332.
(121.58 KiB) Downloaded 361 times
Nappe1
Traffic Manager
Traffic Manager
Posts: 175
Joined: 19 Jan 2004 17:25
Location: kotka or Savitaipale, Finland
Contact:

Post by Nappe1 »

Madman2003: acording to TortoiseSVN, any of your diff files aren't really diff files... :/

I would so much to use this patch with Subsidiaries in our private server, so could you check that you are doing right kind of diff files please?
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

They were normal diff's, this is a so called svn diff. Also did a few minor cleanups were certain things were only a space different.
Attachments
openttd_physics_modified_trunk_09-04-2006.diff
svn diff against r4336.
(117.17 KiB) Downloaded 297 times
Nappe1
Traffic Manager
Traffic Manager
Posts: 175
Joined: 19 Jan 2004 17:25
Location: kotka or Savitaipale, Finland
Contact:

Post by Nappe1 »

madman2003 wrote:They were normal diff's, this is a so called svn diff. Also did a few minor cleanups were certain things were only a space different.
thanks. :)
User avatar
Thief^
Route Supervisor
Route Supervisor
Posts: 469
Joined: 10 Oct 2004 00:11

Post by Thief^ »

As I understand it, a ".patch" file (created by the diff tool) contains the changes between 2 files or directories, and a ".diff" file (created by svn diff) contains the difference between a file / directory and a specific svn revision of that file / directory. I know that the .diff and .patch extensions are interchangable, it just seems the two tools default to the extensions I mentioned above.

I also noticed that your patch file contains the name of the directory that the files should be in, "./openttd-svn/trunk/", so it probably wouldn't have worked for anyone keeping it in a different directory. This is probably true for all patch files. By contrast a diff file doesn't store the name of the directory the files are in, only the svn-url, so it can by applied to any folder that the correct svn branch is checked out into.
Melt with the Shadows,
Embrace your destiny...
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

Found a small bug, the vehicle weight when looking at a running road vehicle (not in the buying screen) was much too high.
Attachments
openttd_physics_modified_trunk_09-04-2006.diff
Fixed a small bug, weight displayed of a running road vehicle was much too high.
(117.18 KiB) Downloaded 292 times
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

I expected people to know how to use patch, patch -p2 would have worked fine. But svn diff's are easier to use and maintain i just discovered :-)
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

Some minor things(some strings) have already been merged into trunk and the patch will continue to break in the future probably.

Removed because faulty patch.
Last edited by madman2003 on 09 Apr 2006 20:49, edited 1 time in total.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Ahrefs [Bot] and 14 guests