Picking/selection

I've discovered another near-impossible weakness in QC - the ability to use a mouse cursor (or any coordinate) to select arbitrary objects. This can be done pretty easily in javascript if there are only a few objects that are the same size, but if they're all different sizes and there are many of them, it's very difficult to tackle.

This would probably be a prerequisite for the GUI widgets etc.

In a more general form, collision detection might be handy to solve this...

franz's picture
Hit test

there's a hit test patch, that just does this. You can even use a bitmap mask to do per pixel picking. Doesn't this work for you ???

cwright's picture
d'oh

Ok, I was searching for Days looking for "collision detection", intersection, and other hit-test related things, but not "hit test" itself. That's basically exactly what I want, thanks for pointing me in the right direction :)

I'm such an idiot sometimes :)

cwright's picture
or not

hittest doesn't seem to work correctly inside an iterator though... so I whipped up a simple JS patch that does the same thing -- it doesn't work correctly in an iterator either, but plugging in patchtime to a dummy input seems to make it work.

next problem: can't get hittest data out of an iterator... (without cheating and using the spooky patches)... man I hate QC! :)

franz's picture
iterator = ;(((

no, hit test doesn't work inside an iterator.... but what does work inside an iterator ? .... barely anything

tobyspark's picture
what works inside an iterator?

the answer to that is easy, every f**king hack plug-in i've coded works inside an iterator. learning obj-c just to work round perhaps the most important and yet flawed patch was not my idea when i started out.

rant-out

cwright's picture
Me Too!

I know exactly where you're coming from... I really have no idea why they crippled the patches and iterators so much... it's almost a joke at times :)

Or in other words, ROFL I AgrEE e/ teh Toby!11

kimba23's picture
hit test

Hello

anyone could explain how to use the hit test patch? if i make an image mask, how do i make it to work? any example qtz? thanks!

cwright's picture
masks

Mask images don't seem to work well with the Hit Test patch:

But otherwise, it works sorta like this:

PreviewAttachmentSize
HitTest.qtz5.53 KB

kimba23's picture
using image pix

thanks for the example, i understand now, although i got what i needed using the alpha on the image pixel patch... seems a little easier to work with; i was getting that error as well with hittest, thats why i decided to try image pixel. thanks again man! cheers

yoki's picture
opengl

wouldnt it be possible to build a patch based on the selection-mode in opengl which outputs a structure of hits?

cwright's picture
selectmode

opengl with select mode requires select buffers; QC doesn't allocate those, so they wouldn't work. :/

You'd also have to double-render everything. Patches aren't currently designed to function this way out of the box :( So lots of work to get that going :(

dust's picture
hit test -private

so this patch is very useful. i have been using java for this kind of thing. what kind of patch is the hit test. the info i get on is that its category is private ? do i need to update my qc or is this a hack ?

cwright's picture
normal, private

the Hit Test patch is a normal (built-in), private (not shown by default) patch.

There are a bunch of docs floating around describing how to enable private patch display -- try KinemeCore, it's like the first menuitem under the K menu (note: lately, people have started noticing some stability problems with KinemeCore due to a bug on our part -- if this bites you, let me know, I've got a newer version under development that fixes this)

dust's picture
kore

have not had any bugs yet got kore the other wasn't exactly sure what it was but noticed i was able to make my grid transparent and snap and stuff. i usually figure things out little by little when i need them, seems like there are a bunch of useful things i should have noticed now. thanks