Skip to content
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

Odd TreeSet usage #27

Open
psygate opened this issue Oct 9, 2015 · 3 comments
Open

Odd TreeSet usage #27

psygate opened this issue Oct 9, 2015 · 3 comments

Comments

@psygate
Copy link

psygate commented Oct 9, 2015

SparseQuadTree is using a TreeSet which is meant to be a one-dimensional sorted set structure. The context of the usage is a 2D bounding box, which is not sortable in a 1D context, since there is not well defined order operation for 2D objects in 1D space (except projection which also is unfavorable for the amount of "doubly" projected objects.). TreeSet also requires a comparator to work correctly, or the natural ordering (as with Numbers). Which leads up to the ill-defined compare in BastionBlock

An N dimensional structure is not a subtype of a N-1 dimensional structure. Nor the other way around. Substitution. TreeSet is an ill-fit choice for bounding boxes, since there is no way to have a well defined, unique order of 2D elements in 1D space. A quadtree already imposes an order over 2D elements, and a HashSet with a well defined equals and hashCode with good Integer Hashing could speed up the lookup process and replacement process quite a bit.

3D Space Integer Coordinate Hashing

@rourke750
Copy link

rourke750 commented Oct 9, 2015 via email

@ProgrammerDan
Copy link

Just a note, there are a number of good 2d-1d projection techniques (but only in discrete number spaces, not continuous), but they involve some annoying math that leads to efficiency losses, such that ultimately your suggestion of using an indexing technique designed for actual N space is correct.

@spaceFountain
Copy link

This is by the way as noted in comments (I think) is the exact same implementation used in JukeAlert.

Maxopoly pushed a commit to Maxopoly/Bastion that referenced this issue Mar 29, 2017
* Should fix doubledrop on break

* Missing import

* Correct block placements healing bastions, it has to always be start - end never end - start...

* Correct block placements healing bastions, add your start, dont subtract it

* minor health balance fix

* Fixing conversion error

* Numerous fixes to address raised issues. With listeners having proper boot config; includes instabreak if you hit the actual bastion block.

* Trying to figure out why its not dropping correctly.

* Fix Y level check logic to prevent blocking inversion

* Sometimes Im an idiot too

* Should fix square radius issue -- use squared not radius, pearl blocking where disabled, and should resolve ability to get back a bastion block placed but unreinforced

* Forgot to add second half of pending bastion return, you know, the break listener.

* Adding better pending handling across all breaking points. Fixed regressive logic reversion on pearl blocking

* just some code quality fix and a config patch

* Allow bastions to not block most things, but still prevent exiles, yet not be breakable unless physically removed

* Should fix midair block failures, there was an extraneously malformed check. Removed some excess logging, and moved the non-block bastion alert to a different section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants