From de114193381f20ccc94f48a2d86edd716cdbc6fe Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 25 May 2006 04:42:29 +0000 Subject: [PATCH] Corrected bug in the pickface to comply deleted faces and to allow to have unsorted results. --- wrap/gl/pick.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/wrap/gl/pick.h b/wrap/gl/pick.h index 6dbe6177..a7e13920 100644 --- a/wrap/gl/pick.h +++ b/wrap/gl/pick.h @@ -54,9 +54,10 @@ public: return false; } - static int PickFace(int x, int y, MESH_TYPE &m, std::vector &result, int width=4, int height=4) + static int PickFace(int x, int y, MESH_TYPE &m, std::vector &result, int width=4, int height=4,bool sorted=true) { result.clear(); + if(width==0 ||height==0) return 0; long hits; int sz=m.face.size()*5; unsigned int *selectBuf =new unsigned int[sz]; @@ -89,16 +90,12 @@ public: { glLoadName(fcnt); glBegin(GL_TRIANGLES); - glVertex( (*fi).V(0)->P() ); glVertex( (*fi).V(1)->P() ); glVertex( (*fi).V(2)->P() ); - - glEnd(); - fcnt++; } - + fcnt++; // the counter should advance even for deleted faces! } glPopMatrix(); @@ -113,7 +110,8 @@ public: //TRACE("%ui %ui %ui %ui\n",selectBuf[ii*4],selectBuf[ii*4+1],selectBuf[ii*4+2],selectBuf[ii*4+3]); H.push_back( std::pair(selectBuf[ii*4+1]/4294967295.0,selectBuf[ii*4+3])); } - std::sort(H.begin(),H.end()); + if(sorted) + std::sort(H.begin(),H.end()); // if(H.size()>0) TRACE("\n Closest is %i\n",H[0].second); result.resize(H.size()); for(long ii=0;ii