* 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
This commit is contained in:
parent
2ded30739d
commit
447fd87d2c
@ -60,6 +60,7 @@ public class MatParam implements Savable, Cloneable {
|
||||
|
||||
protected VarType type;
|
||||
protected String name;
|
||||
protected String prefixedName;
|
||||
protected Object value;
|
||||
protected FixedFuncBinding ffBinding;
|
||||
|
||||
@ -69,6 +70,7 @@ public class MatParam implements Savable, Cloneable {
|
||||
public MatParam(VarType type, String name, Object value, FixedFuncBinding ffBinding){
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.prefixedName = "m_" + name;
|
||||
this.value = value;
|
||||
this.ffBinding = ffBinding;
|
||||
}
|
||||
@ -105,6 +107,15 @@ public class MatParam implements Savable, Cloneable {
|
||||
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
|
||||
* @param name
|
||||
@ -140,7 +151,7 @@ public class MatParam implements Savable, Cloneable {
|
||||
void apply(Renderer r, Technique technique) {
|
||||
TechniqueDef techDef = technique.getDef();
|
||||
if (techDef.isUsingShaders()) {
|
||||
technique.updateUniformParam(getName(), getVarType(), getValue(), true);
|
||||
technique.updateUniformParam(getPrefixedName(), getVarType(), getValue(), true);
|
||||
}
|
||||
if (ffBinding != null && r instanceof GL1Renderer){
|
||||
((GL1Renderer)r).setFixedFuncBinding(ffBinding, getValue());
|
||||
|
@ -45,7 +45,7 @@ public class MatParamTexture extends MatParam {
|
||||
TechniqueDef techDef = technique.getDef();
|
||||
r.setTexture(getUnit(), getTextureValue());
|
||||
if (techDef.isUsingShaders()) {
|
||||
technique.updateUniformParam(getName(), getVarType(), getUnit(), true);
|
||||
technique.updateUniformParam(getPrefixedName(), getVarType(), getUnit(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,9 +149,6 @@ public class Technique implements Savable {
|
||||
}
|
||||
|
||||
void updateUniformParam(String paramName, VarType type, Object value, boolean ifNotOwner) {
|
||||
if (!paramName.startsWith("m_")) {
|
||||
paramName = "m_" + paramName;
|
||||
}
|
||||
Uniform u = shader.getUniform(paramName);
|
||||
|
||||
// if (ifNotOwner && u.getLastChanger() == owner)
|
||||
|
Loading…
x
Reference in New Issue
Block a user