Modified BitmapTextPage to always deep clone its mesh since otherwise

BitmapText objects end up sharing them and that's bad.
revert-573-cleanup_build_scripts
Paul Speed 8 years ago
parent 4952ad0cb5
commit 92b5d40003
  1. 23
      jme3-core/src/main/java/com/jme3/font/BitmapTextPage.java

@ -38,10 +38,12 @@ import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Type;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
import com.jme3.util.clone.Cloner;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.LinkedList;
/** /**
* One page per BitmapText Font Texture. * One page per BitmapText Font Texture.
@ -119,10 +121,29 @@ class BitmapTextPage extends Geometry {
@Override @Override
public BitmapTextPage clone() { public BitmapTextPage clone() {
BitmapTextPage clone = (BitmapTextPage) super.clone(); BitmapTextPage clone = (BitmapTextPage) super.clone();
clone.mesh = mesh.deepClone(); //clone.mesh = mesh.deepClone();
return clone; return clone;
} }
/**
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
*/
@Override
public void cloneFields( Cloner cloner, Object original ) {
Mesh originalMesh = this.mesh;
super.cloneFields(cloner, original);
// BitmapTextPage always requires a new mesh or different
// BitmapText instances will clobber one another.
// But if we were already deep cloning meshes then we don't
// want to do it again... so we'll check first.
if( this.mesh == originalMesh ) {
this.mesh = mesh.deepClone();
}
}
// Here is where one might add JmeCloneable related stuff except // Here is where one might add JmeCloneable related stuff except
// the old clone() method doesn't actually bother to clone anything. // the old clone() method doesn't actually bother to clone anything.
// The arrays and the pageQuads are shared across all BitmapTextPage // The arrays and the pageQuads are shared across all BitmapTextPage

Loading…
Cancel
Save