Picking Returning more than one node?

I know that View.pick() returns an array, but each PickRenderResult retruns nodes, as in more than one, but so far I’ve never seen more than one node per PickRenderResult? When will a Pick RenderResult have more than one node?

If you have more than one object at same X and Y cordinates but one is behind the other …that is different Z Cordinate.
Say for example you have one rectangle at z=1,and another with same values of X and Y but at z=-1 ,now if you set your view at say Z=4,now on picking ,resultant array will have more than one object…i hope you got it…
If still its not clear i can send you the code for this. :slight_smile: :slight_smile:

but it also returns an array of PickRenderResultS - that’s what you described - then you get different PickRenderResultS - so you actually didn’t answer his question.
I myself have actually also no real idea, why it PickRenderResult should return an array in the first place, but I can well image this situation:

root-node
|
node1
|
node2
|
leaf <- you picked that one

Then PickRenderResult could return for picked nodes {root-node,node1,node2,leaf}, because leaf is contained in all the other nodes, so you actually picked also the other nodes. You’re PickRenderResult has now only 1 element, how comes that? (You most probably have a root-node, so this should be included you might think) But you probably haven’t set pickable for that node, so it doesn’t show in that list.

I hope I made things clearer and have not confused you :wink:

just a little comment on the picking stuff:

wouldn’t it be much easier for the user if a call to setPickable would set all parent nodes pickable too? so it wouldn’t be necessary to call setpickable on all nodes on the way down to the node …

would be easy to implement… just replace the picking stuff in Node.java:


    private int pickable = 0;
    
    public boolean getPickable(){
    	return ( pickable != 0 ? true : false );
    }
    
    public void setPickable( boolean value ){
    	
    	if ( value )
    		pickable++;
    	else
    		pickable--;
    	
    	if ( this.getParent() != null )
    		this.getParent().setPickable( value );
    	    	
    }

[edit]
actually there’s another thing that has to be changed … in Node.setParent() i added this:


        if (parent != null) {
            parent.expandBounds(this);
            
            // CHANGE HERE
            if( pickable != 0 )
            	parent.setPickable( true );
            
        }

(actually i’m not sure this is working but from the look it should work just fine)

Greetz … Florian

Yaa the idea of setting all the parent node Pickable is very Resonable but it’s said that this is not implemented because of Optimisation issues.
But if someOne is setting a child node Pickable that itself means he must have all Parent Node Pickable so personally i feel thier wont be any performance loss because of this…Arnie please clarify on this.

Ohh it seems I’ve only confused you :-\ I actually have no idea anymore, why it can return more than one Node. You could try to look at the source code yourself.

the method i suggested deals with the case that nodes can be set unpickable …

another thing i’d suggest is an optional method like setPickableTree that walks the tree … that could be called to set the parent nodes ( but stops if it hits a already pickable node, therefore resulting in just one step in cases where serveral ‘PickableS’ are added to the same group )