src/glRenderer.cc

changeset 752
b80ccc2a24e4
parent 742
f10de1bf22e7
child 753
0379f6fca732
equal deleted inserted replaced
751:49d4eb8edcd8 752:b80ccc2a24e4
1235 1235
1236 setPicking (true); 1236 setPicking (true);
1237 1237
1238 // Paint the picking scene 1238 // Paint the picking scene
1239 glDisable (GL_DITHER); 1239 glDisable (GL_DITHER);
1240 glClearColor (1.0f, 1.0f, 1.0f, 1.0f); 1240 glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
1241 drawGLScene(); 1241 drawGLScene();
1242 1242
1243 int x0 = mouseX, 1243 int x0 = mouseX,
1244 y0 = mouseY; 1244 y0 = mouseY;
1245 int x1, y1; 1245 int x1, y1;
1279 1279
1280 // Read pixels from the color buffer. 1280 // Read pixels from the color buffer.
1281 glReadPixels (x0, m_height - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata); 1281 glReadPixels (x0, m_height - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata);
1282 1282
1283 LDObject* removedObj = null; 1283 LDObject* removedObj = null;
1284 QList<qint32> indices;
1284 1285
1285 // Go through each pixel read and add them to the selection. 1286 // Go through each pixel read and add them to the selection.
1286 for (qint32 i = 0; i < numpixels; ++i) 1287 for (qint32 i = 0; i < numpixels; ++i)
1287 { 1288 {
1288 QList<float> selfloats;
1289 selfloats << ((float) pixelptr[0]) / 255.0f;
1290 selfloats << ((float) pixelptr[1]) / 255.0f;
1291 selfloats << ((float) pixelptr[2]) / 255.0f;
1292 selfloats << ((float) pixelptr[3]) / 255.0f;
1293
1294 qint32 idx = 1289 qint32 idx =
1295 (*(pixelptr + 0) * 0x10000) + 1290 (*(pixelptr + 0) * 0x10000) +
1296 (*(pixelptr + 1) * 0x100) + 1291 (*(pixelptr + 1) * 0x100) +
1297 *(pixelptr + 2); 1292 *(pixelptr + 2);
1298 pixelptr += 4; 1293 pixelptr += 4;
1299 1294
1300 if (idx == 0xFFFFFF) 1295 if (idx != 0)
1301 continue; // White is background; skip 1296 indices << idx;
1297 }
1298
1299 removeDuplicates (indices);
1300
1301 for (qint32 idx : indices)
1302 {
1303 if (idx == 0)
1304 continue; // Black is background; skip
1302 1305
1303 LDObject* obj = LDObject::fromID (idx); 1306 LDObject* obj = LDObject::fromID (idx);
1304 assert (obj != null); 1307 assert (obj != null);
1305 1308
1306 // If this is an additive single pick and the object is currently selected, 1309 // If this is an additive single pick and the object is currently selected,

mercurial