[ENH] BetterTouches

Bob Arning arning at charm.net
Tue Feb 27 17:08:39 UTC 2001


On Tue, 27 Feb 2001 11:22:39 -0500 Joshua Channing Gargus <schwa at cc.gatech.edu> wrote:
>Fixes a problem with Player>>touchesA:, and also uses a better contact
>algorithm than bounding box intersection.  The new algorithm uses
>BitBlt to determine whether any pixels overlap within the intersection
>of two morph's bounding boxes.  It also works with rotated morphs.
>
>Each call to Morph>>touchesMorph: takes approx. 10ms on my 300Mhz G3
>to find whether two ellipses (extent: 300 at 40) touch (assuming that
>their bounding boxes intersect; otherwise it will be much faster)

Joshua,

I apologize for not giving a better indication of the purpose of #touchesA:. Calling the argument to the method "aPrototypicalPlayer" was meant to indicate that I wanted to know if I touched something that "looked like" the prototype. By removing the test (trueGoal appearsToBeSameCostumeAs: trueNeighbor), you seem to have defeated that intent. I ran a comparison of your code and mine in Osmosis2 (available on BSS). I counted each entry to #touchesA:, each time it answered true and the number of milliseconds to reach 10000 invocations:

	raa #(10001 807 17354)
	jcg #(10001 55 16978)

As you can see, both versions took about the same time to do 10000 tests, but yours produced significantly fewer touches. While some of this can be attributed to a narrower criteria for "touch" in your code, I believe the greater part is due to ignoring valid hits. I would be interested in seeing how your code performs when returning all valid collisions. One of my goals was to make something fast at the expense of a little accuracy, if need be. Since the morphs in question were small and round, I felt it a reasonable sacrifice.

Cheers,
Bob





More information about the Squeak-dev mailing list