Re: [osg-users] Disabling small feature culling for a subgraph
Hi, For the record I've found a way to get things working the way I want it, by changing the culling mask of the culling set at the back of the projection culling stack, small feature culling can now be both enabled and disabled for subgraphs. The code for my callback looks like this now (the code is for enabling small feature culling, change the | to ~ to disable small feature culling): virtual void operator() (osg::Node *node, osg::NodeVisitor *nv) { osgUtil::CullVisitor *cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv){ osg::CullStack::CullingStack projCullStack = cv-getProjectionCullingStack(); if(!projCullStack.empty()){ osg::CullingSet cullingSet = projCullStack.back(); osg::CullingSet::Mask cullingSetMask = cullingSet.getCullingMask(); cullingSet.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cullingSet.setCullingMask(cullingSetMask); }else // Do not really now what to do if it is empty traverse(node,nv); }else traverse(node,nv); } Regards, Per Robert Osfield wrote: Hi Per, Unfortunately this is too a niche a part of the OSG to provide an answer off the top of my head. Rober. On Mon, Mar 2, 2009 at 8:01 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, Ok, so if I change the mask of the current CullingSet in a cull callback, should it only affect the culling of the node that the callback is attached to and not the nodes below in the scenegraph? If I change the culling mode of the cull visitor in a cull callback, should it affect all nodes traversed after the node with the callback? This was what I thought, but it didn't work for disabling or enabling small feature culling at least. From my debugging it seams like changing the culling mode of the cullvisitor during traversal doesn't have any affect on culling, i.e. it doesn't change the mask of any culling sets used after the culling mode is changed. I tried to fix this with the patch earlier that you rejected. Is there any other way to change the culling mode from a cull callback so that it affects the culling of nodes below the node with the cull callback? Regrads, Per Robert Osfield wrote: Hi Per, I'm a bit rusty on this topic, too many topics coming flying by each day that niche stuff drops out of focus quite quickly... Something I can answer right away is to to explain the relationship between the CullingSet CullingMode and CullingMask. The Mode is the base mode that specifies what the overall mode should be, while the CullingMask is the current active subset of this mode, that handles the fact that different faces of the view frustum get disabled when subgraphs are completely inside the faces of the view frustum. At least that what I can recall/work out from a brief look through the code. Robert. On Fri, Feb 27, 2009 at 9:16 PM, Per Fahlberg pe...@remograph.com wrote: A correction, my earlier proposed fix also solves this problem if the cull callback is changed to also modify the culling mode of the cull visitor, so that the callback reads something like this: ... osg::CullSettings::CullingMode cullVisitorCullingMode = cv-getCullingMode(); osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask cullingSetMask = cs.getCullingMask(); cv-setCullingMode(cullVisitorCullingMode | osg::CullSettings::SMALL_FEATURE_CULLING); cs.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(cullingSetMask); cv-setCullingMode(cullVisitorCullingMode); ... I'm a bit confused about all the culling masks/modes and which ones to modify and how they are propagated when the cull visitor traverses the scenegraph. Regards, Per Per Fahlberg wrote: Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the fix I submitted then didn't fix this problem. Do I need to add the callback to all nodes that I wish to be culled by small feature culling or is this a problem in osg? Regards, Per Robert Osfield wrote: Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, Great news that you've been able to find a way. Quite a simple change in the end. The trick is knowing exactly what bits to tweak... even I didn't know this in this instance! Robert. On Tue, Mar 3, 2009 at 7:59 PM, Per Fahlberg pe...@remograph.com wrote: Hi, For the record I've found a way to get things working the way I want it, by changing the culling mask of the culling set at the back of the projection culling stack, small feature culling can now be both enabled and disabled for subgraphs. The code for my callback looks like this now (the code is for enabling small feature culling, change the | to ~ to disable small feature culling): virtual void operator() (osg::Node *node, osg::NodeVisitor *nv) { osgUtil::CullVisitor *cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv){ osg::CullStack::CullingStack projCullStack = cv-getProjectionCullingStack(); if(!projCullStack.empty()){ osg::CullingSet cullingSet = projCullStack.back(); osg::CullingSet::Mask cullingSetMask = cullingSet.getCullingMask(); cullingSet.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cullingSet.setCullingMask(cullingSetMask); }else // Do not really now what to do if it is empty traverse(node,nv); }else traverse(node,nv); } Regards, Per Robert Osfield wrote: Hi Per, Unfortunately this is too a niche a part of the OSG to provide an answer off the top of my head. Rober. On Mon, Mar 2, 2009 at 8:01 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, Ok, so if I change the mask of the current CullingSet in a cull callback, should it only affect the culling of the node that the callback is attached to and not the nodes below in the scenegraph? If I change the culling mode of the cull visitor in a cull callback, should it affect all nodes traversed after the node with the callback? This was what I thought, but it didn't work for disabling or enabling small feature culling at least. From my debugging it seams like changing the culling mode of the cullvisitor during traversal doesn't have any affect on culling, i.e. it doesn't change the mask of any culling sets used after the culling mode is changed. I tried to fix this with the patch earlier that you rejected. Is there any other way to change the culling mode from a cull callback so that it affects the culling of nodes below the node with the cull callback? Regrads, Per Robert Osfield wrote: Hi Per, I'm a bit rusty on this topic, too many topics coming flying by each day that niche stuff drops out of focus quite quickly... Something I can answer right away is to to explain the relationship between the CullingSet CullingMode and CullingMask. The Mode is the base mode that specifies what the overall mode should be, while the CullingMask is the current active subset of this mode, that handles the fact that different faces of the view frustum get disabled when subgraphs are completely inside the faces of the view frustum. At least that what I can recall/work out from a brief look through the code. Robert. On Fri, Feb 27, 2009 at 9:16 PM, Per Fahlberg pe...@remograph.com wrote: A correction, my earlier proposed fix also solves this problem if the cull callback is changed to also modify the culling mode of the cull visitor, so that the callback reads something like this: ... osg::CullSettings::CullingMode cullVisitorCullingMode = cv-getCullingMode(); osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask cullingSetMask = cs.getCullingMask(); cv-setCullingMode(cullVisitorCullingMode | osg::CullSettings::SMALL_FEATURE_CULLING); cs.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(cullingSetMask); cv-setCullingMode(cullVisitorCullingMode); ... I'm a bit confused about all the culling masks/modes and which ones to modify and how they are propagated when the cull visitor traverses the scenegraph. Regards, Per Per Fahlberg wrote: Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, Ok, so if I change the mask of the current CullingSet in a cull callback, should it only affect the culling of the node that the callback is attached to and not the nodes below in the scenegraph? If I change the culling mode of the cull visitor in a cull callback, should it affect all nodes traversed after the node with the callback? This was what I thought, but it didn't work for disabling or enabling small feature culling at least. From my debugging it seams like changing the culling mode of the cullvisitor during traversal doesn't have any affect on culling, i.e. it doesn't change the mask of any culling sets used after the culling mode is changed. I tried to fix this with the patch earlier that you rejected. Is there any other way to change the culling mode from a cull callback so that it affects the culling of nodes below the node with the cull callback? Regrads, Per Robert Osfield wrote: Hi Per, I'm a bit rusty on this topic, too many topics coming flying by each day that niche stuff drops out of focus quite quickly... Something I can answer right away is to to explain the relationship between the CullingSet CullingMode and CullingMask. The Mode is the base mode that specifies what the overall mode should be, while the CullingMask is the current active subset of this mode, that handles the fact that different faces of the view frustum get disabled when subgraphs are completely inside the faces of the view frustum. At least that what I can recall/work out from a brief look through the code. Robert. On Fri, Feb 27, 2009 at 9:16 PM, Per Fahlberg pe...@remograph.com wrote: A correction, my earlier proposed fix also solves this problem if the cull callback is changed to also modify the culling mode of the cull visitor, so that the callback reads something like this: ... osg::CullSettings::CullingMode cullVisitorCullingMode = cv-getCullingMode(); osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask cullingSetMask = cs.getCullingMask(); cv-setCullingMode(cullVisitorCullingMode | osg::CullSettings::SMALL_FEATURE_CULLING); cs.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(cullingSetMask); cv-setCullingMode(cullVisitorCullingMode); ... I'm a bit confused about all the culling masks/modes and which ones to modify and how they are propagated when the cull visitor traverses the scenegraph. Regards, Per Per Fahlberg wrote: Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the fix I submitted then didn't fix this problem. Do I need to add the callback to all nodes that I wish to be culled by small feature culling or is this a problem in osg? Regards, Per Robert Osfield wrote: Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? The scene graph itself doesn't support switching off small feature culling in a subgraph. The way you tried to add this back in was inappropriate, so didn't work. My proposed change to just enable small feature culling for subgraphs that needn't it didn't require disabling culling for subgraphs so would be more efficient as culling would never be complete disabled. Disabling culling for a deeply embedded subgraph causes all the parents culling to be disabled as well, which prevents early termination of traversal that would otherwise be done so I wouldn't recommend it. I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. You could just use LOD's, this is effectively all that small feature culling simulates. Alternatively you could just set the bounding box of the drawables of interest to an artificially large size to prevent the small feature culling from effecting them. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, Unfortunately this is too a niche a part of the OSG to provide an answer off the top of my head. Rober. On Mon, Mar 2, 2009 at 8:01 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, Ok, so if I change the mask of the current CullingSet in a cull callback, should it only affect the culling of the node that the callback is attached to and not the nodes below in the scenegraph? If I change the culling mode of the cull visitor in a cull callback, should it affect all nodes traversed after the node with the callback? This was what I thought, but it didn't work for disabling or enabling small feature culling at least. From my debugging it seams like changing the culling mode of the cullvisitor during traversal doesn't have any affect on culling, i.e. it doesn't change the mask of any culling sets used after the culling mode is changed. I tried to fix this with the patch earlier that you rejected. Is there any other way to change the culling mode from a cull callback so that it affects the culling of nodes below the node with the cull callback? Regrads, Per Robert Osfield wrote: Hi Per, I'm a bit rusty on this topic, too many topics coming flying by each day that niche stuff drops out of focus quite quickly... Something I can answer right away is to to explain the relationship between the CullingSet CullingMode and CullingMask. The Mode is the base mode that specifies what the overall mode should be, while the CullingMask is the current active subset of this mode, that handles the fact that different faces of the view frustum get disabled when subgraphs are completely inside the faces of the view frustum. At least that what I can recall/work out from a brief look through the code. Robert. On Fri, Feb 27, 2009 at 9:16 PM, Per Fahlberg pe...@remograph.com wrote: A correction, my earlier proposed fix also solves this problem if the cull callback is changed to also modify the culling mode of the cull visitor, so that the callback reads something like this: ... osg::CullSettings::CullingMode cullVisitorCullingMode = cv-getCullingMode(); osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask cullingSetMask = cs.getCullingMask(); cv-setCullingMode(cullVisitorCullingMode | osg::CullSettings::SMALL_FEATURE_CULLING); cs.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(cullingSetMask); cv-setCullingMode(cullVisitorCullingMode); ... I'm a bit confused about all the culling masks/modes and which ones to modify and how they are propagated when the cull visitor traverses the scenegraph. Regards, Per Per Fahlberg wrote: Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the fix I submitted then didn't fix this problem. Do I need to add the callback to all nodes that I wish to be culled by small feature culling or is this a problem in osg? Regards, Per Robert Osfield wrote: Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? The scene graph itself doesn't support switching off small feature culling in a subgraph. The way you tried to add this back in was inappropriate, so didn't work. My proposed change to just enable small feature culling for subgraphs that needn't it didn't require disabling culling for subgraphs so would be more efficient as culling would never be complete disabled. Disabling culling for a deeply embedded subgraph causes all the parents culling to be disabled as well, which prevents early termination of traversal that would otherwise be done so I wouldn't recommend it. I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. You could just use LOD's, this is effectively all that small feature culling simulates. Alternatively you could just set the bounding box of the drawables of interest to an artificially large size to prevent the small feature
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, I'm a bit rusty on this topic, too many topics coming flying by each day that niche stuff drops out of focus quite quickly... Something I can answer right away is to to explain the relationship between the CullingSet CullingMode and CullingMask. The Mode is the base mode that specifies what the overall mode should be, while the CullingMask is the current active subset of this mode, that handles the fact that different faces of the view frustum get disabled when subgraphs are completely inside the faces of the view frustum. At least that what I can recall/work out from a brief look through the code. Robert. On Fri, Feb 27, 2009 at 9:16 PM, Per Fahlberg pe...@remograph.com wrote: A correction, my earlier proposed fix also solves this problem if the cull callback is changed to also modify the culling mode of the cull visitor, so that the callback reads something like this: ... osg::CullSettings::CullingMode cullVisitorCullingMode = cv-getCullingMode(); osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask cullingSetMask = cs.getCullingMask(); cv-setCullingMode(cullVisitorCullingMode | osg::CullSettings::SMALL_FEATURE_CULLING); cs.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(cullingSetMask); cv-setCullingMode(cullVisitorCullingMode); ... I'm a bit confused about all the culling masks/modes and which ones to modify and how they are propagated when the cull visitor traverses the scenegraph. Regards, Per Per Fahlberg wrote: Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the fix I submitted then didn't fix this problem. Do I need to add the callback to all nodes that I wish to be culled by small feature culling or is this a problem in osg? Regards, Per Robert Osfield wrote: Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? The scene graph itself doesn't support switching off small feature culling in a subgraph. The way you tried to add this back in was inappropriate, so didn't work. My proposed change to just enable small feature culling for subgraphs that needn't it didn't require disabling culling for subgraphs so would be more efficient as culling would never be complete disabled. Disabling culling for a deeply embedded subgraph causes all the parents culling to be disabled as well, which prevents early termination of traversal that would otherwise be done so I wouldn't recommend it. I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. You could just use LOD's, this is effectively all that small feature culling simulates. Alternatively you could just set the bounding box of the drawables of interest to an artificially large size to prevent the small feature culling from effecting them. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the fix I submitted then didn't fix this problem. Do I need to add the callback to all nodes that I wish to be culled by small feature culling or is this a problem in osg? Regards, Per Robert Osfield wrote: Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? The scene graph itself doesn't support switching off small feature culling in a subgraph. The way you tried to add this back in was inappropriate, so didn't work. My proposed change to just enable small feature culling for subgraphs that needn't it didn't require disabling culling for subgraphs so would be more efficient as culling would never be complete disabled. Disabling culling for a deeply embedded subgraph causes all the parents culling to be disabled as well, which prevents early termination of traversal that would otherwise be done so I wouldn't recommend it. I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. You could just use LOD's, this is effectively all that small feature culling simulates. Alternatively you could just set the bounding box of the drawables of interest to an artificially large size to prevent the small feature culling from effecting them. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org /* OpenSceneGraph example, osgscribe. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include osg/Geode #include osg/Group #include osg/Notify #include osg/Material #include osg/PolygonOffset #include osg/PolygonMode #include osg/LineStipple #include osg/PositionAttitudeTransform #include osgDB/Registry #include osgDB/ReadFile #include osgDB/WriteFile #include osgViewer/Viewer #include osgUtil/Optimizer class MyCullingCallback : public osg::NodeCallback { public: MyCullingCallback() : osg::NodeCallback() {} virtual void operator() (osg::Node *node, osg::NodeVisitor *nv) { osgUtil::CullVisitor *cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv){ osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask previousMask = cs.getCullingMask(); cs.setCullingMask(previousMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(previousMask); }else traverse(node,nv); } }; int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(argc,argv); // construct the viewer. osgViewer::Viewer viewer; osg::Camera *cam = viewer.getCamera(); if(cam){ // note just enable view furstum culling sides, leave it to subgraphs to enable // small feature culling where required. cam-setCullingMode(osgUtil::CullVisitor::VIEW_FRUSTUM_SIDES_CULLING); //cam-setCullingMode(osgUtil::CullVisitor::VIEW_FRUSTUM_SIDES_CULLING | osgUtil::CullVisitor::SMALL_FEATURE_CULLING);
Re: [osg-users] Disabling small feature culling for a subgraph
A correction, my earlier proposed fix also solves this problem if the cull callback is changed to also modify the culling mode of the cull visitor, so that the callback reads something like this: ... osg::CullSettings::CullingMode cullVisitorCullingMode = cv-getCullingMode(); osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask cullingSetMask = cs.getCullingMask(); cv-setCullingMode(cullVisitorCullingMode | osg::CullSettings::SMALL_FEATURE_CULLING); cs.setCullingMask(cullingSetMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(cullingSetMask); cv-setCullingMode(cullVisitorCullingMode); ... I'm a bit confused about all the culling masks/modes and which ones to modify and how they are propagated when the cull visitor traverses the scenegraph. Regards, Per Per Fahlberg wrote: Hi Robert, I've been busy with other work and only now been able to try your proposed change and found that it doesn't quite work as expected. When I run the attached modified osgscribe example with the attached box-sphere.osg model the small feature culling only culls the entire model, i.e. both the box and the sphere together not separately as I was expecting. If small feature culling is turned on on the camera the box and sphere is culled by the small feature culling individually. I would like to enable small feature culling on quite large subgraphs and it seams that it only turns on small feature culling on the node with the callback not on the nodes bellow it. This feels very similar to the problem I was originally trying to solve, where the disabling of small feature culling wasn't propagated downwards but the fix I submitted then didn't fix this problem. Do I need to add the callback to all nodes that I wish to be culled by small feature culling or is this a problem in osg? Regards, Per Robert Osfield wrote: Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? The scene graph itself doesn't support switching off small feature culling in a subgraph. The way you tried to add this back in was inappropriate, so didn't work. My proposed change to just enable small feature culling for subgraphs that needn't it didn't require disabling culling for subgraphs so would be more efficient as culling would never be complete disabled. Disabling culling for a deeply embedded subgraph causes all the parents culling to be disabled as well, which prevents early termination of traversal that would otherwise be done so I wouldn't recommend it. I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. You could just use LOD's, this is effectively all that small feature culling simulates. Alternatively you could just set the bounding box of the drawables of interest to an artificially large size to prevent the small feature culling from effecting them. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, On Wed, Jan 28, 2009 at 8:55 PM, Per Fahlberg pe...@remograph.com wrote: I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? The scene graph itself doesn't support switching off small feature culling in a subgraph. The way you tried to add this back in was inappropriate, so didn't work. My proposed change to just enable small feature culling for subgraphs that needn't it didn't require disabling culling for subgraphs so would be more efficient as culling would never be complete disabled. Disabling culling for a deeply embedded subgraph causes all the parents culling to be disabled as well, which prevents early termination of traversal that would otherwise be done so I wouldn't recommend it. I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. You could just use LOD's, this is effectively all that small feature culling simulates. Alternatively you could just set the bounding box of the drawables of interest to an artificially large size to prevent the small feature culling from effecting them. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, FYI, I'm back on the case of the toggling small feature culling in subgraphs. I'm able to reproduce the bug with your example, and should be able to resolve the best way to solve the problem in the next hour or two. Robert. On Mon, Dec 15, 2008 at 2:23 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've found a way to get it working by slightly modifying CullStack.cpp and by also changing my cull callback. When pushing the CullingSet in CullStack I have added updating the cull mask in the new CullingSet. I needed to change both the cull visitors culling mode and the current CullingSets mask in the callback, because I didn't find a way to propagate the changed mode from the CullVisitor to the current CullingSet. I'm cross posting to osg-submissions and have attached the modified CullStack.cpp, I've also attached a modified osgscribe.cpp that shows the problem. When zooming out one model should always be visible but the other shall disappear when it gets less than 200 pixels in size. Regards, Per Robert Osfield wrote: Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, I've just applied your patch and found that it initially seems to work, but breaks once I do several simple zoom in/zoom out movements, randomly the second cow disappears at the same time as the original one, and even when the second cow doesn't disppaer right away it does eventually get culled when zoomed further out. I've now reverted your patch and embarking on a wider review of the way that the small feature culling is managed in CullStack/CullVisitor. Robert. On Wed, Jan 28, 2009 at 2:10 PM, Robert Osfield robert.osfi...@gmail.com wrote: Hi Per, FYI, I'm back on the case of the toggling small feature culling in subgraphs. I'm able to reproduce the bug with your example, and should be able to resolve the best way to solve the problem in the next hour or two. Robert. On Mon, Dec 15, 2008 at 2:23 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've found a way to get it working by slightly modifying CullStack.cpp and by also changing my cull callback. When pushing the CullingSet in CullStack I have added updating the cull mask in the new CullingSet. I needed to change both the cull visitors culling mode and the current CullingSets mask in the callback, because I didn't find a way to propagate the changed mode from the CullVisitor to the current CullingSet. I'm cross posting to osg-submissions and have attached the modified CullStack.cpp, I've also attached a modified osgscribe.cpp that shows the problem. When zooming out one model should always be visible but the other shall disappear when it gets less than 200 pixels in size. Regards, Per Robert Osfield wrote: Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, I've quite a bit of head scratching about what was going on a couple of things dawned on me: 1) The way to implement localization of small feature culling is to disable it globally and then just enable it for the subgraphs that need it. This avoid problems with subgraphs being culled from higher up in the scene graph due to small feature culling that you haven't disabled yet. 2) One should only enable the culling against the view frustum sides, unless you explicitly require near/far culling based on a fixed control of near/far planes. 3) One only needs to modify the mask of the CullingSet, mode of CullSettings is just a distraction. I've applied these changes to your example osgscribe.cpp, and now it works I believe you intended - although the I'm now enabling culling for the right hand subgarph, rather than disabling it for the right hand subgraph, you can get your original effect by just swapping which subgraphs has the callback on. As the modified example demonstrates that you can enable small feature culling selectively on subgraphs without any modifications to the core OSG I'm closing this bug report/bug fix. Cheers, Robert. /* OpenSceneGraph example, osgscribe. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include osg/Geode #include osg/Group #include osg/Notify #include osg/Material #include osg/PolygonOffset #include osg/PolygonMode #include osg/LineStipple #include osg/PositionAttitudeTransform #include osgDB/Registry #include osgDB/ReadFile #include osgDB/WriteFile #include osgViewer/Viewer #include osgUtil/Optimizer class MyCullingCallback : public osg::NodeCallback { public: MyCullingCallback() : osg::NodeCallback() {} virtual void operator() (osg::Node *node, osg::NodeVisitor *nv) { osgUtil::CullVisitor *cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv){ osg::CullingSet cs = cv-getCurrentCullingSet(); osg::CullingSet::Mask previousMask = cs.getCullingMask(); cs.setCullingMask(previousMask | osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cs.setCullingMask(previousMask); }else traverse(node,nv); } }; int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(argc,argv); // construct the viewer. osgViewer::Viewer viewer; osg::Camera *cam = viewer.getCamera(); if(cam){ // note just enable view furstum culling sides, leave it to subgraphs to enable // small feature culling where required. cam-setCullingMode(osgUtil::CullVisitor::VIEW_FRUSTUM_SIDES_CULLING); cam-setSmallFeatureCullingPixelSize(200); } // load the nodes from the commandline arguments. osg::Node* loadedModel = osgDB::readNodeFiles(arguments); // if not loaded assume no arguments passed in, try use default mode instead. if (!loadedModel) loadedModel = osgDB::readNodeFile(cow.osg); if (!loadedModel) { osg::notify(osg::NOTICE)Please specifiy a model filename on the command line.std::endl; return 1; } osg::Group* rootnode = new osg::Group; rootnode-addChild(loadedModel); osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform; pat-setPosition(osg::Vec3d(20, 0, 0)); osg::Group *tmp = new osg::Group; // enable small feature culling for subgraph. tmp-setCullCallback(new MyCullingCallback); tmp-addChild(pat); rootnode-addChild(tmp); pat-addChild(loadedModel); // add a viewport to the viewer and attach the scene graph. viewer.setSceneData( rootnode ); return viewer.run(); } ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, Thank you for looking into this issue. Robert Osfield wrote: Hi Per, I've quite a bit of head scratching about what was going on a couple of things dawned on me: 1) The way to implement localization of small feature culling is to disable it globally and then just enable it for the subgraphs that need it. This avoid problems with subgraphs being culled from higher up in the scene graph due to small feature culling that you haven't disabled yet. I understand that it is possible to achieve the same result the other way around, by disabling small feature culling and only enable it for the subgraphs that needs it. This is however not very practical for my situation where I have a very large scene graph and only want to disable small feature culling for a small set of subgraphs that might be deep down in the graph. I know that setting culling active to false is not the best thing to do but as this was for a small set of subgraphs I don't think it will impact performance much in my case and it is very easy for me to track the nodes that I want to disable small feature culling on. 2) One should only enable the culling against the view frustum sides, unless you explicitly require near/far culling based on a fixed control of near/far planes. 3) One only needs to modify the mask of the CullingSet, mode of CullSettings is just a distraction. In my example I needed to disable small feature culling on both the CullingSet and the CullSettings since otherwise the node with the cull callback would be culled by small feature culling, but I guess that is not a problem if it is done the other way around since small feature culling is not enabled then. I've applied these changes to your example osgscribe.cpp, and now it works I believe you intended - although the I'm now enabling culling for the right hand subgarph, rather than disabling it for the right hand subgraph, you can get your original effect by just swapping which subgraphs has the callback on. As the modified example demonstrates that you can enable small feature culling selectively on subgraphs without any modifications to the core OSG I'm closing this bug report/bug fix. I don't really understand how this is not a bug since it is possible to switch small feature culling on for a subgraph but not switch it off? I will however scratch my head and try to figure out if I can somehow easily invert the enabling and disabling of small feature culling in my program. Regards, Per ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, I've noticed that my fix didn't make it into the 2.7.8 release and just wanted to check if there was a problem with it and that it isn't forgotten. Regards, Per Robert Osfield wrote: Hi Per, I've just done a quick review of your changes and it does feel balanced to me. Is CullVisitor checking the current setting of SmallFeatureCullingPixelSize() from the current CullingSet or CullStack? If so then you own callback should be setting current CullingSet rather than the CullStack. CullStack probably would be best without inheriting from CullingSettings to avoid this confusion, but I suspect I wrote it this may for backwards compatibility. I'll need to dig into CullVisitor to double check all this. Robert. On Mon, Dec 15, 2008 at 2:23 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've found a way to get it working by slightly modifying CullStack.cpp and by also changing my cull callback. When pushing the CullingSet in CullStack I have added updating the cull mask in the new CullingSet. I needed to change both the cull visitors culling mode and the current CullingSets mask in the callback, because I didn't find a way to propagate the changed mode from the CullVisitor to the current CullingSet. I'm cross posting to osg-submissions and have attached the modified CullStack.cpp, I've also attached a modified osgscribe.cpp that shows the problem. When zooming out one model should always be visible but the other shall disappear when it gets less than 200 pixels in size. Regards, Per Robert Osfield wrote: Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, On Sat, Dec 20, 2008 at 7:50 PM, Per Fahlberg pe...@remograph.com wrote: I've noticed that my fix didn't make it into the 2.7.8 release and just wanted to check if there was a problem with it and that it isn't forgotten. As I mentioned in my reply, the patch doesn't feel right, and to me suggest design problems elsewhere that really deserve looking at. So I shelved the patch till I've had a chance to do this wider review. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, In CullVisitor when culling it uses the current CullingSet when checking for small feature culling, that is why i changed both the current CullingSet and the settings in CullVisitor in my callback, so that the current node isn't culled by small feature culling as well as the subgraph below. I agree that it is a lite confusing, my first attempt was to disable small feature culling in the CullVisitor but that failed because of the settings not getting propagated to the CullingSets, this is resolved with my patch. Regards, Per Robert Osfield wrote: Hi Per, I've just done a quick review of your changes and it does feel balanced to me. Is CullVisitor checking the current setting of SmallFeatureCullingPixelSize() from the current CullingSet or CullStack? If so then you own callback should be setting current CullingSet rather than the CullStack. CullStack probably would be best without inheriting from CullingSettings to avoid this confusion, but I suspect I wrote it this may for backwards compatibility. I'll need to dig into CullVisitor to double check all this. Robert. On Mon, Dec 15, 2008 at 2:23 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've found a way to get it working by slightly modifying CullStack.cpp and by also changing my cull callback. When pushing the CullingSet in CullStack I have added updating the cull mask in the new CullingSet. I needed to change both the cull visitors culling mode and the current CullingSets mask in the callback, because I didn't find a way to propagate the changed mode from the CullVisitor to the current CullingSet. I'm cross posting to osg-submissions and have attached the modified CullStack.cpp, I've also attached a modified osgscribe.cpp that shows the problem. When zooming out one model should always be visible but the other shall disappear when it gets less than 200 pixels in size. Regards, Per Robert Osfield wrote: Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, I've found a way to get it working by slightly modifying CullStack.cpp and by also changing my cull callback. When pushing the CullingSet in CullStack I have added updating the cull mask in the new CullingSet. I needed to change both the cull visitors culling mode and the current CullingSets mask in the callback, because I didn't find a way to propagate the changed mode from the CullVisitor to the current CullingSet. I'm cross posting to osg-submissions and have attached the modified CullStack.cpp, I've also attached a modified osgscribe.cpp that shows the problem. When zooming out one model should always be visible but the other shall disappear when it gets less than 200 pixels in size. Regards, Per Robert Osfield wrote: Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include osg/CullStack #include osg/Timer #include osg/Notify #include osg/io_utils using namespace osg; CullStack::CullStack() { _frustumVolume=-1.0f; _bbCornerNear = 0; _bbCornerFar = 7; _currentReuseMatrixIndex=0; _identity = new RefMatrix(); _index_modelviewCullingStack = 0; _back_modelviewCullingStack = 0; _referenceViewPoints.push_back(osg::Vec3(0.0f,0.0f,0.0f)); } CullStack::CullStack(const CullStack cs): CullSettings(cs) { _frustumVolume=-1.0f; _bbCornerNear = 0; _bbCornerFar = 7; _currentReuseMatrixIndex=0; _identity = new RefMatrix(); _index_modelviewCullingStack = 0; _back_modelviewCullingStack = 0; _referenceViewPoints.push_back(osg::Vec3(0.0f,0.0f,0.0f)); } CullStack::~CullStack() { reset(); } void CullStack::reset() { // // first unref all referenced objects and then empty the containers. // _projectionStack.clear(); _modelviewStack.clear(); _viewportStack.clear(); _referenceViewPoints.clear(); _referenceViewPoints.push_back(osg::Vec3(0.0f,0.0f,0.0f)); _eyePointStack.clear(); _viewPointStack.clear(); _clipspaceCullingStack.clear(); _projectionCullingStack.clear(); //_modelviewCullingStack.clear(); _index_modelviewCullingStack=0; _back_modelviewCullingStack = 0; osg::Vec3
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, I've just done a quick review of your changes and it does feel balanced to me. Is CullVisitor checking the current setting of SmallFeatureCullingPixelSize() from the current CullingSet or CullStack? If so then you own callback should be setting current CullingSet rather than the CullStack. CullStack probably would be best without inheriting from CullingSettings to avoid this confusion, but I suspect I wrote it this may for backwards compatibility. I'll need to dig into CullVisitor to double check all this. Robert. On Mon, Dec 15, 2008 at 2:23 PM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've found a way to get it working by slightly modifying CullStack.cpp and by also changing my cull callback. When pushing the CullingSet in CullStack I have added updating the cull mask in the new CullingSet. I needed to change both the cull visitors culling mode and the current CullingSets mask in the callback, because I didn't find a way to propagate the changed mode from the CullVisitor to the current CullingSet. I'm cross posting to osg-submissions and have attached the modified CullStack.cpp, I've also attached a modified osgscribe.cpp that shows the problem. When zooming out one model should always be visible but the other shall disappear when it gets less than 200 pixels in size. Regards, Per Robert Osfield wrote: Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, It sounds like you'll need to directly manipulator or push new settings on the stack in CullVisitor. Robert. On Mon, Dec 15, 2008 at 10:12 AM, Per Fahlberg pe...@remograph.com wrote: Hi Robert, I've traced the problem down now and it seems the culling mode that the CullVisitor uses is correct but the one in the CullingSet is incorrect. This is due to the CullingSet being updated in CullStack::pushProjectionMatrix which is called early on in culling, and when I change the culling mode in my callback it only changes the mode in the CullVisitor and not the mode in the CullingSet. Since I'm not very familiar with the internals in the culling code I would like to ask for some guidance before I dive in and try to code up a fix for the problem. Do you know of a place in the code where the culling set might be updated to reflect the changes in the CullVisitor/CullStack or should I try to directly propagate the changes from the CullSettings::setCullingMode down via CullStack to the CullingSet? Regards, Per Robert Osfield wrote: Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg pe...@remograph.com wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi, Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? Regards, Per Per Fahlberg wrote: Hi, I'm trying to disable small feature culling for a subgraph, but so far I have not been able to disable it with other than calling setCullingActive(false) on the leaf geodes. The leaf geodes are actually shared between several subgraphs and I don't want to disable small feature culling for all of them, so I need a way to disable small feature culling higher up in the scenegraph. I have tried to use a cull callback to disable small feature culling for the subgraph but without success, the code for the cull callback is pasted below. class MyCullingCallback : public osg::NodeCallback { public: MyCullingCallback() : osg::NodeCallback() {} virtual void operator() (osg::Node *node, osg::NodeVisitor *nv) { osgUtil::CullVisitor *cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv){ osg::CullSettings::CullingMode cm = cv-getCullingMode(); cv-setCullingMode(cm ~osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cv-setCullingMode(cm); }else traverse(node,nv); } }; ... node-setCullCallback(new MyCullingCallback); Regards, Per ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Disabling small feature culling for a subgraph
Hi Per, On Tue, Dec 2, 2008 at 11:34 AM, Per Fahlberg [EMAIL PROTECTED] wrote: Perhaps I wasn't clear in my question so I will try once more, is there a way to disable small feature culling for just a subgraph not the entire scene? The only way is is use a cull callback to cache the previous setting, set the new setting do the traverse and the restore the original value. Your original callback does this, but I don't know why it doesn't work. Note, I haven't tried it myself so I can't provide any further direction, you'll just have to dig into the source code. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Disabling small feature culling for a subgraph
Hi, I'm trying to disable small feature culling for a subgraph, but so far I have not been able to disable it with other than calling setCullingActive(false) on the leaf geodes. The leaf geodes are actually shared between several subgraphs and I don't want to disable small feature culling for all of them, so I need a way to disable small feature culling higher up in the scenegraph. I have tried to use a cull callback to disable small feature culling for the subgraph but without success, the code for the cull callback is pasted below. class MyCullingCallback : public osg::NodeCallback { public: MyCullingCallback() : osg::NodeCallback() {} virtual void operator() (osg::Node *node, osg::NodeVisitor *nv) { osgUtil::CullVisitor *cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv){ osg::CullSettings::CullingMode cm = cv-getCullingMode(); cv-setCullingMode(cm ~osg::CullSettings::SMALL_FEATURE_CULLING); traverse(node,nv); cv-setCullingMode(cm); }else traverse(node,nv); } }; ... node-setCullCallback(new MyCullingCallback); Regards, Per ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org