Object Draw: Fix parallax object positions when zoomed

Previously, the object position was used as if it represented the position
in the landscape when viewed from 0/0 with the current Zoom, but it
actually represents the position when viewed from 0/0 with Zoom 1.
floating-point
Günther Brammer 2010-09-26 20:46:13 +02:00
parent aa5db73404
commit 90f3b394a8
2 changed files with 5 additions and 4 deletions

View File

@ -231,8 +231,8 @@ void C4Sky::Draw(C4TargetFacet &cgo)
// Step 1: project to landscape coordinates
float resultzoom = 1.0 / (1.0 - (par - par/zoom));
float rx = ((1 - parx) * targetx) * resultzoom + fixtof(x);
float ry = ((1 - pary) * targety) * resultzoom + fixtof(y);
float rx = ((1 - parx) * targetx) * resultzoom + fixtof(x) / (parx + zoom - parx * zoom);
float ry = ((1 - pary) * targety) * resultzoom + fixtof(y) / (pary + zoom - pary * zoom);
// Step 2: convert to screen coordinates
float resultx = (rx - targetx) * zoom / resultzoom;

View File

@ -5161,11 +5161,12 @@ bool C4Object::GetDrawPosition(const C4TargetFacet & cgo, float objx, float objy
// Step 1: project to landscape coordinates
resultzoom = 1.0 / (1.0 - (par - par/zoom));
// it would be par / (1.0 - (par - par/zoom)) if objects would get smaller farther away
if (resultzoom <= 0 || resultzoom > 100) // FIXME: optimize treshhold
return false;
float rx = ((1 - parx) * targetx) * resultzoom + objx;
float ry = ((1 - pary) * targety) * resultzoom + objy;
float rx = ((1 - parx) * targetx) * resultzoom + objx / (parx + zoom - parx * zoom);
float ry = ((1 - pary) * targety) * resultzoom + objy / (pary + zoom - pary * zoom);
// Step 2: convert to screen coordinates
if(parx == 0 && fix_x < 0)