Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Crude HitTest
-
https://gist.github.com/5eb6c63a8e4ab9998e0d
This is a circle-to-circle based hittest. Used a little nifty math to make it accurate.
-
This works really nicely - thanks!
-
Thank you! Another example I have been playing with. In this one I modified the particles example because I wanted to test hitting a large array of objects. At about fifty it results in lag, probably because my coding is subpar..
https://gist.github.com/68959f100b41187fa3d6
Any advice or improvements is always welcome!
-
Very nice work!
I was thinking about a quad implementation but I didn't know exactly how to do something like that. You demonstrated that wonderfully and pretty much tripled the amount of particles the scene can handle. Good job :)
I'm also quite impressed with how you made the already truncated circle hittest even shorter!
Thank you for the contribution, that's pretty cool stuff and I will definitely learn from this.
-
.
-
thanks dlivingstone! - very devious ways of speeding up the collision checks! :)
-
Very cool.
-
I see that, although you limit the number of checks cleverly, you still have to check the distance for some, and you use "if((dxdx)+(dydy)<radii*radii)"
I notice there is a command in the documentation-
Point.distance(other_point)
#Return the cartesian distance to a different Point object.And wondered if you could incorporate that instead? Or if you had tried and found it slower than your method
-
I've noticed that too, I even use it in my own codes, but it does use the square root function which I believe can make it a bit slower.
-
Thanks S