Skip to content

Commit 3353aea

Browse files
committed
fix Uniform issue related to material changes
1 parent e71cf81 commit 3353aea

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

jme3-core/src/main/java/com/jme3/shader/Uniform.java

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
public class Uniform extends ShaderVariable {
4141

42-
private static final Integer ZERO_INT = Integer.valueOf(0);
42+
private static final Integer ZERO_INT = 0;
4343
private static final Float ZERO_FLT = Float.valueOf(0);
4444
private static final FloatBuffer ZERO_BUF = BufferUtils.createFloatBuffer(4*4);
4545

@@ -171,13 +171,25 @@ public void clearValue(){
171171
this.value = ZERO_FLT;
172172
break;
173173
case Vector2:
174-
this.value = Vector2f.ZERO;
174+
if (this.value != null) {
175+
((Vector2f) this.value).set(Vector2f.ZERO);
176+
}
175177
break;
176178
case Vector3:
177-
this.value = Vector3f.ZERO;
179+
if (this.value != null) {
180+
((Vector3f) this.value).set(Vector3f.ZERO);
181+
}
178182
break;
179183
case Vector4:
180-
this.value = Vector4f.ZERO;
184+
if (this.value != null) {
185+
if (this.value instanceof ColorRGBA) {
186+
((ColorRGBA) this.value).set(ColorRGBA.BlackNoAlpha);
187+
} else if (this.value instanceof Vector4f) {
188+
((Vector4f) this.value).set(Vector4f.ZERO);
189+
} else {
190+
((Quaternion) this.value).set(Quaternion.ZERO);
191+
}
192+
}
181193
break;
182194
default:
183195
// won't happen because those are either textures
@@ -312,6 +324,26 @@ public void setValue(VarType type, Object value){
312324
}
313325
multiData.clear();
314326
break;
327+
case Vector2:
328+
if (value.equals(this.value)) {
329+
return;
330+
}
331+
if (this.value == null) {
332+
this.value = new Vector2f((Vector2f) value);
333+
} else {
334+
((Vector2f) this.value).set((Vector2f) value);
335+
}
336+
break;
337+
case Vector3:
338+
if (value.equals(this.value)) {
339+
return;
340+
}
341+
if (this.value == null) {
342+
this.value = new Vector3f((Vector3f) value);
343+
} else {
344+
((Vector3f) this.value).set((Vector3f) value);
345+
}
346+
break;
315347
case Vector4:
316348
if (value.equals(this.value)) {
317349
return;

0 commit comments

Comments
 (0)