Bugfix for textures loading: when one texture had several mappings it might not have appeared on the scene at all.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9520 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
a85db87169
commit
0e24cf969b
@ -269,23 +269,30 @@ public final class MaterialContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method sorts the textures by their mapping type.
|
* This method sorts the textures by their mapping type. In each group only
|
||||||
* In each group only textures of one type are put (either two- or three-dimensional).
|
* textures of one type are put (either two- or three-dimensional). If the
|
||||||
* If the mapping type is MTEX_COL then if the texture has no alpha channel then all textures before it are
|
* mapping type is MTEX_COL then if the texture has no alpha channel then
|
||||||
* discarded and will not be loaded and merged because texture with no alpha will cover them anyway.
|
* all textures before it are discarded and will not be loaded and merged
|
||||||
|
* because texture with no alpha will cover them anyway.
|
||||||
|
*
|
||||||
* @return a map with sorted and filtered textures
|
* @return a map with sorted and filtered textures
|
||||||
*/
|
*/
|
||||||
private Map<Number, List<TextureData>> sortAndFilterTextures(List<TextureData> textures) {
|
private Map<Number, List<TextureData>> sortAndFilterTextures(List<TextureData> textures) {
|
||||||
|
int[] mappings = new int[] { MTEX_COL, MTEX_NOR, MTEX_EMIT, MTEX_SPEC, MTEX_ALPHA };
|
||||||
Map<Number, List<TextureData>> result = new HashMap<Number, List<TextureData>>();
|
Map<Number, List<TextureData>> result = new HashMap<Number, List<TextureData>>();
|
||||||
for (TextureData data : textures) {
|
for (TextureData data : textures) {
|
||||||
Number mapto = (Number) data.mtex.getFieldValue("mapto");
|
Number mapto = (Number) data.mtex.getFieldValue("mapto");
|
||||||
List<TextureData> datas = result.get(mapto);
|
for (int i = 0; i < mappings.length; ++i) {
|
||||||
|
if((mappings[i] & mapto.intValue()) != 0) {
|
||||||
|
List<TextureData> datas = result.get(mappings[i]);
|
||||||
if (datas == null) {
|
if (datas == null) {
|
||||||
datas = new ArrayList<TextureData>();
|
datas = new ArrayList<TextureData>();
|
||||||
result.put(mapto, datas);
|
result.put(mappings[i], datas);
|
||||||
}
|
}
|
||||||
datas.add(data);
|
datas.add(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user