-
Notifications
You must be signed in to change notification settings - Fork 345
Issue #782 Using shapely to find line of sight #783
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
Issue #782 Using shapely to find line of sight #783
Conversation
Thanks for the PR! That sounds very promising. I'm not processing these PRs as fast as I'd like, so thanks for your patience on this. |
@pvcraven sure, no problem! I've just realised, that there is another, potential gain of implementing shapely: it does not require SpriteLists to use spatial-hashing for efficiency, so moving Sprites could be tested for visibility with the same efficiency as static ones! I use shapely in my RTS-python-game project with a good results. |
Oh nice. Teaching is occupying a lot of my time right now, but once break hits, I want to dive into this. |
We do need to be more careful about the version number of our libraries, but I'm not sure this is the PR to do that in. Thinking maybe that should be separated. |
Yes, I would revert the new version constraints for now. That needs to be carefully looked at. |
My PR #780 deals with the package versioning issues, and is probably the more appropriate place for that to be handled since it re-does the whole setuptools configuration. It does only deal with the versions for core packages though, like pyglet, pillow, pytiled_parser, etc. It does not do it for the dev dependencies like pytest. |
With a simple test I was getting 4.77 ms with the shapely code, and 8.55 ms without shapely, but with spatial hashing, and 101 ms without spatial. This makes me also want to explore using shapely for collision detection. Does that work? Do we want shapely as a dependency? |
Real quick error-prone test:
|
Worst case there could be a shapely implementation and a pure python one? I'm not sure if that is too much to maintain. |
If you can update the PR to not change so much in the requirements, that would be great. I'll merge it in. |
@pvcraven yup, shapely also has collisions for polygons, both convex and concave etc. So it could help with collisions-handling too. I can explore that, test efficiency and if it works faster than current collision-detection, start work on bigger commit. Should I? It seems that adding shapely-depenedence would be a good idea. |
Let's do that as a separate PR. If this one has requirements.txt cleaned up, I'll put it in for 2.5, then do a different PR for working collision detection. |
1. shapely and setuptools removed from requirements.txt
@pvcraven I removed requirements. |
removed all versioning.
What is wrong with it? How can it be improved?
#782
Current has_line_of_sight function works, but it is not so efficient. With just 25 sprites and 25 obstacles if each sprite try to find line of sight to each other, it takes roughly 7 seconds for frame to update! With Shapely it is just 0.18 second: 35 times faster! With 1 player-sprite checking line of sight against 1156 enemies, it currently takes about 16 seconds per frame, whereas shapely does the job within 0.09 second