caewok / fvtt-elevated-vision

Adjust Foundry VTT vision, lighting, and token elevations based on terrain, wall, or token elevation.
MIT License
12 stars 5 forks source link

Full Shadow Penumbra is incompatible with the Limits module #77

Closed dev7355608 closed 1 year ago

dev7355608 commented 1 year ago

Limits patches LightSource#_createPolygon too. Because of the wrapper registration order EV's _createPolygon wrapper wraps around Limits' wrapper and therefore discards the constraint applied to the shape by Limits if Full Shadow Penumbra is enabled. If the wrapper order were the other way around, it would throw an error, because EV's _createPolygon doesn't return a PointSourcePolygon as documented. Limits expects a PointSourcePolygon. If EV patched _getPolygonConfiguration instead of _createPolygon, both problems (order and return type) would be solved. I quickly tested it, and it seemed to work well. The originalShape property is no longer set, but it seemed to be unused anyway.

function _getPolygonConfiguration(wrapped) {
  const config = wrapped();
  if ( getSetting(SETTINGS.LIGHTS_FULL_PENUMBRA) ) {
    config.type = "universal";
  }
  return config;
}

dev7355608/limits#4

caewok commented 1 year ago

Thanks! Fixed in v0.5.8. I forgot that "universal" was a config option, which simplifies things a bit. Presumably Limits is ignoring EV's directional lights, as those also wrap _createPolygon.