소스 검색

* Ensure that MatParam.value and MatParamTexture.texture always match, and throw exception if they dont

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10208 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
sha..RD 12 년 전
부모
커밋
9eb9463261
1개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 13 1
      engine/src/core/com/jme3/material/MatParamTexture.java

+ 13 - 1
engine/src/core/com/jme3/material/MatParamTexture.java

@@ -62,6 +62,15 @@ public class MatParamTexture extends MatParam {
         this.value = value;
         this.texture = value;
     }
+    
+    @Override
+    public void setValue(Object value) {
+        if (!(value instanceof Texture)) {
+            throw new IllegalArgumentException("value must be a texture object");
+        }
+        this.value = value;
+        this.texture = (Texture) value;
+    }
 
     public void setUnit(int unit) {
         this.unit = unit;
@@ -85,6 +94,8 @@ public class MatParamTexture extends MatParam {
         super.write(ex);
         OutputCapsule oc = ex.getCapsule(this);
         oc.write(unit, "texture_unit", -1);
+        
+        // For backwards compat
         oc.write(texture, "texture", null);
     }
 
@@ -93,6 +104,7 @@ public class MatParamTexture extends MatParam {
         super.read(im);
         InputCapsule ic = im.getCapsule(this);
         unit = ic.readInt("texture_unit", -1);
-        texture = (Texture) ic.readSavable("texture", null);
+        texture = (Texture) value;
+        //texture = (Texture) ic.readSavable("texture", null);
     }
 }