فهرست منبع

* Fixed heavy string allocation in Technique/MatParam due to m_ prefix workaround

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7656 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
sha..rd 14 سال پیش
والد
کامیت
447fd87d2c

+ 12 - 1
engine/src/core/com/jme3/material/MatParam.java

@@ -60,6 +60,7 @@ public class MatParam implements Savable, Cloneable {
 
 
     protected VarType type;
     protected VarType type;
     protected String name;
     protected String name;
+    protected String prefixedName;
     protected Object value;
     protected Object value;
     protected FixedFuncBinding ffBinding;
     protected FixedFuncBinding ffBinding;
 
 
@@ -69,6 +70,7 @@ public class MatParam implements Savable, Cloneable {
     public MatParam(VarType type, String name, Object value, FixedFuncBinding ffBinding){
     public MatParam(VarType type, String name, Object value, FixedFuncBinding ffBinding){
         this.type = type;
         this.type = type;
         this.name = name;
         this.name = name;
+        this.prefixedName = "m_" + name;
         this.value = value;
         this.value = value;
         this.ffBinding = ffBinding;
         this.ffBinding = ffBinding;
     }
     }
@@ -105,6 +107,15 @@ public class MatParam implements Savable, Cloneable {
         return name;
         return name;
     }
     }
 
 
+    /**
+     * Returns the name with "m_" prefixed to it.
+     * 
+     * @return the name with "m_" prefixed to it
+     */
+    public String getPrefixedName() {
+        return prefixedName;
+    }
+    
     /**
     /**
      * Used internally
      * Used internally
      * @param name 
      * @param name 
@@ -140,7 +151,7 @@ public class MatParam implements Savable, Cloneable {
     void apply(Renderer r, Technique technique) {
     void apply(Renderer r, Technique technique) {
         TechniqueDef techDef = technique.getDef();
         TechniqueDef techDef = technique.getDef();
         if (techDef.isUsingShaders()) {
         if (techDef.isUsingShaders()) {
-            technique.updateUniformParam(getName(), getVarType(), getValue(), true);
+            technique.updateUniformParam(getPrefixedName(), getVarType(), getValue(), true);
         }
         }
         if (ffBinding != null && r instanceof GL1Renderer){
         if (ffBinding != null && r instanceof GL1Renderer){
             ((GL1Renderer)r).setFixedFuncBinding(ffBinding, getValue());
             ((GL1Renderer)r).setFixedFuncBinding(ffBinding, getValue());

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

@@ -45,7 +45,7 @@ public class MatParamTexture extends MatParam {
         TechniqueDef techDef = technique.getDef();
         TechniqueDef techDef = technique.getDef();
         r.setTexture(getUnit(), getTextureValue());
         r.setTexture(getUnit(), getTextureValue());
         if (techDef.isUsingShaders()) {
         if (techDef.isUsingShaders()) {
-            technique.updateUniformParam(getName(), getVarType(), getUnit(), true);
+            technique.updateUniformParam(getPrefixedName(), getVarType(), getUnit(), true);
         }
         }
     }
     }
 
 

+ 0 - 3
engine/src/core/com/jme3/material/Technique.java

@@ -149,9 +149,6 @@ public class Technique implements Savable {
     }
     }
 
 
     void updateUniformParam(String paramName, VarType type, Object value, boolean ifNotOwner) {
     void updateUniformParam(String paramName, VarType type, Object value, boolean ifNotOwner) {
-        if (!paramName.startsWith("m_")) {
-            paramName = "m_" + paramName;
-        }
         Uniform u = shader.getUniform(paramName);
         Uniform u = shader.getUniform(paramName);
 
 
 //        if (ifNotOwner && u.getLastChanger() == owner)
 //        if (ifNotOwner && u.getLastChanger() == owner)