Strange behaviour in depth of selection Stack.

hi,
I am using openGL based selection and naming the objects something like this…

LoadName(BOX);

pushName(B1);
pushName(B11);
DrawBox(1,1);
popName();
PopName();

pushName(B2);
pushName(B21);
DrawBox(2,1);
popName();
PopName();

… some thing like this… Lets say i have only two cube boxes rendered which are overlapped(not intersected) when seen from the default camera view

             |--------|
             |  |---| | 
             |  |   | | 
             |  |---| | 
             |--------| 

The above image is the ascii art of how two solid box cubes are placed with different depth values…

Outer one is B11,
Inner one is B22,(near to camera)

if i place my mouse on B22 and hit,

now selection stack contains
{B22,
B12}
which means far one(B12) is at the bottom of the stack which is wrong. :frowning:

however strangely if i rotate the view 180 degree back(lets say along Y axis),where B12 is near and B22 is far then selection stack contains
{B22,
B12} which is correctly showing. :smiley:

This Strange selection stack behaviour is only comming selection hits more than one object, that too working fine when rotated back.

I have no clue why this is behaving like this, …??? :mad:

Hi,
The name stack does not order the primitives, it does not guaranties ordered primitives from the view point.
If you want it sorted, sort the list

The name stack does not order the primitives, it does not guaranties ordered primitives from the view point.
If you want it sorted, sort the list

My problem here is name stack in the case of multiple objects hitted, should store the data acoording to the depth from the view point, (ie; the nearest object should be at the end of the stack) but in my case its inverse ( ie; nearest object is first and far object is end of the stack).

guys,

I got it… I was wrongly parsing the selection stack with out considering Min and Max depth values and blindly assuming the last one in the stack is the nearest…

Thank you,
kumar.k