According to the comment on resetFirstLast(),
"it updates firstTexture to be the first non-null Texture, and lastTexture to be the last non-null texture."
It is called at setTexture() but not at removeTexture()
Index: src/com/jme/scene/state/TextureState.java
===================================================================
--- src/com/jme/scene/state/TextureState.java (revision 4138)
+++ src/com/jme/scene/state/TextureState.java (working copy)
@@ -273,6 +273,8 @@
texture.set(index, null);
idCache[index] = 0;
+ resetFirstLast();
+ setNeedsRefresh(true);
return true;
}
@@ -287,6 +289,8 @@
texture.set(textureUnit, null);
idCache[textureUnit] = 0;
+ resetFirstLast();
+ setNeedsRefresh(true);
return true;
}