foundryvtt-lancer icon indicating copy to clipboard operation
foundryvtt-lancer copied to clipboard

[BUG] Performance issues when using Lancer AoE Templates

Open msprijatelj opened this issue 1 year ago • 3 comments

Describe the bug Whenever one of the AoE Template macros is used to target tokens on a gridded scene, Foundry freezes for a moment until it finally places the template and targets all affected tokens.

To Reproduce Steps to reproduce the behavior:

  1. Create a new scene with a grid.
  2. Drag tokens onto the scene.
  3. Execute one of the Lancer system's AoE macros. Drop the AoE on one or more of the tokens added to the scene (ideally more than one).
  4. Observe that Foundry is unresponsive for a moment or more before the Template and tokens are properly targeted.

Expected behavior Targeting with an AoE template immediately targets affected tokens without performance issues.

Platform (please complete the following information):

  • OS: Windows 10
  • Browser Firefox
  • Foundry version 10.303
  • Lancer system version 1.6.1

Additional context It may be possible to grab some code from theripper93's Smart Target module, which allows for Alt-Clicking the area of a measured template to select all affected targets. It has no performance issues when it does so, so it may have a more efficient algorithm for targeting.

Discord contact info _valkyrion

msprijatelj avatar Sep 01 '23 14:09 msprijatelj

The problem with smart target is that its heuristic for selecting tokens is incorrect for size > 1.

BoltsJ avatar Mar 19 '24 19:03 BoltsJ

Ah, and there’s no way to salvage or tweak Smart Target then? Unlucky.

msprijatelj avatar Mar 19 '24 20:03 msprijatelj

Smart target would have to be patched to be aware of the spaces tokens occupy, since it only checks the center point of a token. One obstacle to that is there is a helper method to get the spaces a token takes up, but it's lancer specific.

As for the performance issue, I'm not able to reliably reproduce it, but I have identified potential places that might cause issues and am working on cleaning those up.

BoltsJ avatar Mar 19 '24 22:03 BoltsJ