Closed HoldYourWaffle closed 7 years ago
Did you run the checkstyle plugin? It says there are some checkstyle violations. I'll check out your code and look into it. Checkstlye can be a nuisance sometimes. Thanks for your PR though I'll review it ASAP.
Oops I completely forgot tests... :blush:
I think it did not run the tests because Checkstyle failed the build before it got there. :D
So I checked your PR and fixed the checkstyle problems. There is something which I'd like to clarify: which parts are the optimization?
I mean I'd like to know exactly what resulted in a huge speedup for you because there are some redundancies (pointList
vs pointArray
for example). I'd like to remove one of them but keep the stuff which is faster.
Another thing which is a bit puzzling: why vertices
is useful? From what I understand it is simply a denormalized list of points so it contains all the points flattened like this: (x
, y
, x
, y
, etc...).
Would you kindly clarify these?
If we fix this then I can release a new version to Maven and you can use that for your project.
The code looks good btw, thanks!
which parts are the optimization?
Well what I mainly did was pre-calculating some things on every hexagon-instantiation instead of when a method was invoked, wich creates a general speed boost (altough not that big). Also it just makes more sense.
I mean I'd like to know exactly what resulted in a huge speedup for you
Well I didn't really test the pre-calculations individually but I guess the pre-calculations of the points (HexagonImpl.calcPoints()
) had a big part in it and not having to call List.toArray
every frame could also have helped (It pre-calculates these now).
because there are some redundancies (pointList vs pointArray for example)
Well I made changes over the cours of weeks and pushed them waaay later so I don't remember clearly why they're both in here. What I can see now is that getPointList()
is just a "workaround" for the "general" type List
of getPoints()
because my mind derped and didn't really figure out I could just edit the Hexagon
interface to change it. That could be easily changed.
why vertices is useful? From what I understand it is simply a denormalized list of points so it contains all the points flattened like this: (x, y, x, y, etc...). Would you kindly clarify these?
It's exactly what you understood it is, it's useful for rendering (at least in my GDX-implementation). You could remove it, I guess I didn't fully qualify it as GDX-exclusive in my head.
The code looks good btw, thanks!
Well that's the first time in forever that I've heard that :joy:
Cool, then I'll leave everything in place but I'll factor the getPointArray
out since an ArrayList
is backed by a real array and it does not have any overhead whatsoever. Is this OK for you? I tend not to use plain arrays because they don't add anything compared to a List
and using a List
isn't noticeably slower.
Is this OK for you?
Sure it's your project :man_shrugging:
Cool, I've released a new version. Related reddit post here.
Hereby the PR you asked for by mail.
It contains basically 2 things: