From 3353aea5467ac8cacdb6c1a7be178a481d96cd4c Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Wed, 20 Apr 2016 16:41:01 -0400 Subject: [PATCH] fix Uniform issue related to material changes --- .../main/java/com/jme3/shader/Uniform.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/shader/Uniform.java b/jme3-core/src/main/java/com/jme3/shader/Uniform.java index 7ed4685284..c377b8ebfb 100644 --- a/jme3-core/src/main/java/com/jme3/shader/Uniform.java +++ b/jme3-core/src/main/java/com/jme3/shader/Uniform.java @@ -39,7 +39,7 @@ public class Uniform extends ShaderVariable { - private static final Integer ZERO_INT = Integer.valueOf(0); + private static final Integer ZERO_INT = 0; private static final Float ZERO_FLT = Float.valueOf(0); private static final FloatBuffer ZERO_BUF = BufferUtils.createFloatBuffer(4*4); @@ -171,13 +171,25 @@ public void clearValue(){ this.value = ZERO_FLT; break; case Vector2: - this.value = Vector2f.ZERO; + if (this.value != null) { + ((Vector2f) this.value).set(Vector2f.ZERO); + } break; case Vector3: - this.value = Vector3f.ZERO; + if (this.value != null) { + ((Vector3f) this.value).set(Vector3f.ZERO); + } break; case Vector4: - this.value = Vector4f.ZERO; + if (this.value != null) { + if (this.value instanceof ColorRGBA) { + ((ColorRGBA) this.value).set(ColorRGBA.BlackNoAlpha); + } else if (this.value instanceof Vector4f) { + ((Vector4f) this.value).set(Vector4f.ZERO); + } else { + ((Quaternion) this.value).set(Quaternion.ZERO); + } + } break; default: // won't happen because those are either textures @@ -312,6 +324,26 @@ public void setValue(VarType type, Object value){ } multiData.clear(); break; + case Vector2: + if (value.equals(this.value)) { + return; + } + if (this.value == null) { + this.value = new Vector2f((Vector2f) value); + } else { + ((Vector2f) this.value).set((Vector2f) value); + } + break; + case Vector3: + if (value.equals(this.value)) { + return; + } + if (this.value == null) { + this.value = new Vector3f((Vector3f) value); + } else { + ((Vector3f) this.value).set((Vector3f) value); + } + break; case Vector4: if (value.equals(this.value)) { return;