🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by minch Fri, 18 Dec 1992 00:36
hit detection in user paths
#2123
Author: minch
Date: Fri, 18 Dec 1992 00:36
14 lines
989 bytes
Anybuddy,
I've got some big irregular shapes that I fill with user paths.  
Now I want to find which big irregular shape the mouse is  
clicked in. I look at DPSUserPath and find that dps_ufill is an  
allowable action, but DPSUserPath itself is declared as void. So  
how does the boolean get returned? Presumably it's left on the  
stack and I can maybe pick it up using some dps stack snooper,  
but is there a better way? 

---
 
Eric Minch         Any resemblance to the opinions of persons
Epistemic Artisan  or organizations other than myself--living,
Stanford Genetics  dead, or imaginary--is purely fortuitous.
Re: hit detection in user paths
#2139
Author: Scott Byer
Date: Fri, 18 Dec 1992 19:07
63 lines
2631 bytes
minch@lotka.stanford.edu writes

> I've got some big irregular shapes that I fill with user paths.
> Now I want to find which big irregular shape the mouse is clicked
> in. I look at DPSUserPath and find that dps_ufill is an allowable
> action, but DPSUserPath itself is declared as void. So how does
> the boolean get returned? Presumably it's left on the stack and I
> can maybe pick it up using some dps stack snooper, but is there a
> better way?

Ah, yes, the "in" operators.  Specifically, you're looking for
"inufill".  There are two forms of inufill, depending on how you
want to use the hit detection.  The first form is:

x y userpath inufill bool

The second is:

userpath userpath inufill bool

The first userpath can then be an aperature to be checked for
intersection (say, an aperature around the mouse click - NOTE: you
might as well make this aperature *round*, as it costs almost
nothing in terms of performance, and gives a more natural feel to
selection.)

There will be several ways of using inufill in combination with
DPSDoUserPath, and if you really care about performance, testing
the several variations might be in order.  Since this is off the
top of my head, I'll try and keep it simple so I don't screw up.
This example also happens to require a minimal amount of explanation
:-)

/* Wraps. */

defineps checkfill( | boolean *hit; )
	myPath1 myPath2 inufill hit
endps

defineps putname( char *thename )
	/thename
endps

/* C code calling sequence. */

..
   boolean	answer;
   ...
   putname("myPath1");
   DPSDoUserPath(..., dps_def);
   putname("myPath2");
   DPSDoUserPath(..., dps_def);
   checkfill(&answer);
..

For a much better example, see Chapter 8 of the Purple book.

--
Scott Byer                             NeXTMail: byer@mv.us.adobe.com
Adobe Systems Incorporated               These are *my* opinions, and  
1585 Charleston Road, P.O. Box 7900        do not necessarily reflect
Mountain View, CA 94039-7900             the opinions of my employer.
---------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads