use new Martix4 function which use temporary array

- avoid 'undefined behaviour' which did work for most cases...
This commit is contained in:
Hannes Janetzek 2013-05-11 22:53:24 +02:00
parent b463ca7e3b
commit 477548c5f7
5 changed files with 9 additions and 11 deletions

View File

@ -31,7 +31,6 @@ import org.oscim.utils.Matrix4;
import org.oscim.utils.quadtree.QuadTree; import org.oscim.utils.quadtree.QuadTree;
import android.opengl.GLES20; import android.opengl.GLES20;
/** /**
* This class is for rendering the Line- and PolygonLayers of visible MapTiles. * This class is for rendering the Line- and PolygonLayers of visible MapTiles.
* For visible tiles that do not have data available yet its parent in children * For visible tiles that do not have data available yet its parent in children
@ -58,10 +57,12 @@ public class TileRenderer {
mMatrices = m; mMatrices = m;
mFaded = fade; mFaded = fade;
mProjMatrix.copy(m.viewproj); mProjMatrix.copy(m.proj);
// discard z projection from tilt // discard depth projection from tilt, we use depth buffer
// for clipping
mProjMatrix.setValue(10, 0); mProjMatrix.setValue(10, 0);
mProjMatrix.setValue(14, 0); mProjMatrix.setValue(14, 0);
mProjMatrix.multiplyRhs(m.view);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT); GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT);
@ -141,7 +142,7 @@ public class TileRenderer {
Matrices m = mMatrices; Matrices m = mMatrices;
m.mvp.setTransScale(x, y, (float) (scale / GLRenderer.COORD_SCALE)); m.mvp.setTransScale(x, y, (float) (scale / GLRenderer.COORD_SCALE));
m.mvp.multiplyMM(mProjMatrix, m.mvp); m.mvp.multiplyLhs(mProjMatrix);
// set depth offset (used for clipping to tile boundaries) // set depth offset (used for clipping to tile boundaries)
GLES20.glPolygonOffset(0, mOffsetCnt++); GLES20.glPolygonOffset(0, mOffsetCnt++);

View File

@ -100,7 +100,7 @@ public abstract class RenderLayer {
matrices.mvp.setTransScale((float) (x * tileScale), (float) (y * tileScale), matrices.mvp.setTransScale((float) (x * tileScale), (float) (y * tileScale),
(float) ((position.scale / oPos.scale) / GLRenderer.COORD_SCALE)); (float) ((position.scale / oPos.scale) / GLRenderer.COORD_SCALE));
matrices.mvp.multiplyMM(project ? matrices.viewproj : matrices.view, matrices.mvp); matrices.mvp.multiplyLhs(project ? matrices.viewproj : matrices.view);
} }
/** /**

View File

@ -111,10 +111,7 @@ public class CustomRenderLayer extends RenderLayer {
float ratio = 1f / mMapView.getWidth(); float ratio = 1f / mMapView.getWidth();
m.mvp.setScale(ratio, ratio, 1); m.mvp.setScale(ratio, ratio, 1);
m.mvp.multiplyMM(m.proj, m.mvp); m.mvp.multiplyLhs(m.proj);
// setMatrix(pos, m);
m.mvp.setAsUniform(hMatrixPosition); m.mvp.setAsUniform(hMatrixPosition);
// Draw the triangle // Draw the triangle

View File

@ -333,7 +333,7 @@ public class ExtrusionRenderLayer extends RenderLayer {
// scale height // scale height
m.mvp.setValue(10, scale / 10); m.mvp.setValue(10, scale / 10);
m.mvp.multiplyMM(m.viewproj, m.mvp); m.mvp.multiplyLhs(m.viewproj);
m.mvp.addDepthOffset(delta); m.mvp.addDepthOffset(delta);
} }

View File

@ -123,7 +123,7 @@ public class MapViewPosition {
mProjMatrix.set(tmp); mProjMatrix.set(tmp);
mTmpMatrix.setTranslation(0, 0, -VIEW_DISTANCE); mTmpMatrix.setTranslation(0, 0, -VIEW_DISTANCE);
mProjMatrix.multiplyMM(mTmpMatrix); mProjMatrix.multiplyRhs(mTmpMatrix);
mProjMatrix.get(tmp); mProjMatrix.get(tmp);
Matrix.invertM(tmp, 0, tmp, 0); Matrix.invertM(tmp, 0, tmp, 0);