From 3a039f1a7df7bce902e13d20b43aecebf690f32c Mon Sep 17 00:00:00 2001 From: cwisniew Date: Thu, 20 Feb 2025 01:20:03 +1030 Subject: [PATCH] Revert 4968 for performance reasons --- .../client/ui/zone/renderer/ZoneRenderer.java | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java b/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java index 380057c1e7..dd30a86599 100644 --- a/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java +++ b/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java @@ -889,9 +889,15 @@ public void renderZone(Graphics2D g2d, PlayerView view) { markerLocationList.clear(); itemRenderList.clear(); - if (!compositor.isInitialised()) compositor.setRenderer(this); - if (!gridRenderer.isInitialised()) gridRenderer.setRenderer(this); - if (!haloRenderer.isInitialised()) haloRenderer.setRenderer(this); + if (!compositor.isInitialised()) { + compositor.setRenderer(this); + } + if (!gridRenderer.isInitialised()) { + gridRenderer.setRenderer(this); + } + if (!haloRenderer.isInitialised()) { + haloRenderer.setRenderer(this); + } Rectangle viewRect = new Rectangle(getSize().width, getSize().height); @@ -1131,7 +1137,9 @@ public void renderZone(Graphics2D g2d, PlayerView view) { timer.stop("overlays"); timer.start("renderCoordinates"); - if (!gridRenderer.isInitialised()) gridRenderer.setRenderer(this); + if (!gridRenderer.isInitialised()) { + gridRenderer.setRenderer(this); + } gridRenderer.renderCoordinates(g2d, view); timer.stop("renderCoordinates"); @@ -2415,7 +2423,9 @@ protected void renderTokens( // Calculate alpha Transparency from token and use opacity for indicating that token is moving float opacity = token.getTokenOpacity(); - if (isTokenMoving(token)) opacity = opacity / 2.0f; + if (isTokenMoving(token)) { + opacity = opacity / 2.0f; + } // Finally render the token image timer.start("tokenlist-7"); @@ -2592,40 +2602,22 @@ protected void renderTokens( timer.stop("tokenlist-8"); timer.start("tokenlist-9"); - /** - * Paint States and Bars Set up the graphics so that the overlay can just be painted. Use - * non-rotated token bounds to avoid odd size changes - */ - Token tmpToken = new Token(token); - tmpToken.setFacing(270); - Rectangle tmpBounds = tmpToken.getBounds(this.zone); - - // Unless it is isometric, make it square to avoid distortion - double maxDim = Math.max(tmpBounds.getWidth(), tmpBounds.getHeight()); - // scale it to the view - maxDim *= this.getScale(); - Rectangle bounds; - if (zone.getGrid().isIsometric()) { - bounds = - new Rectangle( - 0, - 0, - (int) (tmpBounds.getWidth() * this.getScale()), - (int) (tmpBounds.getHeight() * this.getScale())); - } else { - bounds = new Rectangle(0, 0, (int) maxDim, (int) maxDim); - } - - // calculate the drawing region from the token centre. + // Set up the graphics so that the overlay can just be painted. Graphics2D locg = (Graphics2D) tokenG.create( - (int) Math.floor(tokenBounds.getBounds().getCenterX() - bounds.getWidth() / 2.0), - (int) Math.floor(tokenBounds.getBounds().getCenterY() - bounds.getHeight() / 2.0), - bounds.width, - bounds.height); + (int) tokenBounds.getBounds().getX(), + (int) tokenBounds.getBounds().getY(), + (int) tokenBounds.getBounds().getWidth(), + (int) tokenBounds.getBounds().getHeight()); + Rectangle bounds = + new Rectangle( + 0, + 0, + (int) tokenBounds.getBounds().getWidth(), + (int) tokenBounds.getBounds().getHeight()); - // Check each of the set values and draw + // Check each of the set values for (String state : MapTool.getCampaign().getTokenStatesMap().keySet()) { Object stateValue = token.getState(state); AbstractTokenOverlay overlay = MapTool.getCampaign().getTokenStatesMap().get(state); @@ -2873,7 +2865,9 @@ protected void renderTokens( private boolean isTokenInNeedOfClipping(Token token, Area tokenCellArea, boolean isGMView) { // can view everything or zone is not using vision = no clipping needed - if (isGMView || !zoneView.isUsingVision()) return false; + if (isGMView || !zoneView.isUsingVision()) { + return false; + } // no clipping if there is no visible screen area if (visibleScreenArea == null) {