Details
Description
When using common geometry on a QGLSceneNode for efficiency of large scenes, it appears that only the base geometry is being selected for the on screen pick. In the test scene, only the two base geometry objects are returned from the pick, no matter what objects are mouse clicked and there are 100 objects sharing these two base objects.
To test this, I altered generatePickNodes() in QGLAbstractScene so that it would create a QGLPickNode for the QGLSceneNode at the top of the leaf so that the base geometry would not generate a QGLPickNode. I did this by naming the QGLSceneNode with the base geometry with a 'B' at the beginning of it's name so I could differentiate them. Also the base pick node is nameless by default so I ignore this for creation of a QGLPickNode also. I also altered the qDumpScene() to print out which QGLSceneNodes had a QGLPickNode associated with them. An Example appears below the generatePickNodes() code below. In the attached project, I added 'setOption(QGLView::ShowPicking, true);' so that I could see the objects on screen that are presented for picking and no object appears on screen when the base geometry has no QGLPickNodes.
I attach the project below.
void QGLAbstractScene::generatePickNodes() { Q_D(QGLAbstractScene); QList<QObject *> objs = objects(); QList<QObject *>::iterator it = objs.begin(); d->pickNodes.clear(); QString name; QChar c; for ( ; it != objs.end(); ++it){ QGLSceneNode *n = qobject_cast<QGLSceneNode *>(*it); name = n->objectName(); c = name[0]; if( (c.toLatin1() != 'B') && (!name.isEmpty()) ) { if (d){ if (!d->pickable.contains(n)) { fprintf( stderr, "Setting Picknode on: %s\n", qPrintable(n->objectName()) ); n->setPickNode(new QGLPickNode(this)); d->pickable.insert(n); } } d->pickNodes.append(n->pickNode()); } } } /////////////// altered qDumpScene() //////////////////// if(node->pickNode()){ fprintf(stderr, "%s Picknode id: %d\n", qPrintable(ind), node->pickNode()->id()); } else fprintf(stderr, "%s no pick node set\n", qPrintable(ind)); /////////////////// and it's output ////////////////////////////////
======== Node: 0x811d038 - Reference0 ========= start: 0 count: 0 children:0: 0x8119be0 position: (-5.0000, -0.5000, 0.0000) local transform: identity geometry: NULL material: 0 palette: 0x81069b0 mat name from pal: -- 0x81265e8: Amb: #232300 - Diff: #8f8f00 - Spec: #000000 - Shin: 0.00 lit material effect Picknode id: 0 ======== Node: 0x8119be0 - Base Regular Node ========= start: 0 count: 0 children:0: 0x812f740 local transform: identity geometry: NULL material: NONE no effect set no pick node set ======== Node: 0x812f740 - ========= start: 0 count: 36 children: local transform: identity geometry: 24 indexes, 24 vertices material: NONE no effect set no pick node set ======== Node: 0x8112db8 - NoOriginChange1 ========= start: 0 count: 0 children:0: 0x8119cf0 position: (-3.9000, -1.0000, 0.0000) local transform: identity geometry: NULL material: 0 palette: 0x8113478 mat name from pal: -- 0x811bf78: Amb: #330000 - Diff: #cc0000 - Spec: #000000 - Shin: 0.00 lit material effect Picknode id: 1 ======== Node: 0x8119cf0 - Base Origin Node ========= start: 0 count: 0 children:0: 0x8116b20 local transform: identity geometry: NULL material: NONE no effect set no pick node set ======== Node: 0x8116b20 - ========= start: 0 count: 36 children: local transform: identity geometry: 24 indexes, 24 vertices material: NONE no effect set no pick node set ======== Node: 0x810d968 - Origin2 ========= start: 0 count: 0 children:0: 0x8119be0 position: (-2.8000, -1.0000, 0.0000) local transform: identity geometry: NULL material: 1 palette: 0x81069b0 mat name from pal: -- 0x8125bf8: Amb: #330000 - Diff: #cc0000 - Spec: #000000 - Shin: 0.00 lit material effect Picknode id: 2 ======== Node: 0x8119be0 - Base Regular Node ========= start: 0 count: 0 children:0: 0x812f740 local transform: identity geometry: NULL material: NONE no effect set no pick node set ======== Node: 0x812f740 - ========= start: 0 count: 36 children: local transform: identity geometry: 24 indexes, 24 vertices material: NONE no effect set no pick node set ======== Node: 0x8113ab0 - Reference3 ========= start: 0 count: 0 children:0: 0x8119be0 position: (-1.7000, -0.5000, 0.0000) local transform: identity geometry: NULL material: 2 palette: 0x81069b0 mat name from pal: -- 0x8118a28: Amb: #232300 - Diff: #8f8f00 - Spec: #000000 - Shin: 0.00 lit material effect Picknode id: 3 ======== Node: 0x8119be0 - Base Regular Node ========= start: 0 count: 0 children:0: 0x812f740 local transform: identity geometry: NULL material: NONE no effect set no pick node set ======== Node: 0x812f740 - ========= start: 0 count: 36 children: local transform: identity geometry: 24 indexes, 24 vertices material: NONE no effect set no pick node set
Attachments
Issue Links
- replaces
-
QTBUG-14763 Pick ids can overlap between multiple scene objects
- Closed