New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fly, use rotating buffer over list to store last 5 positions. #20140
Conversation
8d53513
to
328f30f
Compare
Requested changes addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me. I am not sure how much of a difference these changes will make but they are reasonable changes.
328f30f
to
09cc804
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think buffer related changes should be separated into its own commit. This also needs a rebased as it conflicts with the current codestyle (I've suggested the fix).
09cc804
to
0b4b64f
Compare
set | ||
{ | ||
if (pos >= Count) | ||
throw new ArgumentException($"Index out of bounds: {pos}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't check this for get
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it seemed reasonable, to avoid the overhead.
0b4b64f
to
7445a8e
Compare
7445a8e
to
415a6ed
Compare
ping. fixups were done, apart from the bounds check in the getter, which will be unlikely and obviously tracable by the resulting exception. |
ping. |
Fly stores the last the position over the lats 5 ticks to determine the distance travelled and whether flight is stuck.
List
with an rotating buffer. To avoid removing the head element from a list array each tick. Avoiding a ArrayCopy/Move each tick.RotatingBuffer
can be reused in new contrail implementation. Could potentially also be used in input tap detection. (only used function tested)Future possible improvements:
Map.DistanceAboveTerrain
is looked up more often by all flight activites/functions - during the same tick. For rectangular maps the operation is not that expensive. Functions already take many arguments - did not want to add it.