2018-05-26 07:08 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0002325FSSCPgameplaypublic2012-12-08 22:58
Reporterorigin 
Assigned ToValathil 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionreopened 
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.
Attached Files
  • ? file icon autopilotA.fs2 (8,768 bytes) 2010-10-10 08:47
  • patch file icon wobblybgone.patch (1,572 bytes) 2012-11-29 11:56 -
    Index: code/freespace2/freespace.cpp
    ===================================================================
    --- code/freespace2/freespace.cpp	(revision 9384)
    +++ code/freespace2/freespace.cpp	(working copy)
    @@ -3670,7 +3670,15 @@
     	if(draw_viewer_last && Viewer_obj)
     	{
     		gr_post_process_save_zbuffer();
    +		vec3d Viewer_pos_save = Viewer_obj->pos;
    +		vec3d cockpit_eye_pos;
    +		matrix dummy;
    +		Viewer_obj->pos = vmd_zero_vector;
    +		ship_get_eye(&cockpit_eye_pos, &dummy, Viewer_obj);
    +		vm_vec_scale(&cockpit_eye_pos, -1.0f);
    +		Viewer_obj->pos = cockpit_eye_pos;
     		ship_render(Viewer_obj);
    +		Viewer_obj->pos = Viewer_pos_save;
     	}
     
     
    Index: code/ship/ship.cpp
    ===================================================================
    --- code/ship/ship.cpp	(revision 9384)
    +++ code/ship/ship.cpp	(working copy)
    @@ -5745,8 +5745,8 @@
     	bool is_first_stage_arrival = false;
     	bool show_thrusters = (shipp->flags2 & SF2_NO_THRUSTERS) == 0;
     	dock_function_info dfi;
    +	uint render_flags = MR_NORMAL;
     
    -
     #if 0
     	// show target when attacking big ship
     	vec3d temp, target;
    @@ -5810,7 +5810,9 @@
     			gr_end_proj_matrix();
     
     			gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    -			gr_set_view_matrix(&Eye_position, &Eye_matrix);
    +			gr_set_view_matrix(&vmd_zero_vector, &Eye_matrix);
    +			render_flags |= MR_LOCK_DETAIL;
    +			model_set_detail_level(0);
     		}
     	}
     
    @@ -5848,7 +5850,7 @@
     
     		ship_model_start(obj);
     
    -		uint render_flags = MR_NORMAL;
    +		
     	#ifndef NDEBUG
     		if(Show_paths || Show_fpaths){
     			render_flags |= MR_BAY_PATHS;
    
    patch file icon wobblybgone.patch (1,572 bytes) 2012-11-29 11:56 +
  • patch file icon wobblybgonev2.patch (3,841 bytes) 2012-12-02 20:11 -
    Index: code/freespace2/freespace.cpp
    ===================================================================
    --- code/freespace2/freespace.cpp	(revision 9388)
    +++ code/freespace2/freespace.cpp	(working copy)
    @@ -3670,7 +3670,22 @@
     	if(draw_viewer_last && Viewer_obj)
     	{
     		gr_post_process_save_zbuffer();
    -		ship_render(Viewer_obj);
    +		vec3d cockpit_eye_pos;
    +		matrix dummy;
    +		ship_get_eye(&cockpit_eye_pos, &dummy, Viewer_obj, true, true);
    +		gr_end_view_matrix();
    +		
    +		gr_end_proj_matrix();
    +		gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    +		gr_set_view_matrix(&cockpit_eye_pos, &Eye_matrix);
    +		
    +		model_set_detail_level(0);
    +		model_render(Ship_info[Ships[Viewer_obj->instance].ship_info_index].model_num, &Viewer_obj->orient, &vmd_zero_vector, MR_NORMAL | MR_LOCK_DETAIL, OBJ_INDEX(Viewer_obj));
    +		
    +		gr_end_view_matrix();
    +		gr_end_proj_matrix();
    +		gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
    +		gr_set_view_matrix(&Eye_position, &Eye_matrix);
     	}
     
     
    Index: code/ship/ship.cpp
    ===================================================================
    --- code/ship/ship.cpp	(revision 9388)
    +++ code/ship/ship.cpp	(working copy)
    @@ -5797,21 +5797,10 @@
     			}
     		}		
     
    -		if (!(sip->flags2 & SIF2_SHOW_SHIP_MODEL) && !(Viewer_mode & VM_TOPDOWN))
    +		if (!(Viewer_mode & VM_TOPDOWN))
     		{
     			return;
     		}
    -
    -		//For in-ship cockpits. This is admittedly something of a hack
    -		if (!Cmdline_nohtl) {
    -			reset_proj_when_done = true;
    -
    -			gr_end_view_matrix();
    -			gr_end_proj_matrix();
    -
    -			gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    -			gr_set_view_matrix(&Eye_position, &Eye_matrix);
    -		}
     	}
     
     	MONITOR_INC( NumShipsRend, 1 );
    @@ -12045,7 +12034,7 @@
     // the vector of the eye is returned in the parameter 'eye'.  The orientation of the
     // eye is returned in orient.  (NOTE: this is kind of bogus for now since non 0th element
     // eyes have no defined up vector)
    -void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew )
    +void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew , bool from_origin)
     {
     	ship *shipp = &Ships[obj->instance];
     	polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num);
    @@ -12060,7 +12049,7 @@
     	// eye points are stored in an array -- the normal viewing position for a ship is the current_eye_index
     	// element.
     	eye *ep = &(pm->view_positions[Ships[obj->instance].current_viewpoint]);
    -	model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, &obj->pos );
    +	model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, from_origin ? &vmd_zero_vector : &obj->pos );
     	*eye_orient = obj->orient;
     
     	//	Modify the orientation based on head orientation.
    Index: code/ship/ship.h
    ===================================================================
    --- code/ship/ship.h	(revision 9388)
    +++ code/ship/ship.h	(working copy)
    @@ -1662,7 +1662,7 @@
     extern void compute_slew_matrix(matrix *orient, angles *a);
     //extern camid ship_set_eye( object *obj, int eye_index);
     extern void ship_set_eye(object *obj, int eye_index);
    -extern void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew = true );		// returns in eye the correct viewing position for the given object
    +extern void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew = true, bool from_origin = false);		// returns in eye the correct viewing position for the given object
     //extern camid ship_get_followtarget_eye(object *obj);
     extern ship_subsys *ship_get_indexed_subsys( ship *sp, int index, vec3d *attacker_pos = NULL );	// returns index'th subsystem of this ship
     extern int ship_get_index_from_subsys(ship_subsys *ssp, int objnum, int error_bypass = 0);
    
    patch file icon wobblybgonev2.patch (3,841 bytes) 2012-12-02 20:11 +
  • patch file icon wobblybgonev3.patch (5,061 bytes) 2012-12-03 08:44 -
    Index: code/freespace2/freespace.cpp
    ===================================================================
    --- code/freespace2/freespace.cpp	(revision 9388)
    +++ code/freespace2/freespace.cpp	(working copy)
    @@ -3670,7 +3670,22 @@
     	if(draw_viewer_last && Viewer_obj)
     	{
     		gr_post_process_save_zbuffer();
    -		ship_render(Viewer_obj);
    +		vec3d cockpit_eye_pos;
    +		matrix dummy;
    +		ship_get_eye(&cockpit_eye_pos, &dummy, Viewer_obj, true, true);
    +		gr_end_view_matrix();
    +		
    +		gr_end_proj_matrix();
    +		gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    +		gr_set_view_matrix(&cockpit_eye_pos, &Eye_matrix);
    +		
    +		model_set_detail_level(0);
    +		model_render(Ship_info[Ships[Viewer_obj->instance].ship_info_index].model_num, &Viewer_obj->orient, &vmd_zero_vector, MR_NORMAL | MR_LOCK_DETAIL, OBJ_INDEX(Viewer_obj));
    +		
    +		gr_end_view_matrix();
    +		gr_end_proj_matrix();
    +		gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
    +		gr_set_view_matrix(&Eye_position, &Eye_matrix);
     	}
     
     
    Index: code/ship/ship.cpp
    ===================================================================
    --- code/ship/ship.cpp	(revision 9388)
    +++ code/ship/ship.cpp	(working copy)
    @@ -5741,7 +5741,6 @@
     	ship *shipp = &Ships[num];
     	ship *warp_shipp = NULL;
     	ship_info *sip = &Ship_info[Ships[num].ship_info_index];
    -	bool reset_proj_when_done = false;
     	bool is_first_stage_arrival = false;
     	bool show_thrusters = (shipp->flags2 & SF2_NO_THRUSTERS) == 0;
     	dock_function_info dfi;
    @@ -5797,21 +5796,10 @@
     			}
     		}		
     
    -		if (!(sip->flags2 & SIF2_SHOW_SHIP_MODEL) && !(Viewer_mode & VM_TOPDOWN))
    +		if (!(Viewer_mode & VM_TOPDOWN))
     		{
     			return;
     		}
    -
    -		//For in-ship cockpits. This is admittedly something of a hack
    -		if (!Cmdline_nohtl) {
    -			reset_proj_when_done = true;
    -
    -			gr_end_view_matrix();
    -			gr_end_proj_matrix();
    -
    -			gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    -			gr_set_view_matrix(&Eye_position, &Eye_matrix);
    -		}
     	}
     
     	MONITOR_INC( NumShipsRend, 1 );
    @@ -6266,14 +6254,6 @@
     			}
     		}
     	#endif
    -
    -		if (!Cmdline_nohtl && reset_proj_when_done) {
    -			gr_end_view_matrix();
    -			gr_end_proj_matrix();
    -
    -			gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
    -			gr_set_view_matrix(&Eye_position, &Eye_matrix);
    -		}
     	}
     
     	//WMC - Draw animated warp effect (ie BSG thingy)
    @@ -6308,16 +6288,15 @@
     
     	matrix eye_ori = vmd_identity_matrix;
     	vec3d eye_pos = vmd_zero_vector;
    -	ship_get_eye(&eye_pos, &eye_ori, objp, false);
    +	ship_get_eye(&eye_pos, &eye_ori, objp, false, true);
     
     	vec3d pos = vmd_zero_vector;
     
     	vm_vec_unrotate(&pos, &sip->cockpit_offset, &eye_ori);
    -	vm_vec_add2(&pos, &eye_pos);
     	if (!Cmdline_nohtl)
     	{
     		gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.02f, 10.0f*pm->rad);
    -		gr_set_view_matrix(&Eye_position, &Eye_matrix);
    +		gr_set_view_matrix(&vmd_zero_vector, &Eye_matrix);
     	}
     
     	//Zbuffer
    @@ -12045,7 +12024,7 @@
     // the vector of the eye is returned in the parameter 'eye'.  The orientation of the
     // eye is returned in orient.  (NOTE: this is kind of bogus for now since non 0th element
     // eyes have no defined up vector)
    -void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew )
    +void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew , bool from_origin)
     {
     	ship *shipp = &Ships[obj->instance];
     	polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num);
    @@ -12060,7 +12039,7 @@
     	// eye points are stored in an array -- the normal viewing position for a ship is the current_eye_index
     	// element.
     	eye *ep = &(pm->view_positions[Ships[obj->instance].current_viewpoint]);
    -	model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, &obj->pos );
    +	model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, from_origin ? &vmd_zero_vector : &obj->pos );
     	*eye_orient = obj->orient;
     
     	//	Modify the orientation based on head orientation.
    Index: code/ship/ship.h
    ===================================================================
    --- code/ship/ship.h	(revision 9388)
    +++ code/ship/ship.h	(working copy)
    @@ -1662,7 +1662,7 @@
     extern void compute_slew_matrix(matrix *orient, angles *a);
     //extern camid ship_set_eye( object *obj, int eye_index);
     extern void ship_set_eye(object *obj, int eye_index);
    -extern void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew = true );		// returns in eye the correct viewing position for the given object
    +extern void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew = true, bool from_origin = false);		// returns in eye the correct viewing position for the given object
     //extern camid ship_get_followtarget_eye(object *obj);
     extern ship_subsys *ship_get_indexed_subsys( ship *sp, int index, vec3d *attacker_pos = NULL );	// returns index'th subsystem of this ship
     extern int ship_get_index_from_subsys(ship_subsys *ssp, int objnum, int error_bypass = 0);
    
    patch file icon wobblybgonev3.patch (5,061 bytes) 2012-12-03 08:44 +
  • patch file icon wobblybgonev4.patch (6,017 bytes) 2012-12-03 12:22 -
    Index: code/freespace2/freespace.cpp
    ===================================================================
    --- code/freespace2/freespace.cpp	(revision 9388)
    +++ code/freespace2/freespace.cpp	(working copy)
    @@ -3670,7 +3670,7 @@
     	if(draw_viewer_last && Viewer_obj)
     	{
     		gr_post_process_save_zbuffer();
    -		ship_render(Viewer_obj);
    +		ship_render_show_ship_cockpit(Viewer_obj);
     	}
     
     
    Index: code/ship/ship.cpp
    ===================================================================
    --- code/ship/ship.cpp	(revision 9388)
    +++ code/ship/ship.cpp	(working copy)
    @@ -5741,7 +5741,6 @@
     	ship *shipp = &Ships[num];
     	ship *warp_shipp = NULL;
     	ship_info *sip = &Ship_info[Ships[num].ship_info_index];
    -	bool reset_proj_when_done = false;
     	bool is_first_stage_arrival = false;
     	bool show_thrusters = (shipp->flags2 & SF2_NO_THRUSTERS) == 0;
     	dock_function_info dfi;
    @@ -5797,21 +5796,10 @@
     			}
     		}		
     
    -		if (!(sip->flags2 & SIF2_SHOW_SHIP_MODEL) && !(Viewer_mode & VM_TOPDOWN))
    +		if (!(Viewer_mode & VM_TOPDOWN))
     		{
     			return;
     		}
    -
    -		//For in-ship cockpits. This is admittedly something of a hack
    -		if (!Cmdline_nohtl) {
    -			reset_proj_when_done = true;
    -
    -			gr_end_view_matrix();
    -			gr_end_proj_matrix();
    -
    -			gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    -			gr_set_view_matrix(&Eye_position, &Eye_matrix);
    -		}
     	}
     
     	MONITOR_INC( NumShipsRend, 1 );
    @@ -6266,14 +6254,6 @@
     			}
     		}
     	#endif
    -
    -		if (!Cmdline_nohtl && reset_proj_when_done) {
    -			gr_end_view_matrix();
    -			gr_end_proj_matrix();
    -
    -			gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
    -			gr_set_view_matrix(&Eye_position, &Eye_matrix);
    -		}
     	}
     
     	//WMC - Draw animated warp effect (ie BSG thingy)
    @@ -6308,16 +6288,15 @@
     
     	matrix eye_ori = vmd_identity_matrix;
     	vec3d eye_pos = vmd_zero_vector;
    -	ship_get_eye(&eye_pos, &eye_ori, objp, false);
    +	ship_get_eye(&eye_pos, &eye_ori, objp, false, true);
     
     	vec3d pos = vmd_zero_vector;
     
     	vm_vec_unrotate(&pos, &sip->cockpit_offset, &eye_ori);
    -	vm_vec_add2(&pos, &eye_pos);
     	if (!Cmdline_nohtl)
     	{
     		gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.02f, 10.0f*pm->rad);
    -		gr_set_view_matrix(&Eye_position, &Eye_matrix);
    +		gr_set_view_matrix(&vmd_zero_vector, &Eye_matrix);
     	}
     
     	//Zbuffer
    @@ -6341,6 +6320,28 @@
     	hud_save_restore_camera_data(0);
     }
     
    +void ship_render_show_ship_cockpit(object *objp)
    +{
    +	vec3d cockpit_eye_pos;
    +	matrix dummy;
    +	ship_get_eye(&cockpit_eye_pos, &dummy, objp, true, true); //Get cockpit eye position
    +	
    +	gr_end_view_matrix();
    +	gr_end_proj_matrix();
    +	gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, 0.05f, Max_draw_distance);
    +	gr_set_view_matrix(&cockpit_eye_pos, &Eye_matrix); // Set Camera to cockpit eye position
    +	
    +	Glowpoint_override = true; // Turn off glowpoints so they dont get rendered fixed at origin
    +	model_set_detail_level(0);
    +	model_render(Ship_info[Ships[objp->instance].ship_info_index].model_num, &objp->orient, &vmd_zero_vector, MR_NORMAL | MR_LOCK_DETAIL, OBJ_INDEX(objp)); // Render ship model with fixed detail level 0 so its not switching LOD when moving away from origin
    +	Glowpoint_override = false;
    +
    +	gr_end_view_matrix();
    +	gr_end_proj_matrix();
    +	gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
    +	gr_set_view_matrix(&Eye_position, &Eye_matrix); // Reset Camera to normal
    +}
    +
     void ship_init_cockpit_displays(ship *shipp)
     {
     	ship_info *sip = &Ship_info[shipp->ship_info_index];
    @@ -12045,7 +12046,7 @@
     // the vector of the eye is returned in the parameter 'eye'.  The orientation of the
     // eye is returned in orient.  (NOTE: this is kind of bogus for now since non 0th element
     // eyes have no defined up vector)
    -void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew )
    +void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew , bool from_origin)
     {
     	ship *shipp = &Ships[obj->instance];
     	polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num);
    @@ -12060,7 +12061,7 @@
     	// eye points are stored in an array -- the normal viewing position for a ship is the current_eye_index
     	// element.
     	eye *ep = &(pm->view_positions[Ships[obj->instance].current_viewpoint]);
    -	model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, &obj->pos );
    +	model_find_world_point( eye_pos, &ep->pnt, pm->id, ep->parent, &obj->orient, from_origin ? &vmd_zero_vector : &obj->pos );
     	*eye_orient = obj->orient;
     
     	//	Modify the orientation based on head orientation.
    Index: code/ship/ship.h
    ===================================================================
    --- code/ship/ship.h	(revision 9388)
    +++ code/ship/ship.h	(working copy)
    @@ -1555,6 +1555,7 @@
     extern void ship_process_post( object * objp, float frametime );
     extern void ship_render( object * objp );
     extern void ship_render_cockpit( object * objp);
    +extern void ship_render_show_ship_cockpit( object * objp);
     extern void ship_delete( object * objp );
     extern int ship_check_collision_fast( object * obj, object * other_obj, vec3d * hitpos );
     extern int ship_get_num_ships();
    @@ -1662,7 +1663,7 @@
     extern void compute_slew_matrix(matrix *orient, angles *a);
     //extern camid ship_set_eye( object *obj, int eye_index);
     extern void ship_set_eye(object *obj, int eye_index);
    -extern void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew = true );		// returns in eye the correct viewing position for the given object
    +extern void ship_get_eye( vec3d *eye_pos, matrix *eye_orient, object *obj, bool do_slew = true, bool from_origin = false);		// returns in eye the correct viewing position for the given object
     //extern camid ship_get_followtarget_eye(object *obj);
     extern ship_subsys *ship_get_indexed_subsys( ship *sp, int index, vec3d *attacker_pos = NULL );	// returns index'th subsystem of this ship
     extern int ship_get_index_from_subsys(ship_subsys *ssp, int objnum, int error_bypass = 0);
    
    patch file icon wobblybgonev4.patch (6,017 bytes) 2012-12-03 12:22 +

