Re: [osg-users] Visitor concept. No finalize?
This would require the user to be aware of the fact that the Visitor has not finished its work after dtor is called. This is even more user unfriendly in my point of view. Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35988#35988 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visitor concept. No finalize?
Hi Robert, the second half of my post is about the second option you was talking about. The apply only gathers the nodes in question and does nothing else then there is another method that performs the removal from parent. But the issue with that is, that if I do not call this method, no removal is done. That was, what I was talking about. The visitor finished its work but as long as the user do not call an additional method the removal from parent has not been done yet. I was hoping for a finish method that is automatically called after the visitors work has been finished. This finish method could then perform the necessary removal operation (or any other). Thank you! Cheers, Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35944#35944 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visitor concept. No finalize?
Hi Robert, I am aware of the possibility to define my own methods in the visitor but the point I was trying to explain is, that if I apply a visitor on a scene I would except that this visitor has finished its work after calling the node-accept(myVisitor) If I have a RemoveXVisitor and I as the user and not the writer of it use this visitor as I am used to use them by Code: RemoveXVisitor v; node-accept(v); I would expect that the Visitor has done it's work, which it actually didn't since there is no finalize method I would need to write: Code: RemoveXVisitor v; node-accept(v); v.doTheJobActually(); So there is a discrepancy between what I would except from a visitor after it was passed to accept and what a visitor is able to do in it's apply method Greetings Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35950#35950 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visitor concept. No finalize?
Hi Robert, I suppose I expect that because let's say a RemoveGroupsVisitor should remove Groups from a given graph, when I apply this visitor to a scene by Code: RemoveGroupsVisitor r; scene-accept(r); I personally would expect that now the groups are removed, which they are not by the limitation of the apply methods Regards Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35952#35952 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Visitor concept. No finalize?
Hi, that is exactly the point. My RemoveXVisitor SHOULD remove nodes but since it is not possible to do that in apply and there is no finalize method that gets automatically called after accept has finished, it is only possible to remove nodes by providing a custom member which the user must call manually. That is what I am talking about, it is not possible for a Visitor to do certain things without having the user explicitly call members of it after the accept call. I did not demand a finalize method and I understand Robert's statement that flexibility is achieved by relying on the user. Never the less would a finalize method decrease any flexibility and power of it. (Btw: I have never experienced that handing over responsibility to the user (which is the developer at this point) produced any good results, but this is only my experience) Thanks, Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35965#35965 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Visitor concept. No finalize?
Hi, I was writing a Visitor that performed an extraction of certain elements from a scenegraph. My first try was to remove the nodes in question from their parents directly in the apply method which lead to some exceptions. So what am I doing wrong? I mean I would except some finalize method which is called when the visitor is finished. Currently the only remaining function is the getter function for the nodes, that should be extracted. So in apply I have stored references to the object which I can only extract when using the getter so that the removal logic can be executed. This works so far but if I do not call the getter no extraction code is executed and nothing really happened. What am I doing wrong? Thank you, Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35941#35941 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Swapping ref_ptr
Hi, I am in a situation where I receive a osg::ref_ptrGroup to which I should add a Transform Node (or basically prepend it) Usually the group I receive is in a hierarchy of nodes, so I was thinking about getting parents of this group, removing this group as a child and add the Transform instead. But is there a better way? Since I actually do not know anything about the parents of the group it is also possible that there is no parent yet so the exchange is getting difficult. Now I am wondering if it is possible and safe to swap the inner pointer of the ref_ptr. Basically my functions looks like Code: void foo (osg::ref_ptrosg::Group myGroup) { // do something osg::ptr_refosg::MatrixTransform mat = new MatrixTransform; // change myGroup.swap(mat); } Which is called from a parent function like Code: void parentFoo() { osg::ref_ptrosg::Group myGroup = new osg::Group; foo(myGroup); // now I need myGroup to point to MatrixTransform without noticing it } Is this going to work? I have no compiler on this maschine to test right now so I am just assuming and browsing the docs. Thank you! Cheers, Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29515#29515 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Swapping ref_ptr
Hi, passing a ref_ptr by reference. This sounds somehow strange to me. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29517#29517 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] gDebugger see memory leaks in 14 lines of set up code when FBOs are used
Hi, I spent the whole day chasing a weird memory leak on my GPU. The following code is part of a (not working well) FBO render solution. Code: #include osg/CameraNode #include osgViewer/ViewerEventHandlers void foo() { osg::ref_ptrosg::Camera c = new osg::Camera(); c-setCullingMode(osgUtil::CullVisitor::VIEW_FRUSTUM_CULLING); // Disable SMALL_FEATURE_CULLING c-setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR); c-setClearColor( osg::Vec4(1.0, 1.0, 1.0, 0.0) ); // default white c-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); c-setReferenceFrame(osg::Transform::ABSOLUTE_RF); c-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); c-setRenderOrder(osg::Camera::PRE_RENDER); osg::ref_ptrosg::Group topg = new osg::Group; topg-addChild( c); osgViewer::Viewer viewer; viewer.setSceneData(topg); viewer.realize(); viewer.frame(); } int main(int argc, char* argv[]) { { { foo(); } } return 0; } When I run this with dDebugger I get memory leaks. Call stack: osgViewer::GraphicsWindow::makeContextCurrentImplementation - osg55-osgViewerd.dll osgViewer::GraphicsWindow::makeContextCurrentImplementation - osg55-osgViewerd.dll osgViewer::GraphicsWindow::makeContextCurrentImplementation - osg55-osgViewerd.dll osgViewer::GraphicsWindow::makeContextCurrentImplementation - osg55-osgViewerd.dll osg::LineSegment::start - osg55-osgd.dll osgViewer::GraphicsWindow::makeContextCurrentImplementation - osg55-osgViewerd.dll osgViewer::GraphicsWindow::makeContextCurrentImplementation - osg55-osgViewerd.dll foo - osg_viewer_leak_test.cpp, line 22 main - osg_viewer_leak_test.cpp, line 31 __tmainCRTStartup - crtexe.c, line 597 mainCRTStartup - crtexe.c, line 413 RegisterWaitForInputIdle - kernel32.dll These are two render buffers and one FBO when I change the Code: c-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); from FRAME_BUFFER_OBJECT to FRAME_BUFFER - Code: -setRenderTargetImplementation(osg::Camera::FRAME_BUFFER); No leak occurs. Win XP Pro, SP 2, GeForce GTX 285, Driver 191.07 gDebugger 5.2.1 -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=28363#28363 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org