From 3ed2824cc3708d2225f72aae59016471de7e7e23 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sun, 1 May 2011 04:48:10 +0000 Subject: [PATCH] * Sorting ID now reset properly when shader or texture changed git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7377 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core/com/jme3/material/Material.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/engine/src/core/com/jme3/material/Material.java b/engine/src/core/com/jme3/material/Material.java index aadb363c2..aa1accc1d 100644 --- a/engine/src/core/com/jme3/material/Material.java +++ b/engine/src/core/com/jme3/material/Material.java @@ -377,21 +377,22 @@ public class Material implements Cloneable, Savable, Comparable { name = checkSetParam(null, name); MatParamTexture val = getTextureParam(name); - if (val == null) { + if (val == null) throw new IllegalArgumentException("The given texture parameter is not set."); - } else { - int texUnit = val.getUnit(); - paramValues.remove(name); - nextTexUnit--; - for (MatParam param : paramValues.values()) { - if (param instanceof MatParamTexture) { - MatParamTexture texParam = (MatParamTexture) param; - if (texParam.getUnit() > texUnit) { - texParam.setUnit(texParam.getUnit() - 1); - } + + int texUnit = val.getUnit(); + paramValues.remove(name); + nextTexUnit--; + for (MatParam param : paramValues.values()) { + if (param instanceof MatParamTexture) { + MatParamTexture texParam = (MatParamTexture) param; + if (texParam.getUnit() > texUnit) { + texParam.setUnit(texParam.getUnit() - 1); } } } + + sortingId = -1; } public void setTextureParam(String name, VarType type, Texture value) { @@ -410,6 +411,9 @@ public class Material implements Cloneable, Savable, Comparable { if (technique != null) { technique.notifySetParam(name, type, nextTexUnit - 1); } + + // need to recompute sort ID + sortingId = -1; } /** @@ -547,8 +551,7 @@ public class Material implements Cloneable, Savable, Comparable { * @param lightList */ protected void updateLightListUniforms(Shader shader, Geometry g, int numLights) { - if (numLights == 0) // this shader does not do lighting, ignore. - { + if (numLights == 0){ // this shader does not do lighting, ignore. return; } @@ -732,6 +735,9 @@ public class Material implements Cloneable, Savable, Comparable { technique = tech; tech.makeCurrent(def.getAssetManager()); + + // shader was changed + sortingId = -1; } private void autoSelectTechnique(RenderManager rm) {