mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
A possible explanation for the infrequent CTDs we've been seeing since adding fast forward is that QWebChannel doesn't keep a reference to the python objects that it passes to js, so if the object is GC'd before the front end is done with it, it crashes. We don't really like QWebChannel anyway, so this begins replacing that with FastAPI.
35 lines
974 B
Python
35 lines
974 B
Python
from __future__ import annotations
|
|
|
|
from typing import Iterator
|
|
|
|
from PySide2.QtCore import Property, QObject, Signal
|
|
|
|
from game import Game
|
|
from game.server.leaflet import LeafletLatLon
|
|
|
|
|
|
class UnculledZone(QObject):
|
|
positionChanged = Signal()
|
|
radiusChanged = Signal()
|
|
|
|
def __init__(self, position: LeafletLatLon, radius: float) -> None:
|
|
super().__init__()
|
|
self._position = position
|
|
self._radius = radius
|
|
|
|
@Property(list, notify=positionChanged)
|
|
def position(self) -> LeafletLatLon:
|
|
return self._position
|
|
|
|
@Property(float, notify=radiusChanged)
|
|
def radius(self) -> float:
|
|
return self._radius
|
|
|
|
@classmethod
|
|
def each_from_game(cls, game: Game) -> Iterator[UnculledZone]:
|
|
for zone in game.get_culling_zones():
|
|
ll = game.theater.point_to_ll(zone)
|
|
yield UnculledZone(
|
|
[ll.latitude, ll.longitude], game.settings.perf_culling_distance * 1000
|
|
)
|