ModelLayer nodes are not conserving their nodeMask
I have noticed that every time I add a new modelLayer, the old modelLayer nodes lose their nodeMasks.
In more details:
I need to set a mask for some modelLayers to avoid their selection in the IntersectionPicker;
so every time I add my Layer, I set its masks:
mapNode->getModelLayerGroup()->getChild(mapNode->getModelLayerGroup()->getNumChildren() - 1)->setNodeMask(4);
but with the new modification in the MapNode, I lose these information because in the MapNode.cpp, all the nodes are deleted without saving their masks in the rebuildLayerNodes function.
So, I did a temporary modification to solve that, but I think it should be taken in consideration to maintain all nodes information.
void rebuildLayerNodes(const Map* map, osg::Group* layerNodes)
for (unsigned int i = 0; i < layerNodes->getNumChildren(); i++)
Re: ModelLayer nodes are not conserving their nodeMask
I added layer->getOrCreateNode()->setNodeMask after adding the layer to the map, but it did not work because in the rebuildLayerNodes function you are not adding the layer node directly, but you are adding it as a child of a new group.
So you can instead use "layer->getOrCreateNode()->setNodeMask", but also in rebuildLayerNodes function you need to add: "container->setNodeMask(node->getNodeMask());".
this will affect only the old nodes, not the last inserted one, so you need to call :
mapNode->getModelLayerGroup()->getChild(i)->setNodeMask(4); // for the last layer
layer->getOrCreateNode()->setNodeMask (4); // will be used at rebuild time
it will work using the first modification in the first post, or with this one ( a little bit illogical: 2 differents call of setNodemask)
Sorry for the previous replay, I made a mistake in my test.
your suggestion " layer->getOrCreateNode()->setNodeMask" is working, even if the ModelLayer node does not save its mask, but affecting the node layer directly did the trick, because the modelLayer group contain only the layer node with the correct mask.