-
Notifications
You must be signed in to change notification settings - Fork 4
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
Porting Spatial Hash #6
Comments
I'm starting on this. My branch is here: https://github.com/codeguru42/arcade-accelerate/tree/spatial-hash. I will continue to work on it through PyCon sprints at the least. |
@Cleptomania I have some time today to pick back up on this and have some plans to continue in the near future. One detail I found is that
I believe this is because the default implementation of My first instinct here is that we will need to implement our own version of the functions needed for |
That’s a good question, I’m actually not sure what the answer is, because two different Sprites could have exactly the same values(texture, position, scale, rotation, etc etc) and still be completely separate objects. I would guess they would need some kind of unique hash or something which can be evaluated? We could also investigate starting work on Texture, however that’s gonna be quite the undertaking I think |
@Cleptomania so do we implement object equality rather than structural equality? |
meaning that two sprites are equal if and only if they are the exact same object in memory rather than having fields with the same values |
That would be my thinking, we could maybe implement both somehow but in general I would think we would be wanting to evaluate if it’s the exact object. @einarf might have some input on this well. |
Or alternatively, we add a |
That way if we clone a sprite, it could still be considered "equal" to the original because they would both have the same |
I'm running into another issue while testing
The problem is that the first parameter to |
Additionally, the |
Some of the first work that been completed in this project is improving collision detection performance. This has largely so far been centered around hitboxes and direct brute force polygonal collision detection. While there are still improvements to be made to that system, another desire for collision detection is to see if we can improve the spatial hashing system in Arcade.
Spatial Hashing is a technique by which objects are placed into a sort of "grid" of cells, and when performing collision checks, we need only check items which are in the cells that could possibly collide with an object in a given cell. This significantly reduces the amount of brute force collision checks which are needed, and means the algorithm can in practice support a nearly infinite number of objects.
The downside to this system, is that moving or inserting new objects has a significant cost, making it in most scenarios not suitable for objects which might move, so it is only generally used for things like walls. If by porting this system to Rust we can significantly reduce the cost of this operation, then it may open this algorithm up to be a viable path for many more scenarios.
In terms of the actual implementation of this, this may require starting to port some of
SpriteList
, but I am unsure to what extent or even if at all that will need done, there is a non-zero amount of coupling betweenSpriteList
andSpatialHash
in the pure python version, and having to back and forth between Rust and Python for that could cause a scenario where we don't get any improvement or even make it worse. This will need more investigation and probably won't fully be determined until we get some kind of initial implementation built out.The text was updated successfully, but these errors were encountered: