Schroedingers-Hat / jsphys

Libraries for physics simulation on javascript canvas
GNU Affero General Public License v3.0
11 stars 1 forks source link

Use smarter algorithm to match objects to clicks #127

Open capnrefsmmat opened 12 years ago

capnrefsmmat commented 12 years ago

Currently we just look for any object whose center of mass is nearby; however, this doesn't account for extendedObjects which may have large spatial extents or irregular shapes, and won't handle 3D view very well. We should devise a better algorithm. I expect there's some clever algorithm already in existence, so we'll just have to find one.

Schroedingers-Hat commented 12 years ago

Have a look at my code for clickyness on solarplayground, or i'll port it over when I find some motivation we're already examining what region is within each object to some extent in the drawing, so you can keep track of what the mouse is over by saving the mouse position at the beginning of a frame, then comparing it to what you are drawing. then set 'mousisover = thecurrentthing' each time it's within the bounding box if you're following painter's algorithm for drawing it even sorts out the right one on top correctly