diff --git a/engine/src/core/com/jme3/animation/AnimControl.java b/engine/src/core/com/jme3/animation/AnimControl.java index 02bd46a91..669208755 100644 --- a/engine/src/core/com/jme3/animation/AnimControl.java +++ b/engine/src/core/com/jme3/animation/AnimControl.java @@ -70,52 +70,41 @@ import java.util.HashMap; */ public final class AnimControl extends AbstractControl implements Savable, Cloneable { - /** - * List of targets which this controller effects. - */ - // Mesh[] targets; /** * Skeleton object must contain corresponding data for the targets' weight buffers. */ Skeleton skeleton; + /** only used for backward compatibility */ @Deprecated private SkeletonControl skeletonControl; + /** * List of animations */ HashMap animationMap; + /** * Animation channels */ - transient ArrayList channels = new ArrayList(); - transient ArrayList listeners = new ArrayList(); + private transient ArrayList channels = new ArrayList(); /** - * Create a new AnimControl that will animate the given skins - * using the skeleton and provided animations. - * - * @param model The root node of all the skins specified in - * meshes argument. - * @param meshes The skins, or meshes, to animate. Should have - * properly set BoneIndex and BoneWeight buffers. - * @param skeleton The skeleton structure represents a bone hierarchy - * to be animated. - * @deprecated AnimControl doesnt' hande the skinning anymore, use AnimControl(Skeleton skeleton); - * Then create a SkeletonControl(Node model, Mesh[] meshes, Skeleton skeleton); - * and add it to the spatial. + * Animation event listeners */ - @Deprecated - public AnimControl(Node model, Mesh[] meshes, Skeleton skeleton) { - super(model); - - this.skeleton = skeleton; - - skeletonControl = new SkeletonControl(meshes, this.skeleton); - reset(); - } + private transient ArrayList listeners = new ArrayList(); + /** + * Creates a new animation control for the given skeleton. + * The method {@link AnimControl#setAnimations(java.util.HashMap) } + * must be called after initialization in order for this class to be useful. + * + * @param skeleton The skeleton to animate + */ public AnimControl(Skeleton skeleton) { + if (skeleton == null) + throw new IllegalArgumentException("skeleton cannot be null"); + this.skeleton = skeleton; reset(); } @@ -134,6 +123,8 @@ public final class AnimControl extends AbstractControl implements Savable, Clone clone.spatial = spatial; clone.skeleton = new Skeleton(skeleton); clone.channels = new ArrayList(); + // animationMap is reference-copied, animation data should be shared + // to reduce memory usage. return clone; } catch (CloneNotSupportedException ex) { throw new AssertionError(); @@ -181,28 +172,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone animationMap.remove(anim.getName()); } - /** - * - * @param boneName the name of the bone - * @return the node attached to this bone - * @deprecated use SkeletonControl.getAttachementNode instead. - */ - @Deprecated - public Node getAttachmentsNode(String boneName) { - Bone b = skeleton.getBone(boneName); - if (b == null) { - throw new IllegalArgumentException("Given bone name does not exist " - + "in the skeleton."); - } - - Node n = b.getAttachmentsNode(); - if (spatial != null) { - Node model = (Node) spatial; - model.attachChild(n); - } - return n; - } - /** * Create a new animation channel, by default assigned to all bones * in the skeleton. @@ -253,17 +222,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone return skeleton; } - /** - * @return The targets, or skins, being influenced by this - * AnimControl. - * @deprecated use SkeletonControl.getTargets() instead - * get the SkeletonControl doing spatial.getControl(SkeletonControl.class); - */ - @Deprecated - public Mesh[] getTargets() { - return skeletonControl.getTargets(); - } - /** * Adds a new listener to receive animation related events. * @param listener The listener to add. @@ -317,8 +275,10 @@ public final class AnimControl extends AbstractControl implements Savable, Clone //Backward compatibility. if (skeletonControl != null) { spatial.addControl(skeletonControl); + // once the skeleton control is added to the spatial, + // the AnimControl returns to "non-compatible" mode. + skeletonControl = null; } - } final void reset() { @@ -380,7 +340,6 @@ public final class AnimControl extends AbstractControl implements Savable, Clone skeleton = (Skeleton) in.readSavable("skeleton", null); animationMap = (HashMap) in.readStringSavableMap("animations", null); - //changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split //if we find a target mesh array the AnimControl creates the SkeletonControl for old files and add it to the spatial. //When backward compatibility won't be needed anymore this can deleted @@ -392,7 +351,5 @@ public final class AnimControl extends AbstractControl implements Savable, Clone skeletonControl = new SkeletonControl(tg, skeleton); spatial.addControl(skeletonControl); } - //------ - } } diff --git a/engine/src/core/com/jme3/material/Material.java b/engine/src/core/com/jme3/material/Material.java index 0292d93c5..9cf80adf1 100644 --- a/engine/src/core/com/jme3/material/Material.java +++ b/engine/src/core/com/jme3/material/Material.java @@ -694,7 +694,7 @@ public class Material implements Cloneable, Savable, Comparable { if (name.equals("Default")) { List techDefs = def.getDefaultTechniques(); - if (techDefs == null || techDefs.size() == 0) { + if (techDefs == null || techDefs.isEmpty()) { throw new IllegalStateException("No default techniques are available on material '" + def.getName() + "'"); } @@ -723,7 +723,7 @@ public class Material implements Cloneable, Savable, Comparable { if (!rendererCaps.containsAll(techDef.getRequiredCaps())) { throw new UnsupportedOperationException("The explicitly chosen technique '" + name + "' on material '" + def.getName() + "'\n" - + "requires caps " + techDef.getRequiredCaps() + " which are not" + + "requires caps " + techDef.getRequiredCaps() + " which are not " + "supported by the video renderer"); } diff --git a/engine/src/core/com/jme3/scene/Mesh.java b/engine/src/core/com/jme3/scene/Mesh.java index c03afc215..b43366255 100644 --- a/engine/src/core/com/jme3/scene/Mesh.java +++ b/engine/src/core/com/jme3/scene/Mesh.java @@ -749,11 +749,9 @@ public class Mesh implements Savable, Cloneable { // in.readStringSavableMap("buffers", null); buffers = (IntMap) in.readIntSavableMap("buffers", null); Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null); - if(lodLevelsSavable!=null){ + if (lodLevelsSavable != null) { lodLevels = new VertexBuffer[lodLevelsSavable.length]; - for (int i = 0; i < lodLevels.length; i++){ - lodLevels[i] = (VertexBuffer) lodLevelsSavable[i]; - } + System.arraycopy( lodLevelsSavable, 0, lodLevels, 0, lodLevels.length); } } diff --git a/engine/src/core/com/jme3/scene/control/AbstractControl.java b/engine/src/core/com/jme3/scene/control/AbstractControl.java index 20117ccba..25865a5cc 100644 --- a/engine/src/core/com/jme3/scene/control/AbstractControl.java +++ b/engine/src/core/com/jme3/scene/control/AbstractControl.java @@ -51,16 +51,6 @@ public abstract class AbstractControl implements Control { protected boolean enabled = true; protected Spatial spatial; - /** - * @param spatial - * @deprecated The spatial parameter is passed in {@link AbstractControl#setSpatial(com.jme3.scene.Spatial) } - * automatically. - */ - @Deprecated - public AbstractControl(Spatial spatial){ - this.spatial = spatial; - } - public AbstractControl(){ } diff --git a/engine/src/test/jme3test/audio/AudioApp.java b/engine/src/test/jme3test/audio/AudioApp.java index 2770e25c3..01b80355e 100644 --- a/engine/src/test/jme3test/audio/AudioApp.java +++ b/engine/src/test/jme3test/audio/AudioApp.java @@ -43,20 +43,20 @@ public class AudioApp { private static final float UPDATE_RATE = 0.01f; - protected AssetManager manager; + protected AssetManager assetManager; protected Listener listener; - protected AudioRenderer ar; + protected AudioRenderer audioRenderer; public AudioApp(){ AppSettings settings = new AppSettings(true); settings.setRenderer(null); // force dummy renderer (?) settings.setAudioRenderer(AppSettings.LWJGL_OPENAL); - ar = JmeSystem.newAudioRenderer(settings); - ar.initialize(); - manager = new DesktopAssetManager(true); + audioRenderer = JmeSystem.newAudioRenderer(settings); + audioRenderer.initialize(); + assetManager = new DesktopAssetManager(true); listener = new Listener(); - ar.setListener(listener); + audioRenderer.setListener(listener); } public void initAudioApp(){ @@ -70,7 +70,7 @@ public class AudioApp { while (true){ updateAudioApp(UPDATE_RATE); - ar.update(UPDATE_RATE); + audioRenderer.update(UPDATE_RATE); try{ Thread.sleep((int) (UPDATE_RATE * 1000f)); diff --git a/engine/src/test/jme3test/audio/TestAmbient.java b/engine/src/test/jme3test/audio/TestAmbient.java index 79fd160be..e0bc143a1 100644 --- a/engine/src/test/jme3test/audio/TestAmbient.java +++ b/engine/src/test/jme3test/audio/TestAmbient.java @@ -51,10 +51,10 @@ public class TestAmbient extends AudioApp { @Override public void initAudioApp(){ - waves = new AudioNode(manager, "Sound/Environment/Ocean Waves.ogg", false); + waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false); waves.setPositional(true); - nature = new AudioNode(manager, "Sound/Environment/Nature.ogg", true); + nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true); // river = new AudioSource(manager, "sounds/river.ogg"); // float[] eax = new float[] @@ -69,8 +69,8 @@ public class TestAmbient extends AudioApp { waves.setRefDistance(1); nature.setVolume(3); - ar.playSourceInstance(waves); - ar.playSource(nature); + audioRenderer.playSourceInstance(waves); + audioRenderer.playSource(nature); } @Override diff --git a/engine/src/test/jme3test/audio/TestDoppler.java b/engine/src/test/jme3test/audio/TestDoppler.java index fd9cff3fe..ac07a4c3e 100644 --- a/engine/src/test/jme3test/audio/TestDoppler.java +++ b/engine/src/test/jme3test/audio/TestDoppler.java @@ -52,10 +52,10 @@ public class TestDoppler extends AudioApp { @Override public void initAudioApp(){ - ufo = new AudioNode(manager, "Sound/Effects/Beep.ogg", false); + ufo = new AudioNode(assetManager, "Sound/Effects/Beep.ogg", false); ufo.setPositional(true); ufo.setLooping(true); - ar.playSource(ufo); + audioRenderer.playSource(ufo); } @Override diff --git a/engine/src/test/jme3test/audio/TestOgg.java b/engine/src/test/jme3test/audio/TestOgg.java index fd21b457c..9d37c1f57 100644 --- a/engine/src/test/jme3test/audio/TestOgg.java +++ b/engine/src/test/jme3test/audio/TestOgg.java @@ -47,20 +47,20 @@ public class TestOgg extends AudioApp { @Override public void initAudioApp(){ System.out.println("Playing without filter"); - src = new AudioNode(manager, "Sound/Effects/Foot steps.ogg", true); - ar.playSource(src); + src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true); + audioRenderer.playSource(src); } @Override public void updateAudioApp(float tpf){ if (src.getStatus() != AudioNode.Status.Playing){ - ar.deleteAudioData(src.getAudioData()); + audioRenderer.deleteAudioData(src.getAudioData()); System.out.println("Playing with low pass filter"); - src = new AudioNode(manager, "Sound/Effects/Foot steps.ogg", true); + src = new AudioNode(assetManager, "Sound/Effects/Foot steps.ogg", true); src.setDryFilter(new LowPassFilter(1f, .1f)); src.setVolume(3); - ar.playSource(src); + audioRenderer.playSource(src); } } diff --git a/engine/src/test/jme3test/audio/TestReverb.java b/engine/src/test/jme3test/audio/TestReverb.java index 53fa9543e..93a79e70a 100644 --- a/engine/src/test/jme3test/audio/TestReverb.java +++ b/engine/src/test/jme3test/audio/TestReverb.java @@ -51,7 +51,7 @@ public class TestReverb extends AudioApp { @Override public void initAudioApp(){ - src = new AudioNode(manager, "Sound/Effects/Bang.wav"); + src = new AudioNode(assetManager, "Sound/Effects/Bang.wav"); float[] eax = new float[] {15, 38.0f, 0.300f, -1000, -3300, 0, 1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f,0.00f,0.00f, -229, 0.088f, 0.00f,0.00f,0.00f, 0.125f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } @@ -59,7 +59,7 @@ public class TestReverb extends AudioApp { // ar.setEnvironment(new Environment(eax)); Environment env = Environment.Cavern; - ar.setEnvironment(env); + audioRenderer.setEnvironment(env); } @Override @@ -75,7 +75,7 @@ public class TestReverb extends AudioApp { v.subtractLocal(20, 1, 20); src.setLocalTranslation(v); - ar.playSourceInstance(src); + audioRenderer.playSourceInstance(src); time = 0; nextTime = FastMath.nextRandomFloat() * 2 + 0.5f; } diff --git a/engine/src/test/jme3test/audio/TestWav.java b/engine/src/test/jme3test/audio/TestWav.java index f6710b00e..ee3666454 100644 --- a/engine/src/test/jme3test/audio/TestWav.java +++ b/engine/src/test/jme3test/audio/TestWav.java @@ -55,7 +55,7 @@ public class TestWav extends AudioApp { public void updateAudioApp(float tpf){ time += tpf; if (time > .1f){ - ar.playSourceInstance(src); + audioRenderer.playSourceInstance(src); time = 0; } @@ -63,7 +63,7 @@ public class TestWav extends AudioApp { @Override public void initAudioApp(){ - src = new AudioNode(manager, "Sound/Effects/Gun.wav", false); + src = new AudioNode(assetManager, "Sound/Effects/Gun.wav", false); src.setLooping(false); }