-Relationships
related to 0001704closed Large coordiante values result in ships not being where they apper to be. 
related to 0000527resolvedtaylor Objects Wiggle [significantly] on their position. 
+Relationships

-Notes

~0014199

Goober5000 (administrator)

This is another manifestation of the large coordinate problem. It's not fixable without a serious redesign, per earlier comments in 0001704.

~0014201

Goober5000 (administrator)

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.

~0014220

Valathil (developer)

Of course, "The Wizard will fix it!" -_-

~0014224

Goober5000 (administrator)

Of course. :) And it should be a pretty simple fix, too. Stand by for an email.

~0014228

Valathil (developer)

Attached a patch with fix.

~0014249

Goober5000 (administrator)

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.

~0014258

Valathil (developer)

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?

~0014259

The_E (administrator)

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.

~0014260

Goober5000 (administrator)

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".)

~0014262

Valathil (developer)

Last edited: 2012-12-03 08:45

View 7 revisions

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

~0014273

taylor (administrator)

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.

~0014274

Valathil (developer)

v4 is attached with move to own function and comments.

~0014373

Zacam (administrator)

Fix committed to trunk@9413.
+Notes

+Related Changesets

-Issue History
Date Modified Username Field Change
2010-10-09 00:38 origin New Issue
2010-10-10 08:47 origin File Added: autopilotA.fs2
2012-11-27 01:57 Goober5000 Relationship added related to 0001704
2012-11-27 01:58 Goober5000 Note Added: 0014199
2012-11-27 01:58 Goober5000 Status new => closed
2012-11-27 01:58 Goober5000 Resolution open => not fixable
2012-11-27 23:33 Goober5000 Relationship added related to 0000527
2012-11-27 23:35 Goober5000 Note Added: 0014201
2012-11-27 23:35 Goober5000 Assigned To => Valathil
2012-11-27 23:35 Goober5000 Status closed => assigned
2012-11-27 23:35 Goober5000 Resolution not fixable => reopened
2012-11-28 16:07 Valathil Note Added: 0014220
2012-11-29 00:50 Goober5000 Note Added: 0014224
2012-11-29 11:56 Valathil File Added: wobblybgone.patch
2012-11-29 11:56 Valathil Note Added: 0014228
2012-11-29 11:56 Valathil Status assigned => code review
2012-12-02 00:08 Goober5000 Note Added: 0014249
2012-12-02 10:46 Valathil Note Added: 0014258
2012-12-02 10:52 The_E Note Added: 0014259
2012-12-02 13:35 Goober5000 Note Added: 0014260
2012-12-02 16:40 Valathil Note Added: 0014262
2012-12-02 16:55 Valathil Note Edited: 0014262 View Revisions
2012-12-02 19:25 Valathil Note Edited: 0014262 View Revisions
2012-12-02 20:11 Valathil File Added: wobblybgonev2.patch
2012-12-02 20:16 Valathil Note Edited: 0014262 View Revisions
2012-12-02 20:17 Valathil Note Edited: 0014262 View Revisions
2012-12-02 22:03 Valathil Note Edited: 0014262 View Revisions
2012-12-03 08:44 Valathil File Added: wobblybgonev3.patch
2012-12-03 08:45 Valathil Note Edited: 0014262 View Revisions
2012-12-03 11:38 taylor Note Added: 0014273
2012-12-03 12:22 Valathil File Added: wobblybgonev4.patch
2012-12-03 12:22 Valathil Note Added: 0014274
2012-12-08 22:58 Zacam Changeset attached => fs2open trunk r9413
2012-12-08 22:58 Zacam Note Added: 0014373
2012-12-08 22:58 Zacam Status code review => resolved
+Issue History