mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
fix(cctv): keep a clicked group in frame and let counts take clicks over plain fills
- The flight after a count click checks the frame on both axes and at the height of the highest mount, so a group on a slope or in a very wide window stays in view; when it cannot, it flies to the nearest cell with two or more cameras, never to a lone camera that joined the count. - A count takes a click over a background fill no layer owns (earthquake discs, fire perimeters), and still yields to a scene item another layer registered. - A count crossing the HUD edge refreshes the view only when the active icon or a lone camera depends on it, and never mid-motion, so panning no longer runs extra full view passes. - A count restored at the HUD edge keeps the lone cameras its outline covers, and leaves the others as icons.
This commit is contained in:
1 parent
f6982dc934
commit
aba4c9e533
14 files changed
+674
-41
No files matched your search
@@ -152,6 +152,36 @@ export function createCountMarkers(
|
||||
};
|
||||
}
|
||||
|
||||
/** Keep covered icons in the restored count if its new label clears the HUD. */
|
||||
function retainCoveredCameras(group, core, project) {
|
||||
const anchor = cellCenter(core);
|
||||
const at = project(anchor);
|
||||
if (!at) return core;
|
||||
const { x, y } = at; // The projector reuses its result.
|
||||
const size = sizeFor(core.count);
|
||||
const halfSegment = (size.width - size.height) / 2;
|
||||
const covered = group.lone.filter((lone) => {
|
||||
const p = project(cellCenter(lone));
|
||||
if (!p) return false;
|
||||
// The pill outline that merging measures, without its gap.
|
||||
const dx = Math.max(
|
||||
0,
|
||||
Math.abs(p.x + (lone.offsetPx ?? 0) - x) - halfSegment,
|
||||
);
|
||||
const reach = (size.height + (lone.iconPx ?? CAMERA_ICON_PX)) / 2;
|
||||
return dx * dx + (p.y - y) ** 2 < reach * reach;
|
||||
});
|
||||
if (!covered.length) return core;
|
||||
const { width, height } = sizeFor(core.count + covered.length);
|
||||
if (hardUi({ x: x - width / 2, y: y - height / 2, w: width, h: height }))
|
||||
return core;
|
||||
const held = withoutLoneCameras(group, covered);
|
||||
held.anchor = anchor;
|
||||
held.groundM = core.groundM;
|
||||
for (const lone of covered) lone.absorbed = true;
|
||||
return held;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reuse marker slots in ground-key order, and invalidate only changed frames.
|
||||
* `groundHeight(lon, lat)` gives the drawn terrain in metres, or a non-finite
|
||||
@@ -216,9 +246,9 @@ export function createCountMarkers(
|
||||
for (const lone of cell.lone) lone.absorbed = false;
|
||||
const core = withoutLoneCameras(cell);
|
||||
if (core) {
|
||||
core.releasedAt = rect;
|
||||
ground([core]);
|
||||
cell = core;
|
||||
cell = retainCoveredCameras(cell, core, project);
|
||||
cell.releasedAt = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,9 +261,12 @@ export function createCountMarkers(
|
||||
last.latSum !== cell.latSum ||
|
||||
last.lonSum !== cell.lonSum ||
|
||||
last.heightSum !== cell.heightSum ||
|
||||
last.groundM !== cell.groundM
|
||||
last.groundM !== cell.groundM ||
|
||||
last.anchor?.x !== cell.anchor?.x ||
|
||||
last.anchor?.y !== cell.anchor?.y ||
|
||||
last.anchor?.z !== cell.anchor?.z
|
||||
) {
|
||||
marker.pos = cellCenter(cell);
|
||||
marker.pos = cell.anchor ?? cellCenter(cell);
|
||||
marker.cullPos = liftedForHorizon(marker.pos);
|
||||
marker.hudHidden = undefined;
|
||||
changed = true;
|
||||
@@ -303,10 +336,9 @@ export function createCountMarkers(
|
||||
const previous = marker.hudHidden;
|
||||
if (previous !== hidden) {
|
||||
marker.hudHidden = hidden;
|
||||
// The active icon steps aside only for visible counts.
|
||||
// The active icon steps aside only for visible counts beside it.
|
||||
refresh ||=
|
||||
hidden ||
|
||||
previous !== undefined ||
|
||||
((hidden || previous !== undefined) && marker.besideActive) ||
|
||||
marker.cell.lone?.some((cell) => cell.absorbed === hidden);
|
||||
}
|
||||
if (hidden) continue;
|
||||
|
||||
Reference in new issue
Block a user