mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Don't access point coordinates when hashing.
For some reason this is crazy expensive. Turn time goes from 1.7 seconds to 1 second with this change.
This commit is contained in:
parent
b9138acbc8
commit
9a374711fd
@ -47,21 +47,15 @@ class NavPoint:
|
||||
return Point(self.point.x, self.point.y)
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash((self.poly.ident, int(self.point.x), int(self.point.y)))
|
||||
return hash(self.poly.ident)
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
if not isinstance(other, NavPoint):
|
||||
return False
|
||||
|
||||
# The int comparisons here aren't really correct, but the units here are
|
||||
# meters and even approximate floating point comparisons can cause
|
||||
# issues when these are used in sets or maps. For our purposes, two
|
||||
# waypoints within a meter of each other might as well be identical for
|
||||
# the purposes of path finding, so not an issue.
|
||||
if int(self.point.x) != int(other.point.x):
|
||||
return False
|
||||
if int(self.point.y) != int(other.point.y):
|
||||
if not self.point.almost_equals(other.point):
|
||||
return False
|
||||
|
||||
return self.poly == other.poly
|
||||
|
||||
def __str__(self) -> str:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user