Skip to content

Commit

Permalink
fix Uniform issue related to material changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowislord committed Apr 20, 2016
1 parent e71cf81 commit 3353aea
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions jme3-core/src/main/java/com/jme3/shader/Uniform.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3353aea

Please sign in to comment.