diff --git a/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java b/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java index 9123ef28cc..b13db08e7d 100644 --- a/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java +++ b/src/main/java/net/rptools/maptool/client/ui/zone/ZoneRenderer.java @@ -1520,7 +1520,7 @@ private void renderAuras(Graphics2D g, PlayerView view) { // Setup timer.start("renderAuras:getAuras"); if (drawableAuras == null) { - drawableAuras = new ArrayList<>(zoneView.getLights(LightSource.Type.AURA)); + drawableAuras = new ArrayList<>(zoneView.getDrawableAuras()); } timer.stop("renderAuras:getAuras"); diff --git a/src/main/java/net/rptools/maptool/client/ui/zone/ZoneView.java b/src/main/java/net/rptools/maptool/client/ui/zone/ZoneView.java index ca022f3804..ff12b7f0a1 100644 --- a/src/main/java/net/rptools/maptool/client/ui/zone/ZoneView.java +++ b/src/main/java/net/rptools/maptool/client/ui/zone/ZoneView.java @@ -534,15 +534,15 @@ private void getLightAreasByLumens( } /** - * Get the lists of drawable light from lightSourceMap. + * Get the lists of drawable auras. * - * @param type the type of lights to get. - * @return the list of drawable lights of the given type. + * @return the list of drawable auras. */ - public List getLights(LightSource.Type type) { + public List getDrawableAuras() { List lightList = new LinkedList(); - if (lightSourceMap.get(type) != null) { - for (GUID lightSourceToken : lightSourceMap.get(type)) { + final var auraTokenGUIDs = lightSourceMap.get(LightSource.Type.AURA); + if (auraTokenGUIDs != null) { + for (GUID lightSourceToken : auraTokenGUIDs) { Token token = zone.getToken(lightSourceToken); if (token == null) { continue; @@ -554,40 +554,52 @@ public List getLights(LightSource.Type type) { if (lightSource == null) { continue; } - if (lightSource.getType() == type) { - // This needs to be cached somehow - Area lightSourceArea = lightSource.getArea(token, zone, Direction.CENTER); - Area visibleArea = - FogUtil.calculateVisibility( - p.x, - p.y, - lightSourceArea, - getTopologyTree(Zone.TopologyType.WALL_VBL), - getTopologyTree(Zone.TopologyType.HILL_VBL), - getTopologyTree(Zone.TopologyType.PIT_VBL)); - if (visibleArea == null) { + // Token can also have non-auras lights, we don't want those. + if (lightSource.getType() != LightSource.Type.AURA) { + continue; + } + + Area lightSourceArea = lightSource.getArea(token, zone, Direction.CENTER); + Area visibleArea = + FogUtil.calculateVisibility( + p.x, + p.y, + lightSourceArea, + getTopologyTree(Zone.TopologyType.WALL_VBL), + getTopologyTree(Zone.TopologyType.HILL_VBL), + getTopologyTree(Zone.TopologyType.PIT_VBL)); + + // This needs to be cached somehow + for (Light light : lightSource.getLightList()) { + // If there is no paint, it's a "bright aura" that just shows whatever is beneath it and + // doesn't need to be rendered. + if (light.getPaint() == null) { + continue; + } + boolean isOwner = token.getOwners().contains(MapTool.getPlayer().getName()); + if ((light.isGM() && !MapTool.getPlayer().isEffectiveGM())) { + continue; + } + if ((!token.isVisible()) && !MapTool.getPlayer().isEffectiveGM()) { continue; } - for (Light light : lightSource.getLightList()) { - boolean isOwner = token.getOwners().contains(MapTool.getPlayer().getName()); - if ((light.isGM() && !MapTool.getPlayer().isEffectiveGM())) { - continue; - } - if ((!token.isVisible()) && !MapTool.getPlayer().isEffectiveGM()) { - continue; - } - if (token.isVisibleOnlyToOwner() && !AppUtil.playerOwns(token)) { - continue; - } - if (light.isOwnerOnly() - && lightSource.getType() == LightSource.Type.AURA - && !isOwner - && !MapTool.getPlayer().isEffectiveGM()) { - continue; - } - lightList.add( - new DrawableLight(type, light.getPaint(), visibleArea, lightSource.getLumens())); + if (token.isVisibleOnlyToOwner() && !AppUtil.playerOwns(token)) { + continue; + } + if (light.isOwnerOnly() && !isOwner && !MapTool.getPlayer().isEffectiveGM()) { + continue; + } + + // Calculate the area covered by this particular range. + Area lightArea = lightSource.getArea(token, zone, Direction.CENTER, light); + if (lightArea == null) { + continue; } + lightArea.transform(AffineTransform.getTranslateInstance(p.x, p.y)); + lightArea.intersect(visibleArea); + lightList.add( + new DrawableLight( + LightSource.Type.AURA, light.getPaint(), lightArea, lightSource.getLumens())); } } }