return toAwtColor().getRGB();
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Color color = (Color) o;
+
+ if (r != color.r) return false;
+ if (g != color.g) return false;
+ if (b != color.b) return false;
+ return a == color.a;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = r;
+ result = 31 * result + g;
+ result = 31 * result + b;
+ result = 31 * result + a;
+ return result;
+ }
}
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
+import java.util.Collections;
+import java.util.Set;
+import java.util.WeakHashMap;
+
public class GlowingPoint extends ForwardOrientedTexture {
private static final int TEXTURE_SIZE = 50;
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;
+ }
- getTexture(color);
+ 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;
+ // existing texture not found, creating new one
+ return createTexture(color);
}
- public static Texture getTexture(final Color color) {
+ private static Texture createTexture(final Color color) {
final Texture texture = new Texture(TEXTURE_SIZE, TEXTURE_SIZE, 1);
for (int x = 0; x < TEXTURE_SIZE; x++)
for (int y = 0; y < TEXTURE_SIZE; y++) {
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
* In order to get perspective correct textures, large textured polygons are
}
}
+ public List<SubShape> getGroup(final String groupIdentifier) {
+ return originalSubShapes.stream().filter(
+ subShape -> subShape.matchesGroup(groupIdentifier))
+ .collect(Collectors.toList());
+ }
+
private void resliceIfNeeded() {
final double proposedSliceFactor = relativityTracker