reduce overhead by not spamming updates when stationary

This commit is contained in:
David Camp committed 2025-08-07 21:05:35 -07:00
1 parent d7d15026d8
commit 2d69836887
1 file changed
+7 -3
+7 -3
View File
@@ -504,11 +504,15 @@ function redrawDynamics(){
// Placing it after culling means that if the user fast travels the map won't snap to them until manually scrolled to near their position.
if(MapData.layers.gps && marker.type === 'player') {
//This works fine
MapData.view.x = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5;
//This does not
// MapData.view.y = -marker.position.z * MapData.view.scale;
let newX = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5;
if(Math.abs(MapData.view.x - newX) >= 10) { // Needs some tuning, but the idea is to not keep calling the map update _constantly_ when stationary.
MapData.view.x = newX;
MapData.view.dirty = true;
}
//This calculation does not
// MapData.view.y = -marker.position.z * MapData.view.scale;
}
if(marker.hidden || (marker.minZoom && MapData.view.scale < marker.minZoom) || (marker.maxZoom && MapData.view.scale > marker.maxZoom)) continue;
if(markerX > mapCanvas.width + Config.viewCullMargin || markerX < -Config.viewCullMargin || markerY > mapCanvas.height + Config.viewCullMargin || markerY < -Config.viewCullMargin) continue; // View Culling