From c8344bba1a05a2e455dc6bd5851b1bdd5d33fa68 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia Date: Mon, 21 Nov 2016 12:00:56 +0100 Subject: [PATCH] - fixed crash derived from changing mesh topology without updating internal data structures --- wrap/gl/pick.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/wrap/gl/pick.h b/wrap/gl/pick.h index c8878491..d4ea2e8d 100644 --- a/wrap/gl/pick.h +++ b/wrap/gl/pick.h @@ -155,7 +155,7 @@ public: Box3 reg =ComputeDCBox(x,y,width,height); - if(M!=lastM || &m != lastm) + if ((M != lastM) || (&m != lastm) || (pVec.size() != m.VN())) { FillProjectedVector(m,pVec,M,viewportF); lastM = M; @@ -184,21 +184,24 @@ public: reg.Add(CoordType(x-width/ScalarType(2.0),y-height/ScalarType(2.0),ScalarType(-1.0))); reg.Add(CoordType(x+width/ScalarType(2.0),y+height/ScalarType(2.0),ScalarType(1.0))); - if(M!=lastM || &m != lastm) + if((M!=lastM) || (&m != lastm) || (pVec.size() != m.VN())) { FillProjectedVector(m,pVec,M,viewportF); lastM = M; lastm = &m; } - for(size_t i=0;i-1.0f) && (p1[2]>-1.0f) && (p2[2]>-1.0f) && IntersectionTriangleBox(reg,p0,p1,p2)) - result.push_back(&m.face[i]); - } + for (size_t i = 0; i < m.face.size(); ++i) + { + if (!m.face[i].IsD()) + { + const CoordType &p0 = pVec[tri::Index(m, m.face[i].V(0))]; + const CoordType &p1 = pVec[tri::Index(m, m.face[i].V(1))]; + const CoordType &p2 = pVec[tri::Index(m, m.face[i].V(2))]; + if ((p0[2] > -1.0f) && (p1[2] > -1.0f) && (p2[2] > -1.0f) && IntersectionTriangleBox(reg, p0, p1, p2)) + result.push_back(&m.face[i]); + } + } return result.size(); }