Location renderer improvements #321

This commit is contained in:
Emux
2017-03-05 17:17:16 +02:00
parent e0c02a83d0
commit 6461d39357
2 changed files with 16 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright 2013 Ahmad Saleem * Copyright 2013 Ahmad Saleem
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86 * Copyright 2016-2017 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@@ -85,6 +85,11 @@ public class Compass extends Layer implements SensorEventListener, Map.UpdateLis
setEnabled(false); setEnabled(false);
} }
@Override
public boolean hasRotation() {
return true;
}
@Override @Override
public synchronized float getRotation() { public synchronized float getRotation() {
return mCurRotation; return mCurRotation;

View File

@@ -226,17 +226,14 @@ public class LocationRenderer extends LayerRenderer {
gl.uniform1f(hPhase, 1); gl.uniform1f(hPhase, 1);
} }
if (viewShed && mLocationIsVisible && mCallback != null) { if (viewShed && mLocationIsVisible && mCallback != null && mCallback.hasRotation()) {
float rotation = mCallback.getRotation(); float rotation = mCallback.getRotation();
if (rotation != 0) {
rotation -= 90; rotation -= 90;
gl.uniform2f(hDirection, gl.uniform2f(hDirection,
(float) Math.cos(Math.toRadians(rotation)), (float) Math.cos(Math.toRadians(rotation)),
(float) Math.sin(Math.toRadians(rotation))); (float) Math.sin(Math.toRadians(rotation)));
} else } else
gl.uniform2f(hDirection, 0, 0); gl.uniform2f(hDirection, 0, 0);
} else
gl.uniform2f(hDirection, 0, 0);
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4); gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
} }
@@ -257,6 +254,11 @@ public class LocationRenderer extends LayerRenderer {
} }
public interface Callback { public interface Callback {
/**
* Usually true, can be used with e.g. Android Location.hasBearing().
*/
boolean hasRotation();
float getRotation(); float getRotation();
} }
} }