Add max points to fog bounding box
This commit is contained in:
parent
c8e2707421
commit
355da5d012
@ -284,6 +284,7 @@ function MapFog({
|
||||
|
||||
function handlePointerMove() {
|
||||
if (
|
||||
editable &&
|
||||
active &&
|
||||
(toolSettings.type === "polygon" || toolSettings.type === "rectangle")
|
||||
) {
|
||||
@ -572,7 +573,7 @@ function MapFog({
|
||||
|
||||
if (editable) {
|
||||
const visibleShapes = shapes.filter(shapeVisible);
|
||||
setFogShapeBoundingBoxes(getFogShapesBoundingBoxes(visibleShapes));
|
||||
setFogShapeBoundingBoxes(getFogShapesBoundingBoxes(visibleShapes, 5));
|
||||
setFogShapes(visibleShapes);
|
||||
} else {
|
||||
setFogShapes(mergeFogShapes(shapes));
|
||||
|
@ -260,11 +260,15 @@ export function mergeFogShapes(shapes, ignoreHidden = true) {
|
||||
|
||||
/**
|
||||
* @param {Fog[]} shapes
|
||||
* @param {boolean} maxPoints Max amount of points per shape to get bounds for
|
||||
* @returns {Vector2.BoundingBox[]}
|
||||
*/
|
||||
export function getFogShapesBoundingBoxes(shapes) {
|
||||
export function getFogShapesBoundingBoxes(shapes, maxPoints = 0) {
|
||||
let boxes = [];
|
||||
for (let shape of shapes) {
|
||||
if (maxPoints > 0 && shape.data.points.length > maxPoints) {
|
||||
continue;
|
||||
}
|
||||
boxes.push(Vector2.getBoundingBox(shape.data.points));
|
||||
}
|
||||
return boxes;
|
||||
|
Loading…
Reference in New Issue
Block a user