|
39 | 39 |
|
40 | 40 | public class Uniform extends ShaderVariable { |
41 | 41 |
|
42 | | - private static final Integer ZERO_INT = Integer.valueOf(0); |
| 42 | + private static final Integer ZERO_INT = 0; |
43 | 43 | private static final Float ZERO_FLT = Float.valueOf(0); |
44 | 44 | private static final FloatBuffer ZERO_BUF = BufferUtils.createFloatBuffer(4*4); |
45 | 45 |
|
@@ -171,13 +171,25 @@ public void clearValue(){ |
171 | 171 | this.value = ZERO_FLT; |
172 | 172 | break; |
173 | 173 | case Vector2: |
174 | | - this.value = Vector2f.ZERO; |
| 174 | + if (this.value != null) { |
| 175 | + ((Vector2f) this.value).set(Vector2f.ZERO); |
| 176 | + } |
175 | 177 | break; |
176 | 178 | case Vector3: |
177 | | - this.value = Vector3f.ZERO; |
| 179 | + if (this.value != null) { |
| 180 | + ((Vector3f) this.value).set(Vector3f.ZERO); |
| 181 | + } |
178 | 182 | break; |
179 | 183 | 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 | + } |
181 | 193 | break; |
182 | 194 | default: |
183 | 195 | // won't happen because those are either textures |
@@ -312,6 +324,26 @@ public void setValue(VarType type, Object value){ |
312 | 324 | } |
313 | 325 | multiData.clear(); |
314 | 326 | 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; |
315 | 347 | case Vector4: |
316 | 348 | if (value.equals(this.value)) { |
317 | 349 | return; |
|
0 commit comments