This project has moved. For the latest updates, please go here.

How to tell if a picked point is near the edge of a Geom

Topics: Developer Forum
May 7, 2010 at 10:39 PM
I'm using code similar to the samples that use the mouse pick spring, where the user can click on a geom, so a line like this: Geom pickedGeom = PhysicsSimulator.Collide(pickPoint); This returns me the geom that is picked, but what is the best way to tell if the point is near the edge of the Geom? Basically, I want to ignore the picking action if the user has clicked near the edge of the Geom, say a few pixels near the edge. I'm using SAT and have rectangles, circles, pyramids, arbitrary (convex) paths that can be selected. I could solve this by making a smaller Geom inside all my main Geoms but this seems a lot of work. Is there a way to get the distance to the nearest edge of the Geom from a point if I use SAT?
May 8, 2010 at 12:48 PM

I found a solution.  I draw a line from the center of the picked Geom, through the picked point, and extend it on a little extra distance.  Then I take another pick point at that new location and see if it returns me the same Geom.  If it doesnt, then I know the original point isnt near the edge.  Seems to work anyway.