ExtrusionRenderer: simplify mesh-mode int to boolean (readability) (#564)
This commit is contained in:
parent
f07de4c910
commit
12b56905f6
@ -2,6 +2,7 @@
|
|||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2017 Izumi Kawashima
|
* Copyright 2017 Izumi Kawashima
|
||||||
* Copyright 2017 devemux86
|
* Copyright 2017 devemux86
|
||||||
|
* Copyright 2018 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -35,7 +36,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
// Don't draw extrusions which are covered by others
|
// Don't draw extrusions which are covered by others
|
||||||
private final boolean mTranslucent;
|
private final boolean mTranslucent;
|
||||||
|
|
||||||
private final int mMode;
|
private final boolean mMesh;
|
||||||
private Shader mShader;
|
private Shader mShader;
|
||||||
|
|
||||||
protected ExtrusionBuckets[] mExtrusionBucketSet = {};
|
protected ExtrusionBuckets[] mExtrusionBucketSet = {};
|
||||||
@ -45,7 +46,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
private float mZLimit = Float.MAX_VALUE;
|
private float mZLimit = Float.MAX_VALUE;
|
||||||
|
|
||||||
public ExtrusionRenderer(boolean mesh, boolean translucent) {
|
public ExtrusionRenderer(boolean mesh, boolean translucent) {
|
||||||
mMode = mesh ? 1 : 0;
|
mMesh = mesh;
|
||||||
mTranslucent = translucent;
|
mTranslucent = translucent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setup() {
|
public boolean setup() {
|
||||||
if (mMode == 0)
|
if (!mMesh)
|
||||||
mShader = new Shader("extrusion_layer_ext");
|
mShader = new Shader("extrusion_layer_ext");
|
||||||
else
|
else
|
||||||
mShader = new Shader("extrusion_layer_mesh");
|
mShader = new Shader("extrusion_layer_mesh");
|
||||||
@ -86,12 +87,12 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
|
|
||||||
int sumIndices = eb.idx[0] + eb.idx[1] + eb.idx[2];
|
int sumIndices = eb.idx[0] + eb.idx[1] + eb.idx[2];
|
||||||
|
|
||||||
/* extrusion */
|
/* extrusion (mMesh == false) */
|
||||||
if (sumIndices > 0)
|
if (sumIndices > 0)
|
||||||
gl.drawElements(GL.TRIANGLES, sumIndices,
|
gl.drawElements(GL.TRIANGLES, sumIndices,
|
||||||
GL.UNSIGNED_SHORT, eb.off[0]);
|
GL.UNSIGNED_SHORT, eb.off[0]);
|
||||||
|
|
||||||
/* mesh */
|
/* mesh (mMesh == true) */
|
||||||
if (eb.idx[4] > 0) {
|
if (eb.idx[4] > 0) {
|
||||||
gl.drawElements(GL.TRIANGLES, eb.idx[4],
|
gl.drawElements(GL.TRIANGLES, eb.idx[4],
|
||||||
GL.UNSIGNED_SHORT, eb.off[4]);
|
GL.UNSIGNED_SHORT, eb.off[4]);
|
||||||
@ -182,7 +183,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
if (eb.getColors() != currentColors) {
|
if (eb.getColors() != currentColors) {
|
||||||
currentColors = eb.getColors();
|
currentColors = eb.getColors();
|
||||||
GLUtils.glUniform4fv(s.uColor,
|
GLUtils.glUniform4fv(s.uColor,
|
||||||
mMode == 0 ? 4 : 1,
|
mMesh ? 1 : 4,
|
||||||
currentColors);
|
currentColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +193,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
gl.vertexAttribPointer(s.aLight, 2, GL.UNSIGNED_BYTE,
|
gl.vertexAttribPointer(s.aLight, 2, GL.UNSIGNED_BYTE,
|
||||||
false, 8, eb.getVertexOffset() + 6);
|
false, 8, eb.getVertexOffset() + 6);
|
||||||
|
|
||||||
/* draw extruded outlines */
|
/* draw extruded outlines (mMesh == false) */
|
||||||
if (eb.idx[0] > 0) {
|
if (eb.idx[0] > 0) {
|
||||||
if (mTranslucent) {
|
if (mTranslucent) {
|
||||||
gl.depthFunc(GL.EQUAL);
|
gl.depthFunc(GL.EQUAL);
|
||||||
@ -229,7 +230,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
GL.UNSIGNED_SHORT, eb.off[3]);
|
GL.UNSIGNED_SHORT, eb.off[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw triangle meshes */
|
/* draw triangle meshes (mMesh == true) */
|
||||||
if (eb.idx[4] > 0) {
|
if (eb.idx[4] > 0) {
|
||||||
gl.drawElements(GL.TRIANGLES, eb.idx[4],
|
gl.drawElements(GL.TRIANGLES, eb.idx[4],
|
||||||
GL.UNSIGNED_SHORT, eb.off[4]);
|
GL.UNSIGNED_SHORT, eb.off[4]);
|
||||||
|
@ -47,7 +47,7 @@ public class ExtrusionBucket extends RenderBucket {
|
|||||||
private final int color;
|
private final int color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* indices for: 0. even sides, 1. odd sides, 2. roof, 3. roof outline
|
* indices for: 0. even sides, 1. odd sides, 2. roof, 3. roof outline, 4. mesh
|
||||||
*/
|
*/
|
||||||
public int idx[] = {0, 0, 0, 0, 0};
|
public int idx[] = {0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user