View Issue Details

IDProjectCategoryView StatusLast Update
0002362FSSCPSEXPspublic2014-07-01 04:32
ReporterFSF Assigned ToYarn  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.13 
Target Version3.7.2 
Summary0002362: Show-subtitle-image: position messed up
DescriptionUsing the show-subtitle-image SEXP, the positioning of the image gets messed up if it's rescaled. The more it's scaled, the more offset the position is. Centered images are affected too.
Using nightly 6880, December 24
Additional InformationThe attached mission is pretty self-explanatory. The red blob should be centered, the command briefing screen should be at X=80%, Y=30% of the screen.
The mission is fully retail-compatible.
TagsNo tags attached.

Activities

2010-12-28 16:35

 

Test_title.fs2 (3,666 bytes)

CommanderDJ

2011-04-29 03:15

developer   ~0012670

Just tested the mission with r7151, the issue persists. No idea why it's occurring though. Someone with more coding experience will have to take a look.

FSF

2011-11-09 21:22

reporter   ~0012946

3.6.14 RC1, still persists. It appears that the scaling is applied from top-left of the screen instead of top-left of the image; e.g. positioning at 80% x and scaling to 10% of screen width will render the image at 8% x. So yeah, it's a graphics issue rather than a SEXP issue...

In camera.cpp, subtitle::do_frame(), lines 699-700, the scale matrix and image_pos seem alright - but I don't know how to track the subtitle further into the graphics code.

Goober5000

2011-11-10 05:01

administrator   ~0012947

"It appears that the scaling is applied from top-left of the screen instead of top-left of the image" -- what do you mean?

2011-11-10 09:33

 

temp.gif (11,434 bytes)   
temp.gif (11,434 bytes)   

FSF

2011-11-10 09:36

reporter   ~0012948

Ahm, I hope the picture explains it better than I do... FS takes the unscaled image, and positions it on the screen; then it scales the image in screen coordinates, instead of image coordinates. Hence, not only the image, but also the position on-screen is scaled.

Picture drawn for x-coordinate, but equally valid for y.

MjnMixael

2012-12-05 21:40

manager   ~0014317

Last edited: 2012-12-05 21:40

As per my conversation with Goober...

This is probably an order of operations problem. Currently it places the image on the screen, then scales the screen. What it should do is scale the image, then place it on the screen.

Goober5000

2012-12-06 04:28

administrator   ~0014327

Just spent nearly an hour giving myself a headache on this. It is nearly impossible to follow the logic of the subtitle display code. I think it may have to be rewritten.

Goober5000

2012-12-06 04:32

administrator   ~0014329

Retargeting for 3.7.2.

Yarn

2014-07-01 03:39

developer  

mantis2362.patch (788 bytes)   
Index: code/camera/camera.cpp
===================================================================
--- code/camera/camera.cpp	(revision 10864)
+++ code/camera/camera.cpp	(working copy)
@@ -739,12 +739,12 @@
 			vec3d scale;
 
 			bm_get_info(image_id, &orig_w, &orig_h);
-			scale.xyz.x = image_pos.w / (float) orig_w;
-			scale.xyz.y = image_pos.h / (float) orig_h;
+			scale.xyz.x = (image_pos.w > 0) ? (image_pos.w / (float) orig_w) : 1.0f;
+			scale.xyz.y = (image_pos.h > 0) ? (image_pos.h / (float) orig_h) : 1.0f;
 			scale.xyz.z = 1.0f;
 
 			gr_push_scale_matrix(&scale);
-			gr_bitmap(image_pos.x, image_pos.y, GR_RESIZE_NONE);
+			gr_bitmap(fl2i(image_pos.x / scale.xyz.x), fl2i(image_pos.y / scale.xyz.y), GR_RESIZE_NONE);
 			gr_pop_scale_matrix();
 		}
 		// no scaling
mantis2362.patch (788 bytes)   

Yarn

2014-07-01 03:39

developer   ~0015994

Last edited: 2014-07-01 03:42

The attached patch should fix this. Since the image coordinates are scaled with the image itself, they have to be corrected before or during the call to gr_bitmap(). The patch also corrects a probable bug where, if only one scale value is zero, then the image would not appear at all, deviating from how the SEXP is documented in FRED (and, with this patch, resulting in division by zero).

MageKing17

2014-07-01 04:09

developer   ~0015996

Seems to work; the red blob was dead center and the screenshot was on the right and up a little.

Goober5000

2014-07-01 04:30

administrator   ~0015997

Outstanding. Simple patch, caught a div-0 trap, verified fixed. Well done!

Goober5000

2014-07-01 04:32

administrator   ~0015998

Fix committed to trunk@10865.

Related Changesets

fs2open: trunk r10865

2014-07-01 00:53

Goober5000


Ported: N/A

Details Diff
Yarn's fix for Mantis 0002362 (scale images properly with show-subtitle-image) Affected Issues
0002362
mod - /trunk/fs2_open/code/camera/camera.cpp Diff File

Issue History

Date Modified Username Field Change
2010-12-28 16:35 FSF New Issue
2010-12-28 16:35 FSF File Added: Test_title.fs2
2011-04-29 03:15 CommanderDJ Note Added: 0012670
2011-11-09 21:22 FSF Note Added: 0012946
2011-11-10 05:01 Goober5000 Status new => assigned
2011-11-10 05:01 Goober5000 Assigned To => Goober5000
2011-11-10 05:01 Goober5000 Note Added: 0012947
2011-11-10 09:33 FSF File Added: temp.gif
2011-11-10 09:36 FSF Note Added: 0012948
2012-12-05 21:40 MjnMixael Note Added: 0014317
2012-12-05 21:40 MjnMixael Note Edited: 0014317
2012-12-06 04:28 Goober5000 Note Added: 0014327
2012-12-06 04:32 Goober5000 Note Added: 0014329
2012-12-06 04:32 Goober5000 Target Version => 3.7.2
2014-07-01 03:39 Yarn File Added: mantis2362.patch
2014-07-01 03:39 Yarn Note Added: 0015994
2014-07-01 03:40 Yarn Assigned To Goober5000 => Yarn
2014-07-01 03:40 Yarn Status assigned => code review
2014-07-01 03:42 Yarn Note Edited: 0015994
2014-07-01 04:09 MageKing17 Note Added: 0015996
2014-07-01 04:30 Goober5000 Note Added: 0015997
2014-07-01 04:32 Goober5000 Changeset attached => fs2open trunk r10865
2014-07-01 04:32 Goober5000 Note Added: 0015998
2014-07-01 04:32 Goober5000 Status code review => resolved
2014-07-01 04:32 Goober5000 Resolution open => fixed