View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002362 | FSSCP | SEXPs | public | 2010-12-28 16:35 | 2014-07-01 04:32 |
Reporter | FSF | Assigned To | Yarn | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.6.13 | ||||
Target Version | 3.7.2 | ||||
Summary | 0002362: Show-subtitle-image: position messed up | ||||
Description | Using 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 Information | The 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. | ||||
Tags | No tags attached. | ||||
2010-12-28 16:35
|
|
|
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. |
|
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. |
|
"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
|
|
|
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. |
|
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. |
|
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. |
|
Retargeting for 3.7.2. |
|
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 |
|
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). |
|
Seems to work; the red blob was dead center and the screenshot was on the right and up a little. |
|
Outstanding. Simple patch, caught a div-0 trap, verified fixed. Well done! |
|
Fix committed to trunk@10865. |
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 |