Source Code Project Mantis - FSSCP
View Issue Details
0002325FSSCPgameplaypublic2010-10-09 00:382012-12-08 22:58
Assigned ToValathil 
PlatformOSOS Version
Product Version3.6.12 RC4 
Target VersionFixed in Version 
Summary0002325: View shakes in 'show ship' flag when far from the mission origin
DescriptionWhen using a cockpit in the show ship mode the view is fine near the origin of the mission but the farther from the origin you get the worse the shaking gets. At less than 7500 meters the shaking is very slight but gets worse with the greater distance. The relationship appears to be linear. The amount of shaking in this mode appears to be ship dependent, that is some ships shake worse than others.
Additional InformationThe mission shows the ulysses demonstrating the problem (of course the 'show ship' flag must be checked on the ulysses table entry to see the effect. After the auto pilot the ship is at 30,000 meters from the origin and the shaking is evident.
TagsNo tags attached.
related to 0001704closed  Large coordiante values result in ships not being where they apper to be. 
related to 0000527resolved taylor Objects Wiggle [significantly] on their position. 
Attached Files? autopilotA.fs2 (8,768) 2010-10-10 08:47
patch wobblybgone.patch (1,572) 2012-11-29 11:56
patch wobblybgonev2.patch (3,841) 2012-12-02 20:11
patch wobblybgonev3.patch (5,061) 2012-12-03 08:44
patch wobblybgonev4.patch (6,017) 2012-12-03 12:22

2012-11-27 01:58   
This is another manifestation of the large coordinate problem. It's not fixable without a serious redesign, per earlier comments in 0001704.
2012-11-27 23:35   
Upon further investigation (and emails with Taylor), this may be fixable without requiring a complete overhaul of the system. The technique should be the same as the one used to fix 0000527: the math should be done explicitly in the gr_opengl function, using GLdoubles, rather than through the vecmat library function using floats. See revision 3376 for the gory details.

Assigning to Valathil in hopes that he can use this information to fix the bug.
2012-11-28 16:07   
Of course, "The Wizard will fix it!" -_-
2012-11-29 00:50   
Of course. :) And it should be a pretty simple fix, too. Stand by for an email.
2012-11-29 11:56   
Attached a patch with fix.
2012-12-02 00:08   
Uh, okay, this isn't the right approach. Instead of resetting the camera to 0 and drawing the view from there, you should draw the view from the ship location, but while using the GLdouble vector manipulation. Consult the email I sent you about the approach Taylor took.
2012-12-02 10:46   
So fixing the bug by doing the render by excluding the inaccurate float computation all together instead of doing senseless increased accuracy computation which always has the same result cause the cockpit doesn't move is the wrong approach?
2012-12-02 10:52   
Yeah, I'm with Valathil on this. V's solution obviously works and looks correct, so even if taylor would have done it differently, it doesn't matter.
2012-12-02 13:35   
No, it does matter. It's not enough that the patch appears to fix the problem; the patch must also follow the existing framework and design of the code. There are reasons why Taylor implemented the fix he did.

In Valathil's patch, the entire context of the ship_render function is saved, altered, and later restored. That's a hackish approach, and it could have undetectable knock-on effects to the rest of the function. What needs to be done is to implement the fix in the actual place the cockpit is rendered. (This would appear to be the if() block with the comment "//For in-ship cockpits. This is admittedly something of a hack".)
2012-12-02 16:40   
(Last edited: 2012-12-03 08:45)
There is no way to fix the wobbly otherwise. If you look at external camera the whole ship is shaking at about 1 pixel amplitude. If you go into the cockpit of course that is going to be magnified. You cant have the camera at a different spot than the EXACT SAME position of the ship and not have floating point problems. 527 was a float instability of the camera direction not a ship position issue which this is. You want to position something very precise into an increasingly large grid the further you go out. You cant do that. There's a difference between the accuracy of a calculation WHILE calculating and the accuracy of the RESULT. 527 was about the Forward vector in gluLookAt beeing calculated inaccurately because doing (a + b - b) in float when b is much larger than a is BAD. This is similar BUT different since a+b is done in the game THEN sent to gl and the -b is done entirely in GL which is ALWAYS done in float even if you send it in double. The only way to go around it is to eliminate the superfluous +b-b step which is by resetting the camerapos to the model eye offset and drawing the ship at 0. I tried to make it less hackish in v2 of the patch by changing the ship_get_eye function and using model_render instead of ship_render but that's as good as it gets.

