fix: MapEventLayer velocity when timediff = 0
This commit is contained in:
parent
4f77643321
commit
45db59650a
@ -423,6 +423,9 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(float x, float y, long time) {
|
public void update(float x, float y, long time) {
|
||||||
|
if (time == mLastTime)
|
||||||
|
return;
|
||||||
|
|
||||||
if (--mIndex < 0)
|
if (--mIndex < 0)
|
||||||
mIndex = SAMPLES - 1;
|
mIndex = SAMPLES - 1;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import static org.oscim.core.MercatorProjection.latitudeToY;
|
|||||||
import static org.oscim.core.MercatorProjection.longitudeToX;
|
import static org.oscim.core.MercatorProjection.longitudeToX;
|
||||||
import static org.oscim.utils.FastMath.clamp;
|
import static org.oscim.utils.FastMath.clamp;
|
||||||
|
|
||||||
|
import org.oscim.backend.CanvasAdapter;
|
||||||
import org.oscim.core.BoundingBox;
|
import org.oscim.core.BoundingBox;
|
||||||
import org.oscim.core.GeoPoint;
|
import org.oscim.core.GeoPoint;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
@ -162,11 +163,15 @@ public class Animator {
|
|||||||
|
|
||||||
float duration = 500;
|
float duration = 500;
|
||||||
|
|
||||||
float flingFactor = 0.5f;
|
float flingFactor = 240 / CanvasAdapter.dpi;
|
||||||
mVelocity.x = velocityX * flingFactor;
|
mVelocity.x = velocityX * flingFactor;
|
||||||
mVelocity.y = velocityY * flingFactor;
|
mVelocity.y = velocityY * flingFactor;
|
||||||
clamp(mVelocity.x, minX, maxX);
|
mVelocity.x = clamp(mVelocity.x, minX, maxX);
|
||||||
clamp(mVelocity.y, minY, maxY);
|
mVelocity.y = clamp(mVelocity.y, minY, maxY);
|
||||||
|
if (Double.isNaN(mVelocity.x) || Double.isNaN(mVelocity.y)) {
|
||||||
|
log.debug("fling NaN!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
animStart(duration, ANIM_FLING);
|
animStart(duration, ANIM_FLING);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user