Changed license to Creative Commons Zero (CC0).
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / raster / shapes / basic / GlowingPoint.java
index 4dd454f..fcbef26 100644 (file)
@@ -1,10 +1,8 @@
 /*
- * Sixth 3D engine. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko. 
+ * This project is released under Creative Commons Zero (CC0) license.
  *
+*
  */
 
 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic;
@@ -20,20 +18,26 @@ import java.util.WeakHashMap;
 public class GlowingPoint extends ForwardOrientedTexture {
 
     private static final int TEXTURE_SIZE = 50;
+    private static final Set<GlowingPoint> glowingPoints = Collections.newSetFromMap(new WeakHashMap<>());
     private final Color color;
 
-    private static final Set<GlowingPoint> glowingPoints = Collections.newSetFromMap(new WeakHashMap<GlowingPoint, Boolean>());
-
     public GlowingPoint(final Point3D point, final double pointSize,
                         final Color color) {
         super(point, pointSize, getTexture(color));
         this.color = color;
+
+        synchronized (glowingPoints) {
+            glowingPoints.add(this);
+        }
     }
 
     private static Texture getTexture(final Color color) {
         // attempt to reuse texture from existing glowing point of the same color
-        for (GlowingPoint glowingPoint : glowingPoints)
-            if (color.equals(glowingPoint.color)) return glowingPoint.texture;
+        synchronized (glowingPoints) {
+            for (GlowingPoint glowingPoint : glowingPoints)
+                if (color.equals(glowingPoint.color))
+                    return glowingPoint.texture;
+        }
 
         // existing texture not found, creating new one
         return createTexture(color);