Move update logic into DefineList.

experimental
Hannes Nevalainen 10 years ago
parent 068ab69ed9
commit 3d6656463e
  1. 16
      jme3-core/src/main/java/com/jme3/material/Technique.java
  2. 24
      jme3-core/src/main/java/com/jme3/shader/DefineList.java

@ -179,21 +179,7 @@ public class Technique /* implements Savable */ {
} }
if (techniqueSwitched) { if (techniqueSwitched) {
// If the technique was switched, check if the define list changed if (defines.update(owner.getParamsMap(), def)) {
// based on material parameters.
ListMap params = owner.getParamsMap();
if (!defines.equalsParams(params, def)) {
// Defines were changed, update define list
defines.clear();
for(int i=0;i<params.size();i++) {
MatParam param = (MatParam)params.getValue(i);
String defineName = def.getShaderParamDefine(param.getName());
if (defineName != null) {
defines.set(defineName, param.getVarType(), param.getValue());
}
}
needReload = true; needReload = true;
} }
} }

@ -182,7 +182,29 @@ public class DefineList implements Savable, Cloneable {
return defines.equals(other.defines); return defines.equals(other.defines);
} }
public boolean equalsParams(ListMap params, TechniqueDef def) { /**
* Update defines if the define list changed based on material parameters.
* @param params
* @param def
* @return true if defines was updated
*/
public boolean update(ListMap params, TechniqueDef def){
if(equalsParams(params, def)){
return false;
}
// Defines were changed, update define list
clear();
for(int i=0;i<params.size();i++) {
MatParam param = (MatParam)params.getValue(i);
String defineName = def.getShaderParamDefine(param.getName());
if (defineName != null) {
set(defineName, param.getVarType(), param.getValue());
}
}
return true;
}
private boolean equalsParams(ListMap params, TechniqueDef def) {
int size = 0; int size = 0;

Loading…
Cancel
Save