Allow multiple TextureAtlas per SymbolBucket (#303)

This commit is contained in:
Longri
2017-02-24 18:47:17 +01:00
committed by Emux
parent 325f848969
commit 5480cd6df8
3 changed files with 152 additions and 3 deletions

17
vtm/src/org/oscim/renderer/bucket/SymbolBucket.java Normal file → Executable file
View File

@@ -80,6 +80,7 @@ public final class SymbolBucket extends TextureBucket {
prevTextures = textures;
textures = null;
TextureItem t = null;
TextureItem lastTexture = null;
for (SymbolItem it = mSymbols.head(); it != null; ) {
int width = 0, height = 0;
@@ -88,12 +89,24 @@ public final class SymbolBucket extends TextureBucket {
// FIXME Use simultaneously TextureAtlas and external symbols
if (it.texRegion != null) {
/* FIXME This work only with one TextureAtlas per SymbolBucket */
if (textures == null) {
if (it.texRegion.texture.id == -1) {
//upload texture for give correct texID
it.texRegion.texture.upload();
}
if (textures == null || lastTexture == null || lastTexture.id != it.texRegion.texture.id) {
/* clone TextureItem to use same texID with
* multiple TextureItem */
int nextOffset = 0;
if (t != null) {
nextOffset = t.offset + t.indices;
}
t = TextureItem.clone(it.texRegion.texture);
t.offset = nextOffset;
textures = Inlist.appendItem(textures, t);
lastTexture = t;
}
TextureAtlas.Rect r = it.texRegion.rect;

3
vtm/src/org/oscim/renderer/bucket/TextureItem.java Normal file → Executable file
View File

@@ -1,6 +1,7 @@
/*
* Copyright 2012, 2013 Hannes Janetzek
* Copyright 2016 devemux86
* Copyright 2017 Longri
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -42,7 +43,7 @@ public class TextureItem extends Inlist<TextureItem> {
/**
* texture ID
*/
private int id;
int id;
/**
* current settings