parent
71a82d087b
commit
bd9e7d7456
@ -32,6 +32,7 @@ import org.oscim.map.Animator2;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.Map.InputListener;
|
||||
import org.oscim.map.ViewController;
|
||||
import org.oscim.utils.FastMath;
|
||||
import org.oscim.utils.Parameters;
|
||||
|
||||
import static org.oscim.backend.CanvasAdapter.dpi;
|
||||
@ -366,10 +367,11 @@ public class MapEventLayer extends AbstractMapEventLayer implements InputListene
|
||||
deltaPinch = 0;
|
||||
|
||||
if (Parameters.ANIMATOR2) {
|
||||
double clampedRotation = FastMath.clampRadian(rotateBy);
|
||||
if (mRotateTracker.mNumSamples < 0)
|
||||
mRotateTracker.start(mRotateTracker.mLastX + (float) da, 0, e.getTime());
|
||||
mRotateTracker.start(mRotateTracker.mLastX + (float) clampedRotation, 0, e.getTime());
|
||||
else
|
||||
mRotateTracker.update(mRotateTracker.mLastX + (float) da, 0, e.getTime());
|
||||
mRotateTracker.update(mRotateTracker.mLastX + (float) clampedRotation, 0, e.getTime());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -31,6 +31,7 @@ import org.oscim.map.Animator2;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.Map.InputListener;
|
||||
import org.oscim.map.ViewController;
|
||||
import org.oscim.utils.FastMath;
|
||||
import org.oscim.utils.Parameters;
|
||||
import org.oscim.utils.async.Task;
|
||||
|
||||
@ -457,10 +458,11 @@ public class MapEventLayer2 extends AbstractMapEventLayer implements InputListen
|
||||
deltaPinch = 0;
|
||||
|
||||
if (Parameters.ANIMATOR2) {
|
||||
double clampedRotation = FastMath.clampRadian(rotateBy);
|
||||
if (mRotateTracker.mNumSamples < 0)
|
||||
mRotateTracker.start(mRotateTracker.mLastX + (float) da, 0, e.getTime());
|
||||
mRotateTracker.start(mRotateTracker.mLastX + (float) clampedRotation, 0, e.getTime());
|
||||
else
|
||||
mRotateTracker.update(mRotateTracker.mLastX + (float) da, 0, e.getTime());
|
||||
mRotateTracker.update(mRotateTracker.mLastX + (float) clampedRotation, 0, e.getTime());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -41,8 +41,8 @@ public class Animator2 extends Animator {
|
||||
/**
|
||||
* The minimum changes that are pleasant for users.
|
||||
*/
|
||||
private static final float DEFAULT_MIN_VISIBLE_CHANGE_DEGREE = 0.001f;
|
||||
private static final float DEFAULT_MIN_VISIBLE_CHANGE_PIXELS = 0.5f;
|
||||
private static final float DEFAULT_MIN_VISIBLE_CHANGE_RADIAN = 0.001f;
|
||||
private static final float DEFAULT_MIN_VISIBLE_CHANGE_SCALE = 1f;
|
||||
|
||||
private static final float FLING_FRICTION_MOVE = 0.9f;
|
||||
@ -65,6 +65,8 @@ public class Animator2 extends Animator {
|
||||
|
||||
/**
|
||||
* Animates a physical fling for rotations.
|
||||
*
|
||||
* @param angularVelocity angular velocity in radians
|
||||
*/
|
||||
public void animateFlingRotate(float angularVelocity, float pivotX, float pivotY) {
|
||||
ThreadUtils.assertMainThread();
|
||||
@ -77,7 +79,7 @@ public class Animator2 extends Animator {
|
||||
float flingFactor = -0.4f; // Can be changed but should be standardized for all callers
|
||||
angularVelocity *= flingFactor;
|
||||
|
||||
mFlingRotateForce.setValueThreshold(DEFAULT_MIN_VISIBLE_CHANGE_DEGREE);
|
||||
mFlingRotateForce.setValueThreshold(DEFAULT_MIN_VISIBLE_CHANGE_RADIAN);
|
||||
mFlingRotateForce.setFrictionScalar(FLING_FRICTION_ROTATE);
|
||||
mFlingRotateForce.setValueAndVelocity(0f, angularVelocity);
|
||||
|
||||
|
@ -74,6 +74,17 @@ public class FastMath {
|
||||
return (value < 0f ? 0f : (value > 1f ? 1f : value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns normalized radian in range of -PI to +PI
|
||||
*/
|
||||
public static double clampRadian(double radian) {
|
||||
while (radian > Math.PI)
|
||||
radian -= 2 * Math.PI;
|
||||
while (radian < -Math.PI)
|
||||
radian += 2 * Math.PI;
|
||||
return radian;
|
||||
}
|
||||
|
||||
public static byte clampToByte(int value) {
|
||||
return (byte) (value < 0 ? 0 : (value > 255 ? 255 : value));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user