|
|
@ -103,6 +103,10 @@ public class Uniform extends ShaderVariable { |
|
|
|
return value; |
|
|
|
return value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public FloatBuffer getMultiData() { |
|
|
|
|
|
|
|
return multiData; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isSetByCurrentMaterial() { |
|
|
|
public boolean isSetByCurrentMaterial() { |
|
|
|
return setByCurrentMaterial; |
|
|
|
return setByCurrentMaterial; |
|
|
|
} |
|
|
|
} |
|
|
@ -111,21 +115,6 @@ public class Uniform extends ShaderVariable { |
|
|
|
setByCurrentMaterial = false; |
|
|
|
setByCurrentMaterial = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void setVector4(Vector4f vec, Object value) { |
|
|
|
|
|
|
|
if (value instanceof ColorRGBA) { |
|
|
|
|
|
|
|
ColorRGBA color = (ColorRGBA) value; |
|
|
|
|
|
|
|
vec.set(color.r, color.g, color.b, color.a); |
|
|
|
|
|
|
|
} else if (value instanceof Quaternion) { |
|
|
|
|
|
|
|
Quaternion quat = (Quaternion) value; |
|
|
|
|
|
|
|
vec.set(quat.getX(), quat.getY(), quat.getZ(), quat.getW()); |
|
|
|
|
|
|
|
} else if (value instanceof Vector4f) { |
|
|
|
|
|
|
|
Vector4f vec4 = (Vector4f) value; |
|
|
|
|
|
|
|
vec.set(vec4); |
|
|
|
|
|
|
|
} else{ |
|
|
|
|
|
|
|
throw new IllegalArgumentException(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void clearValue(){ |
|
|
|
public void clearValue(){ |
|
|
|
updateNeeded = true; |
|
|
|
updateNeeded = true; |
|
|
|
|
|
|
|
|
|
|
@ -189,20 +178,36 @@ public class Uniform extends ShaderVariable { |
|
|
|
|
|
|
|
|
|
|
|
switch (type){ |
|
|
|
switch (type){ |
|
|
|
case Matrix3: |
|
|
|
case Matrix3: |
|
|
|
|
|
|
|
if (value.equals(this.value)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
Matrix3f m3 = (Matrix3f) value; |
|
|
|
Matrix3f m3 = (Matrix3f) value; |
|
|
|
if (multiData == null) { |
|
|
|
if (multiData == null) { |
|
|
|
multiData = BufferUtils.createFloatBuffer(9); |
|
|
|
multiData = BufferUtils.createFloatBuffer(9); |
|
|
|
} |
|
|
|
} |
|
|
|
m3.fillFloatBuffer(multiData, true); |
|
|
|
m3.fillFloatBuffer(multiData, true); |
|
|
|
multiData.clear(); |
|
|
|
multiData.clear(); |
|
|
|
|
|
|
|
if (this.value == null) { |
|
|
|
|
|
|
|
this.value = new Matrix3f(m3); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
((Matrix3f)this.value).set(m3); |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case Matrix4: |
|
|
|
case Matrix4: |
|
|
|
|
|
|
|
if (value.equals(this.value)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
Matrix4f m4 = (Matrix4f) value; |
|
|
|
Matrix4f m4 = (Matrix4f) value; |
|
|
|
if (multiData == null) { |
|
|
|
if (multiData == null) { |
|
|
|
multiData = BufferUtils.createFloatBuffer(16); |
|
|
|
multiData = BufferUtils.createFloatBuffer(16); |
|
|
|
} |
|
|
|
} |
|
|
|
m4.fillFloatBuffer(multiData, true); |
|
|
|
m4.fillFloatBuffer(multiData, true); |
|
|
|
multiData.clear(); |
|
|
|
multiData.clear(); |
|
|
|
|
|
|
|
if (this.value == null) { |
|
|
|
|
|
|
|
this.value = new Matrix4f(m4); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
((Matrix4f)this.value).copy(m4); |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IntArray: |
|
|
|
case IntArray: |
|
|
|
int[] ia = (int[]) value; |
|
|
|
int[] ia = (int[]) value; |
|
|
@ -283,11 +288,32 @@ public class Uniform extends ShaderVariable { |
|
|
|
} |
|
|
|
} |
|
|
|
multiData.clear(); |
|
|
|
multiData.clear(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case Vector4: |
|
|
|
|
|
|
|
if (value.equals(this.value)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (value instanceof ColorRGBA) { |
|
|
|
|
|
|
|
if (this.value == null) { |
|
|
|
|
|
|
|
this.value = new ColorRGBA(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
((ColorRGBA) this.value).set((ColorRGBA) value); |
|
|
|
|
|
|
|
} else if (value instanceof Vector4f) { |
|
|
|
|
|
|
|
if (this.value == null) { |
|
|
|
|
|
|
|
this.value = new Vector4f(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
((Vector4f) this.value).set((Vector4f) value); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (this.value == null) { |
|
|
|
|
|
|
|
this.value = new Quaternion(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
((Quaternion) this.value).set((Quaternion) value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
// Only use check if equals optimization for primitive values
|
|
|
|
// Only use check if equals optimization for primitive values
|
|
|
|
case Int: |
|
|
|
case Int: |
|
|
|
case Float: |
|
|
|
case Float: |
|
|
|
case Boolean: |
|
|
|
case Boolean: |
|
|
|
if (this.value != null && this.value.equals(value)) { |
|
|
|
if (value.equals(this.value)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.value = value; |
|
|
|
this.value = value; |
|
|
@ -297,9 +323,9 @@ public class Uniform extends ShaderVariable { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (multiData != null) { |
|
|
|
// if (multiData != null) {
|
|
|
|
this.value = multiData; |
|
|
|
// this.value = multiData;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
varType = type; |
|
|
|
varType = type; |
|
|
|
updateNeeded = true; |
|
|
|
updateNeeded = true; |
|
|
|