summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-02-08 22:17:15 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-02-08 22:17:15 +0000
commitc02e469bbba8f363317a8b54b388774fdb5d431d (patch)
tree6e78a3b8fcd413609c9ead5905fbfb2ceb7f4745
parent755ddc9fc2b3c4af3e62353b4be6abbb4e7a934f (diff)
simplify zo calculation a bit, "zoom" the center margin value and add term for zo to offset calculation, so that margins are still correct when zooming
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19947 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/pictureflow.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c
index bd51a88b36..4a4d6b405e 100644
--- a/apps/plugins/pictureflow.c
+++ b/apps/plugins/pictureflow.c
@@ -113,7 +113,7 @@ typedef fb_data pix_t;
#define DISPLAY_OFFS ((LCD_HEIGHT / 2) - REFLECT_HEIGHT)
#define CAM_DIST MAX(MIN(LCD_HEIGHT,LCD_WIDTH),120)
#define CAM_DIST_R (CAM_DIST << PFREAL_SHIFT)
-#define DISPLAY_LEFT_R (PFREAL_HALF - LCD_WIDTH * PFREAL_ONE / 2)
+#define DISPLAY_LEFT_R (PFREAL_HALF - LCD_WIDTH * PFREAL_HALF)
#define SLIDE_CACHE_SIZE 100
@@ -1207,25 +1207,27 @@ void reset_slides(void)
Call this when the viewport size or slide dimension is changed.
*
* To calculate the offset that will provide the proper margin, we use the same
- * projection used to render the slides. Assuming zo == 0, the solution for xc,
- * the slide center, is:
- * xp * xs * sin(r)
- * xc = xp - xs * cos(r) + ────────────────
- * z
+ * projection used to render the slides. The solution for xc, the slide center,
+ * is:
+ * xp * (zo + xs * sin(r))
+ * xc = xp - xs * cos(r) + ───────────────────────
+ * z
* TODO: support moving the side slides toward or away from the camera
*/
void recalc_offsets(void)
{
PFreal xs = PFREAL_HALF - DISPLAY_WIDTH * PFREAL_HALF;
- PFreal xp = DISPLAY_WIDTH * PFREAL_HALF - PFREAL_HALF + center_margin *
- PFREAL_ONE;
+ PFreal zo = CAM_DIST_R * 100 / zoom - CAM_DIST_R;
+ PFreal xp = (DISPLAY_WIDTH * PFREAL_HALF - PFREAL_HALF + center_margin *
+ PFREAL_ONE) * zoom / 100;
PFreal cosr, sinr;
itilt = 70 * IANGLE_MAX / 360; /* approx. 70 degrees tilted */
cosr = fcos(-itilt);
sinr = fsin(-itilt);
offsetX = xp - fmul(xs, cosr) + fmuln(xp,
- fmuln(xs, sinr, PFREAL_SHIFT - 2, 0), PFREAL_SHIFT - 2, 0)/CAM_DIST;
+ zo + fmuln(xs, sinr, PFREAL_SHIFT - 2, 0), PFREAL_SHIFT - 2, 0)
+ / CAM_DIST;
offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2);
}
@@ -1303,8 +1305,8 @@ void render_slide(struct slide_data *slide, const int alpha)
const int w = LCD_WIDTH;
- PFreal zo = (CAM_DIST_R + PFREAL_ONE * slide->distance) * 100 / zoom -
- CAM_DIST_R;
+ PFreal zo = PFREAL_ONE * slide->distance + CAM_DIST_R * 100 / zoom
+ - CAM_DIST_R;
PFreal cosr = fcos(slide->angle);
PFreal sinr = fsin(slide->angle);
PFreal xs = slide_left, xsnum, xsnumi, xsden, xsdeni;