Physics patches
Moderator: OpenTTD Developers
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
Might I make some suggestings to raise the chance it'll be trunk one day?madman2003 wrote:Is there any reason why this isn't included in the main tree?
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.
If you've done all that, go to #openttd and bug a dev until he looks at the patches.
-- Michael Lutz
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.
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.
Actually, the current code correctly rounds those results to 42 and 3.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
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
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.
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
Probably yes, but you have some stray files in your patch, namely Makefile.config and rev.c.madman2003 wrote:This was made against the 32bpp tree, but i think it will work for the normal one too.
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
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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
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.
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...
Embrace your destiny...
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.
Removed because faulty patch.
Last edited by madman2003 on 09 Apr 2006 20:49, edited 1 time in total.
Who is online
Users browsing this forum: hpfx and 19 guests