Prechádzať zdrojové kódy

* Added fix for when an mesh xml animation has no tracks will no longer throw NPE
* FileLocator now supports "." as a path

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7990 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sha..rd 14 rokov pred
rodič
commit
77dd6761ee

+ 3 - 2
engine/src/core/com/jme3/animation/AnimChannel.java

@@ -344,10 +344,11 @@ public final class AnimChannel {
         time += tpf * speed;
 
         if (animation.getLength() > 0){
-            if (time >= animation.getLength())
+            if (time >= animation.getLength()) {
                 control.notifyAnimCycleDone(this, animation.getName());
-            else if (time < 0)
+            } else if (time < 0) {
                 control.notifyAnimCycleDone(this, animation.getName());
+            } 
         }
 
         time = clampWrapTime(time, animation.getLength(), loopMode);

+ 3 - 0
engine/src/core/com/jme3/animation/BoneAnimation.java

@@ -113,6 +113,9 @@ public final class BoneAnimation implements Animation, Savable, Cloneable {
         BitSet affectedBones = channel.getAffectedBones();
         Skeleton skeleton = control.getSkeleton();
         
+        if (tracks == null)
+            return;
+        
         for (int i = 0; i < tracks.length; i++) {
             if (affectedBones == null
                     || affectedBones.get(tracks[i].getTargetBoneIndex())) {

+ 12 - 6
engine/src/desktop/com/jme3/asset/plugins/FileLocator.java

@@ -56,10 +56,15 @@ public class FileLocator implements AssetLocator {
     public void setRootPath(String rootPath) {
         if (rootPath == null)
             throw new NullPointerException();
-
-        root = new File(rootPath);
-        if (!root.isDirectory())
-            throw new IllegalArgumentException("Given root path \"" + root + "\" not a directory");
+        
+        try {
+            root = new File(rootPath).getCanonicalFile();
+            if (!root.isDirectory()){
+                throw new IllegalArgumentException("Given root path \"" + root + "\" not a directory");
+            }
+        } catch (IOException ex) {
+            throw new AssetLoadException("Root path is invalid", ex);
+        }
     }
 
     private static class AssetInfoFile extends AssetInfo {
@@ -76,7 +81,9 @@ public class FileLocator implements AssetLocator {
             try{
                 return new FileInputStream(file);
             }catch (FileNotFoundException ex){
-                return null;
+                // NOTE: Can still happen even if file.exists() is true, e.g.
+                // permissions issue and similar
+                throw new AssetLoadException("Failed to open file: " + file, ex);
             }
         }
     }
@@ -97,7 +104,6 @@ public class FileLocator implements AssetLocator {
                 throw new AssetLoadException("Failed to get file canonical path " + file, ex);
             }
             
-            
             return new AssetInfoFile(manager, key, file);
         }else{
             return null;