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, |