FYI Model Cockpits have the same problem but i'm too tired to fix them today.
EDIT: Patch v3 with model cockpit fix is attached

2012-12-03 11:38   
wobblybgonev3 looks good to me, and after taking more than a cursory look at the specific code, it's probably the best (and only real) way to fix it too without larger code changes.

If I had any complaint it's with the bit in freespace.cpp. It could really use a little bit of organizational cleanup and commenting so that it's a little more obvious what is going on and why. Makes it easier for other coders to understand and would help prevent someone from removing or changing that code later on.
2012-12-03 12:22   
v4 is attached with move to own function and comments.
2012-12-08 22:58   
Fix committed to trunk@9413.

Issue History
2010-10-09 00:38originNew Issue
2010-10-10 08:47originFile Added: autopilotA.fs2
2012-11-27 01:57Goober5000Relationship addedrelated to 0001704
2012-11-27 01:58Goober5000Note Added: 0014199
2012-11-27 01:58Goober5000Statusnew => closed
2012-11-27 01:58Goober5000Resolutionopen => not fixable
2012-11-27 23:33Goober5000Relationship addedrelated to 0000527
2012-11-27 23:35Goober5000Note Added: 0014201
2012-11-27 23:35Goober5000Assigned To => Valathil
2012-11-27 23:35Goober5000Statusclosed => assigned
2012-11-27 23:35Goober5000Resolutionnot fixable => reopened
2012-11-28 16:07ValathilNote Added: 0014220
2012-11-29 00:50Goober5000Note Added: 0014224
2012-11-29 11:56ValathilFile Added: wobblybgone.patch
2012-11-29 11:56ValathilNote Added: 0014228
2012-11-29 11:56ValathilStatusassigned => code review
2012-12-02 00:08Goober5000Note Added: 0014249
2012-12-02 10:46ValathilNote Added: 0014258
2012-12-02 10:52The_ENote Added: 0014259
2012-12-02 13:35Goober5000Note Added: 0014260
2012-12-02 16:40ValathilNote Added: 0014262
2012-12-02 16:55ValathilNote Edited: 0014262bug_revision_view_page.php?bugnote_id=14262#r263
2012-12-02 19:25ValathilNote Edited: 0014262bug_revision_view_page.php?bugnote_id=14262#r264
2012-12-02 20:11ValathilFile Added: wobblybgonev2.patch
2012-12-02 20:16ValathilNote Edited: 0014262bug_revision_view_page.php?bugnote_id=14262#r265
2012-12-02 20:17ValathilNote Edited: 0014262bug_revision_view_page.php?bugnote_id=14262#r266
2012-12-02 22:03ValathilNote Edited: 0014262bug_revision_view_page.php?bugnote_id=14262#r267
2012-12-03 08:44ValathilFile Added: wobblybgonev3.patch
2012-12-03 08:45ValathilNote Edited: 0014262bug_revision_view_page.php?bugnote_id=14262#r270
2012-12-03 11:38taylorNote Added: 0014273
2012-12-03 12:22ValathilFile Added: wobblybgonev4.patch
2012-12-03 12:22ValathilNote Added: 0014274
2012-12-08 22:58ZacamChangeset attached => fs2open trunk r9413
2012-12-08 22:58ZacamNote Added: 0014373
2012-12-08 22:58ZacamStatuscode review => resolved