From 8ed643ca24d78b89622ee7f34f048531735261f1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 18 Mar 2003 20:27:09 +0000 Subject: [PATCH] Chaned the OsgCameraGroup so that its scene handler list used ref_ptr<> for robustly managing memory. --- AUTHORS.txt | 2 +- .../examples/osgcluster/osgcluster.dsp | 138 ------------------ examples/osglight/osglight.cpp | 3 +- examples/osgoccluder/osgoccluder.cpp | 2 +- examples/osgstereoimage/osgstereoimage.cpp | 2 +- examples/osgviewer/osgviewer.cpp | 3 + include/osgProducer/OsgCameraGroup | 3 +- src/osgProducer/OsgCameraGroup.cpp | 7 +- 8 files changed, 14 insertions(+), 146 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index af0081593..46ed8cc82 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -47,7 +47,7 @@ Ben Discoe - png plugin. - fixes to OBJ plugin. -Maroc Jez +Marco Jez - osgParticle - IO support for osgText. diff --git a/VisualStudio/examples/osgcluster/osgcluster.dsp b/VisualStudio/examples/osgcluster/osgcluster.dsp index c2008e246..9f586a60e 100644 --- a/VisualStudio/examples/osgcluster/osgcluster.dsp +++ b/VisualStudio/examples/osgcluster/osgcluster.dsp @@ -1,360 +1,222 @@ # Microsoft Developer Studio Project File - Name="Example osgcluster" - Package Owner=<4> - # Microsoft Developer Studio Generated Build File, Format Version 6.00 - # ** DO NOT EDIT ** - - - # TARGTYPE "Win32 (x86) Console Application" 0x0103 - - - CFG=Example osgcluster - Win32 Release - !MESSAGE This is not a valid makefile. To build this project using NMAKE, - !MESSAGE use the Export Makefile command and run - !MESSAGE - !MESSAGE NMAKE /f "osgcluster.mak". - !MESSAGE - !MESSAGE You can specify a configuration when running NMAKE - !MESSAGE by defining the macro CFG on the command line. For example: - !MESSAGE - !MESSAGE NMAKE /f "osgcluster.mak" CFG="Example osgcluster - Win32 Release" - !MESSAGE - !MESSAGE Possible choices for configuration are: - !MESSAGE - !MESSAGE "Example osgcluster - Win32 Release" (based on "Win32 (x86) Console Application") - !MESSAGE "Example osgcluster - Win32 Debug" (based on "Win32 (x86) Console Application") - !MESSAGE - - - # Begin Project - # PROP AllowPerConfigDependencies 0 - # PROP Scc_ProjName "" - # PROP Scc_LocalPath "" - CPP=cl.exe - RSC=rc.exe - - - !IF "$(CFG)" == "Example osgcluster - Win32 Release" - - - # PROP BASE Use_MFC 0 - # PROP BASE Use_Debug_Libraries 0 - # PROP BASE Output_Dir "Release" - # PROP BASE Intermediate_Dir "Release" - # PROP BASE Target_Dir "" - # PROP Use_MFC 0 - # PROP Use_Debug_Libraries 0 - # PROP Output_Dir "Release" - # PROP Intermediate_Dir "Release" - # PROP Ignore_Export_Lib 0 - # PROP Target_Dir "" - # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c - # ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c - # ADD BASE RSC /l 0x809 /d "NDEBUG" - # ADD RSC /l 0x809 /d "NDEBUG" - BSC32=bscmake.exe - # ADD BASE BSC32 /nologo - # ADD BSC32 /nologo - LINK32=link.exe - # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - # ADD LINK32 wsock32.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"../../../bin/osgcluster.exe" /libpath:"../../../lib" - - - !ELSEIF "$(CFG)" == "Example osgcluster - Win32 Debug" - - - # PROP BASE Use_MFC 0 - # PROP BASE Use_Debug_Libraries 1 - # PROP BASE Output_Dir "Debug" - # PROP BASE Intermediate_Dir "Debug" - # PROP BASE Target_Dir "" - # PROP Use_MFC 0 - # PROP Use_Debug_Libraries 1 - # PROP Output_Dir "Debug" - # PROP Intermediate_Dir "Debug" - # PROP Ignore_Export_Lib 0 - # PROP Target_Dir "" - # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c - # ADD CPP /nologo /MDd /W3 /Gm /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /YX /FD /c - # SUBTRACT CPP /Fr - # ADD BASE RSC /l 0x809 /d "_DEBUG" - # ADD RSC /l 0x809 /d "_DEBUG" - BSC32=bscmake.exe - # ADD BASE BSC32 /nologo - # ADD BSC32 /nologo - LINK32=link.exe - # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - # ADD LINK32 wsock32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../../bin/osgclusterd.exe" /pdbtype:sept /libpath:"../../../lib" - # SUBTRACT LINK32 /incremental:no - - - !ENDIF - - - # Begin Target - - - # Name "Example osgcluster - Win32 Release" - # Name "Example osgcluster - Win32 Debug" - # Begin Group "Source Files" - - - # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" - # Begin Source File - - - SOURCE=..\..\..\examples\osgcluster\broadcaster.cpp - # End Source File - # Begin Source File - - - SOURCE=..\..\..\examples\osgcluster\osgcluster.cpp - # End Source File - # Begin Source File - - - SOURCE=..\..\..\examples\osgcluster\receiver.cpp - # End Source File - # End Group - # Begin Group "Header Files" - - - # PROP Default_Filter ";h;hpp;hxx;hm;inl" - # Begin Source File - - - SOURCE=..\..\..\examples\osgcluster\broadcaster.h - # End Source File - # Begin Source File - - - SOURCE=..\..\..\examples\osgcluster\receiver.h - # End Source File - # End Group - # Begin Group "Resource Files" - - - # PROP Default_Filter "" - # End Group - # End Target - # End Project - diff --git a/examples/osglight/osglight.cpp b/examples/osglight/osglight.cpp index 73dbee065..a77cb5e42 100644 --- a/examples/osglight/osglight.cpp +++ b/examples/osglight/osglight.cpp @@ -355,10 +355,9 @@ int main( int argc, char **argv ) itr!=viewer.getSceneHandlerList().end(); ++itr) { - osgUtil::SceneView* sceneview = *itr; // switch off small feature culling to prevent the light points from being culled. + osgUtil::SceneView* sceneview = itr->get(); sceneview->setCullingMode( sceneview->getCullingMode() & ~osg::CullStack::SMALL_FEATURE_CULLING); - //sceneview->setCullingMode( 0); } while( !viewer.done() ) diff --git a/examples/osgoccluder/osgoccluder.cpp b/examples/osgoccluder/osgoccluder.cpp index 2033bf1be..f3a397cef 100644 --- a/examples/osgoccluder/osgoccluder.cpp +++ b/examples/osgoccluder/osgoccluder.cpp @@ -347,7 +347,7 @@ int main( int argc, char **argv ) if (manuallyCreateOccluders) { - osgUtil::SceneView* sceneview = viewer.getSceneHandlerList()[0]; + osgUtil::SceneView* sceneview = viewer.getSceneHandlerList()[0].get(); viewer.getEventHandlerList().push_front(new OccluderEventHandler(sceneview,rootnode)); } diff --git a/examples/osgstereoimage/osgstereoimage.cpp b/examples/osgstereoimage/osgstereoimage.cpp index 434d80765..54e2b5db4 100644 --- a/examples/osgstereoimage/osgstereoimage.cpp +++ b/examples/osgstereoimage/osgstereoimage.cpp @@ -108,7 +108,7 @@ int main( int argc, char **argv ) itr!=viewer.getSceneHandlerList().end(); ++itr) { - osgUtil::SceneView* sceneview = *itr; + osgUtil::SceneView* sceneview = itr->get(); sceneview->setCullMask(0xffffffff); sceneview->setCullMaskLeft(0x00000001); sceneview->setCullMaskRight(0x00000002); diff --git a/examples/osgviewer/osgviewer.cpp b/examples/osgviewer/osgviewer.cpp index d5c140aa6..edf9c6a11 100644 --- a/examples/osgviewer/osgviewer.cpp +++ b/examples/osgviewer/osgviewer.cpp @@ -86,6 +86,9 @@ int main( int argc, char **argv ) } + // wait for all cull and draw threads to complete before exit. + viewer.sync(); + return 0; } diff --git a/include/osgProducer/OsgCameraGroup b/include/osgProducer/OsgCameraGroup index cda92e3a0..efb2a04e6 100644 --- a/include/osgProducer/OsgCameraGroup +++ b/include/osgProducer/OsgCameraGroup @@ -1,3 +1,4 @@ + /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield * * This library is open source and may be redistributed and/or modified under @@ -42,7 +43,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup virtual ~OsgCameraGroup() {} - typedef std::vector SceneHandlerList; + typedef std::vector < osg::ref_ptr > SceneHandlerList; SceneHandlerList& getSceneHandlerList() { return _shvec;} diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index 115e7b2c7..64e7d8238 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -127,7 +127,10 @@ void OsgCameraGroup::setUpSceneViewsWithData() else if (_scene_data.valid()) { (*p)->setSceneData( _scene_data.get() ); - + } + else + { + (*p)->setSceneData( 0 ); } (*p)->setFrameStamp( _frameStamp.get() ); @@ -135,7 +138,7 @@ void OsgCameraGroup::setUpSceneViewsWithData() (*p)->setBackgroundColor( _background_color ); (*p)->setLODScale( _LODScale ); (*p)->setFusionDistance( _fusionDistanceMode, _fusionDistanceValue ); - + (*p)->getState()->reset(); } }