From: <me...@us...> - 2009-04-02 10:22:56
|
Revision: 2678 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2678&view=rev Author: melven2 Date: 2009-04-02 10:22:46 +0000 (Thu, 02 Apr 2009) Log Message: ----------- -fixed error when destroying OgreNewt::World and OgreNewt::Debugger Modified Paths: -------------- branches/ogrenewt/newton20/inc/OgreNewt_Debugger.h branches/ogrenewt/newton20/inc/OgreNewt_World.h branches/ogrenewt/newton20/src/OgreNewt_Debugger.cpp branches/ogrenewt/newton20/src/OgreNewt_World.cpp Modified: branches/ogrenewt/newton20/inc/OgreNewt_Debugger.h =================================================================== --- branches/ogrenewt/newton20/inc/OgreNewt_Debugger.h 2009-03-29 17:00:34 UTC (rev 2677) +++ branches/ogrenewt/newton20/inc/OgreNewt_Debugger.h 2009-04-02 10:22:46 UTC (rev 2678) @@ -17,6 +17,11 @@ #include "OgreNewt_Tools.h" +namespace Ogre +{ + class ManualObject; +} + namespace OgreNewt { @@ -128,7 +133,10 @@ //! clear debug data cache fo bodies (m_cachemap) void clearBodyDebugDataCache(); + typedef std::list<Ogre::ManualObject*> ManualObjectList; + ManualObjectList mRecordedRaycastObjects; + private: //! this function is declared private, so nobody can use it! Debugger() {} Modified: branches/ogrenewt/newton20/inc/OgreNewt_World.h =================================================================== --- branches/ogrenewt/newton20/inc/OgreNewt_World.h 2009-03-29 17:00:34 UTC (rev 2677) +++ branches/ogrenewt/newton20/inc/OgreNewt_World.h 2009-04-02 10:22:46 UTC (rev 2678) @@ -209,7 +209,7 @@ /*! * the debugger needs to be initialized (Debugger::init(...) ) in order to work correctly */ - Debugger& getDebugger() const {return m_debugger;} + Debugger& getDebugger() const {return *m_debugger;} protected: @@ -220,7 +220,7 @@ BodyInAABBIterator m_bodyInAABBIterator; - mutable Debugger m_debugger; + mutable Debugger* m_debugger; private: Modified: branches/ogrenewt/newton20/src/OgreNewt_Debugger.cpp =================================================================== --- branches/ogrenewt/newton20/src/OgreNewt_Debugger.cpp 2009-03-29 17:00:34 UTC (rev 2677) +++ branches/ogrenewt/newton20/src/OgreNewt_Debugger.cpp 2009-04-02 10:22:46 UTC (rev 2678) @@ -58,18 +58,16 @@ void Debugger::deInit() { + clearBodyDebugDataCache(); if (m_debugnode) { m_debugnode->setListener(NULL); - m_debugnode->removeAllChildren(); + m_debugnode->removeAndDestroyAllChildren(); m_debugnode->getParentSceneNode()->removeAndDestroyChild( m_debugnode->getName() ); m_debugnode = NULL; } - clearBodyDebugDataCache(); - - clearRaycastsRecorded(); if( m_raycastsnode ) { @@ -84,15 +82,14 @@ { if(node == m_debugnode) { + m_debugnode = NULL; clearBodyDebugDataCache(); - m_debugnode = NULL; } if(node == m_raycastsnode) { - //!TODO: check this... this accesses the node, I'm not shure if this is allowed in this function + m_raycastsnode = NULL; clearRaycastsRecorded(); - m_raycastsnode = NULL; } } @@ -104,9 +101,11 @@ Ogre::ManualObject* mo = it->second.m_lines; if( mo ) delete mo; + OgreNewt::OgreAddons::MovableText *text = it->second.m_text; + if( text ) + delete text; } m_cachemap.clear(); - } @@ -136,6 +135,9 @@ Ogre::ManualObject* mo = it->second.m_lines; if( mo ) delete mo; + OgreNewt::OgreAddons::MovableText *text = it->second.m_text; + if( text ) + delete text; } } m_cachemap.swap(newmap); @@ -299,13 +301,20 @@ { if( m_raycastsnode ) { +/* while( m_raycastsnode->numAttachedObjects() > 0 ) { delete m_raycastsnode->detachObject((unsigned short)0); } +*/ + m_raycastsnode->removeAndDestroyAllChildren(); + } - m_raycastsnode->detachAllObjects(); + for(ManualObjectList::iterator it = mRecordedRaycastObjects.begin(); it != mRecordedRaycastObjects.end(); it++) + { + delete (*it); } + mRecordedRaycastObjects.clear(); } void Debugger::stopRaycastRecording() @@ -330,6 +339,7 @@ std::ostringstream oss; oss << "__OgreNewt__Raycast_Debugger__Lines__Raycastline__" << i++ << "__"; Ogre::ManualObject *line = new Ogre::ManualObject(oss.str()); + mRecordedRaycastObjects.push_back(line); line->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST ); line->colour(m_raycol); @@ -350,6 +360,7 @@ std::ostringstream oss; oss << "__OgreNewt__Raycast_Debugger__Lines__Convexcastlines__" << i++ << "__"; Ogre::ManualObject *line = new Ogre::ManualObject(oss.str()); + mRecordedRaycastObjects.push_back(line); line->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST ); line->colour(m_convexcol); @@ -402,6 +413,7 @@ std::ostringstream oss; oss << "__OgreNewt__Raycast_Debugger__Lines__DiscardedBody__" << i++ << "__"; Ogre::ManualObject *line = new Ogre::ManualObject(oss.str()); + mRecordedRaycastObjects.push_back(line); line->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST ); line->colour(m_prefilterdiscardedcol); @@ -427,6 +439,7 @@ std::ostringstream oss; oss << "__OgreNewt__Raycast_Debugger__Lines__HitBody__" << i++ << "__"; Ogre::ManualObject *line = new Ogre::ManualObject(oss.str()); + mRecordedRaycastObjects.push_back(line); line->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST ); line->colour(m_hitbodycol); Modified: branches/ogrenewt/newton20/src/OgreNewt_World.cpp =================================================================== --- branches/ogrenewt/newton20/src/OgreNewt_World.cpp 2009-03-29 17:00:34 UTC (rev 2677) +++ branches/ogrenewt/newton20/src/OgreNewt_World.cpp 2009-04-02 10:22:46 UTC (rev 2678) @@ -8,8 +8,7 @@ // Constructor World::World() : - m_bodyInAABBIterator(this), - m_debugger(this) + m_bodyInAABBIterator(this) { m_limits = Ogre::AxisAlignedBox(Ogre::Vector3(-100,-100,-100), Ogre::Vector3(100,100,100)); @@ -26,16 +25,30 @@ m_defaultMatID = new OgreNewt::MaterialID( this, NewtonMaterialGetDefaultGroupID( m_world ) ); m_leaveCallback = NULL; + + m_debugger = new Debugger(this); } // Destructor World::~World() { + if (m_debugger) + { + delete m_debugger; + m_debugger = NULL; + } + if (m_defaultMatID) + { delete m_defaultMatID; + m_defaultMatID = NULL; + } if (m_world) + { NewtonDestroy( m_world ); + m_world = NULL; + } } // update This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |