Fixed an issue with J3MLoader thinking certain texture path patterns with new texture options still looked like old style and hence ignoring new options and getting the texture path wrong.

cleanup_build_scripts
Daniel Johansson 9 years ago
parent e530fa644b
commit 9f9cb824cd
  1. 22
      jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java
  2. 2
      jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java
  3. 3
      jme3-core/src/test/resources/texture-parameters-newstyle.j3m

@ -169,9 +169,23 @@ public class J3MLoader implements AssetLoader {
return matchList;
}
private boolean isTexturePathDeclaredTheTraditionalWay(final int numberOfValues, final int numberOfTextureOptions, final String texturePath) {
return (numberOfValues > 1 && (texturePath.startsWith("Flip Repeat ") || texturePath.startsWith("Flip ") ||
texturePath.startsWith("Repeat ") || texturePath.startsWith("Repeat Flip "))) || numberOfTextureOptions == 0;
private boolean isTexturePathDeclaredTheTraditionalWay(final List<TextureOptionValue> optionValues, final String texturePath) {
final boolean startsWithOldStyle = texturePath.startsWith("Flip Repeat ") || texturePath.startsWith("Flip ") ||
texturePath.startsWith("Repeat ") || texturePath.startsWith("Repeat Flip ");
if (!startsWithOldStyle) {
return false;
}
if (optionValues.size() == 1 && (optionValues.get(0).textureOption == TextureOption.Flip || optionValues.get(0).textureOption == TextureOption.Repeat)) {
return true;
} else if (optionValues.size() == 2 && optionValues.get(0).textureOption == TextureOption.Flip && optionValues.get(1).textureOption == TextureOption.Repeat) {
return true;
} else if (optionValues.size() == 2 && optionValues.get(0).textureOption == TextureOption.Repeat && optionValues.get(1).textureOption == TextureOption.Flip) {
return true;
}
return false;
}
private Texture parseTextureType(final VarType type, final String value) {
@ -187,7 +201,7 @@ public class J3MLoader implements AssetLoader {
String texturePath = value.trim();
// If there are no valid "new" texture options specified but the path is split into several parts, lets parse the old way.
if (isTexturePathDeclaredTheTraditionalWay(textureValues.size(), textureOptionValues.size(), texturePath)) {
if (isTexturePathDeclaredTheTraditionalWay(textureOptionValues, texturePath)) {
boolean flipY = false;
if (texturePath.startsWith("Flip Repeat ") || texturePath.startsWith("Repeat Flip ")) {

@ -80,6 +80,7 @@ public class J3MLoaderTest {
final Texture textureMin = Mockito.mock(Texture.class);
final Texture textureMag = Mockito.mock(Texture.class);
final Texture textureCombined = Mockito.mock(Texture.class);
final Texture textureLooksLikeOldStyle = Mockito.mock(Texture.class);
final TextureKey textureKeyNoParameters = setupMockForTexture("Empty", "empty.png", false, textureNoParameters);
final TextureKey textureKeyFlip = setupMockForTexture("Flip", "flip.png", true, textureFlip);
@ -88,6 +89,7 @@ public class J3MLoaderTest {
setupMockForTexture("Min", "min.png", false, textureMin);
setupMockForTexture("Mag", "mag.png", false, textureMag);
setupMockForTexture("Combined", "combined.png", true, textureCombined);
setupMockForTexture("LooksLikeOldStyle", "oldstyle.png", true, textureLooksLikeOldStyle);
j3MLoader.load(assetInfo);

@ -6,6 +6,7 @@ Material Test : matdef.j3md {
Min: MinTrilinear "min.png"
Mag: MagBilinear "mag.png"
RepeatAxis: WrapRepeat_T "repeat-axis.png"
Combined: MagNearest MinBilinearNoMipMaps Flip WrapRepeat "combined.png"
Combined: Flip MagNearest MinBilinearNoMipMaps WrapRepeat "combined.png"
LooksLikeOldStyle: Flip WrapRepeat "oldstyle.png"
}
}
Loading…
Cancel
Save