Fixed crash on exit issues with osgFX, osgParticle, osgSim and the osgforest example
This commit is contained in:
parent
c1a491bd54
commit
dd9ccbad86
@ -803,6 +803,18 @@ class ShaderGeometry : public osg::Drawable
|
|||||||
|
|
||||||
typedef std::vector<osg::Vec4> PositionSizeList;
|
typedef std::vector<osg::Vec4> PositionSizeList;
|
||||||
|
|
||||||
|
virtual void resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
|
{
|
||||||
|
osg::Drawable::resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_geometry) _geometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseGLObjects(osg::State* state) const
|
||||||
|
{
|
||||||
|
osg::Drawable::releaseGLObjects(state);
|
||||||
|
if (_geometry) _geometry->releaseGLObjects(state);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const
|
virtual void drawImplementation(osg::RenderInfo& renderInfo) const
|
||||||
{
|
{
|
||||||
for(PositionSizeList::const_iterator itr = _trees.begin();
|
for(PositionSizeList::const_iterator itr = _trees.begin();
|
||||||
|
@ -119,6 +119,9 @@ namespace osgFX
|
|||||||
/** default traversal */
|
/** default traversal */
|
||||||
inline void inherited_traverse(osg::NodeVisitor& nv);
|
inline void inherited_traverse(osg::NodeVisitor& nv);
|
||||||
|
|
||||||
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||||
|
virtual void releaseGLObjects(osg::State* state = 0) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~Effect();
|
virtual ~Effect();
|
||||||
Effect &operator=(const Effect &) { return *this; }
|
Effect &operator=(const Effect &) { return *this; }
|
||||||
|
@ -37,8 +37,10 @@ namespace osgParticle
|
|||||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const PrecipitationEffect*>(obj) != 0; }
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const PrecipitationEffect*>(obj) != 0; }
|
||||||
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
|
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
|
||||||
|
|
||||||
virtual void traverse(osg::NodeVisitor& nv);
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||||
|
virtual void releaseGLObjects(osg::State* state = 0) const;
|
||||||
|
|
||||||
|
virtual void traverse(osg::NodeVisitor& nv);
|
||||||
|
|
||||||
/** Set all the parameters to create an rain effect of specified intensity.*/
|
/** Set all the parameters to create an rain effect of specified intensity.*/
|
||||||
void rain(float intensity);
|
void rain(float intensity);
|
||||||
@ -117,6 +119,9 @@ namespace osgParticle
|
|||||||
void setNumberOfVertices(unsigned int numVertices) { _numberOfVertices = numVertices; }
|
void setNumberOfVertices(unsigned int numVertices) { _numberOfVertices = numVertices; }
|
||||||
unsigned int getNumberOfVertices() const { return _numberOfVertices; }
|
unsigned int getNumberOfVertices() const { return _numberOfVertices; }
|
||||||
|
|
||||||
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||||
|
virtual void releaseGLObjects(osg::State* state) const;
|
||||||
|
|
||||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
|
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
|
||||||
|
|
||||||
struct Cell
|
struct Cell
|
||||||
@ -174,7 +179,7 @@ namespace osgParticle
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~PrecipitationDrawable() {}
|
virtual ~PrecipitationDrawable();
|
||||||
|
|
||||||
bool _requiresPreviousMatrix;
|
bool _requiresPreviousMatrix;
|
||||||
|
|
||||||
|
@ -240,6 +240,10 @@ public:
|
|||||||
/** recompute the primitives rendering meshes/lines thtat represent the sphere segment.*/
|
/** recompute the primitives rendering meshes/lines thtat represent the sphere segment.*/
|
||||||
void updatePrimitives();
|
void updatePrimitives();
|
||||||
|
|
||||||
|
|
||||||
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||||
|
virtual void releaseGLObjects(osg::State* state = 0) const;
|
||||||
|
|
||||||
virtual osg::BoundingSphere computeBound() const;
|
virtual osg::BoundingSphere computeBound() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -385,6 +385,8 @@ QueryGeometry::getNumPixels( const osg::Camera* cam )
|
|||||||
void
|
void
|
||||||
QueryGeometry::releaseGLObjects( osg::State* state ) const
|
QueryGeometry::releaseGLObjects( osg::State* state ) const
|
||||||
{
|
{
|
||||||
|
Geometry::releaseGLObjects(state);
|
||||||
|
|
||||||
if (!state)
|
if (!state)
|
||||||
{
|
{
|
||||||
// delete all query IDs for all contexts.
|
// delete all query IDs for all contexts.
|
||||||
|
@ -135,6 +135,20 @@ void Effect::traverse(osg::NodeVisitor& nv)
|
|||||||
// wow, we're finished! :)
|
// wow, we're finished! :)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Effect::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
|
{
|
||||||
|
Group::resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_dummy_for_validation) _dummy_for_validation->resizeGLObjectBuffers(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Effect::releaseGLObjects(osg::State* state) const
|
||||||
|
{
|
||||||
|
Group::releaseGLObjects(state);
|
||||||
|
if (_dummy_for_validation) _dummy_for_validation->releaseGLObjects(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Effect::build_dummy_node()
|
void Effect::build_dummy_node()
|
||||||
{
|
{
|
||||||
_dummy_for_validation = new osg::Geode;
|
_dummy_for_validation = new osg::Geode;
|
||||||
|
@ -647,6 +647,8 @@ osg::BoundingBox osgParticle::ParticleSystem::computeBoundingBox() const
|
|||||||
|
|
||||||
void osgParticle::ParticleSystem::resizeGLObjectBuffers(unsigned int maxSize)
|
void osgParticle::ParticleSystem::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
{
|
{
|
||||||
|
Drawable::resizeGLObjectBuffers(maxSize);
|
||||||
|
|
||||||
_bufferedArrayData.resize(maxSize);
|
_bufferedArrayData.resize(maxSize);
|
||||||
for(unsigned int i=0; i<_bufferedArrayData.size(); ++i)
|
for(unsigned int i=0; i<_bufferedArrayData.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -656,6 +658,8 @@ void osgParticle::ParticleSystem::resizeGLObjectBuffers(unsigned int maxSize)
|
|||||||
|
|
||||||
void osgParticle::ParticleSystem::releaseGLObjects(osg::State* state) const
|
void osgParticle::ParticleSystem::releaseGLObjects(osg::State* state) const
|
||||||
{
|
{
|
||||||
|
Drawable::releaseGLObjects(state);
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
_bufferedArrayData[state->getContextID()].releaseGLObjects(state);
|
_bufferedArrayData[state->getContextID()].releaseGLObjects(state);
|
||||||
|
@ -121,22 +121,64 @@ void PrecipitationEffect::snow(float intensity)
|
|||||||
|
|
||||||
void PrecipitationEffect::compileGLObjects(osg::RenderInfo& renderInfo) const
|
void PrecipitationEffect::compileGLObjects(osg::RenderInfo& renderInfo) const
|
||||||
{
|
{
|
||||||
if (_quadGeometry.valid())
|
if (_quadGeometry.valid()) _quadGeometry->compileGLObjects(renderInfo);
|
||||||
|
if (_lineGeometry.valid()) _lineGeometry->compileGLObjects(renderInfo);
|
||||||
|
if (_pointGeometry.valid()) _pointGeometry->compileGLObjects(renderInfo);
|
||||||
|
|
||||||
|
if (_quadStateSet.valid()) _quadStateSet->compileGLObjects(*renderInfo.getState());
|
||||||
|
if (_lineStateSet.valid()) _lineStateSet->compileGLObjects(*renderInfo.getState());
|
||||||
|
if (_pointStateSet.valid()) _pointStateSet->compileGLObjects(*renderInfo.getState());
|
||||||
|
|
||||||
|
for(ViewDrawableMap::const_iterator itr = _viewDrawableMap.begin();
|
||||||
|
itr != _viewDrawableMap.end();
|
||||||
|
++itr)
|
||||||
{
|
{
|
||||||
_quadGeometry->compileGLObjects(renderInfo);
|
const PrecipitationDrawableSet& pds = itr->second;
|
||||||
if (_quadGeometry->getStateSet()) _quadGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
if (pds._quadPrecipitationDrawable.valid()) pds._quadPrecipitationDrawable->compileGLObjects(renderInfo);
|
||||||
|
if (pds._linePrecipitationDrawable.valid()) pds._linePrecipitationDrawable->compileGLObjects(renderInfo);
|
||||||
|
if (pds._pointPrecipitationDrawable.valid()) pds._pointPrecipitationDrawable->compileGLObjects(renderInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lineGeometry.valid())
|
void PrecipitationEffect::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
{
|
{
|
||||||
_lineGeometry->compileGLObjects(renderInfo);
|
if (_quadGeometry.valid()) _quadGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
if (_lineGeometry->getStateSet()) _lineGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
if (_lineGeometry.valid()) _lineGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_pointGeometry.valid()) _pointGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
|
||||||
|
if (_quadStateSet.valid()) _quadStateSet->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_lineStateSet.valid()) _lineStateSet->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_pointStateSet.valid()) _pointStateSet->resizeGLObjectBuffers(maxSize);
|
||||||
|
|
||||||
|
for(ViewDrawableMap::const_iterator itr = _viewDrawableMap.begin();
|
||||||
|
itr != _viewDrawableMap.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
const PrecipitationDrawableSet& pds = itr->second;
|
||||||
|
if (pds._quadPrecipitationDrawable.valid()) pds._quadPrecipitationDrawable->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (pds._linePrecipitationDrawable.valid()) pds._linePrecipitationDrawable->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (pds._pointPrecipitationDrawable.valid()) pds._pointPrecipitationDrawable->resizeGLObjectBuffers(maxSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pointGeometry.valid())
|
void PrecipitationEffect::releaseGLObjects(osg::State* state) const
|
||||||
{
|
{
|
||||||
_pointGeometry->compileGLObjects(renderInfo);
|
if (_quadGeometry.valid()) _quadGeometry->releaseGLObjects(state);
|
||||||
if (_pointGeometry->getStateSet()) _pointGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
|
if (_lineGeometry.valid()) _lineGeometry->releaseGLObjects(state);
|
||||||
|
if (_pointGeometry.valid()) _pointGeometry->releaseGLObjects(state);
|
||||||
|
|
||||||
|
if (_quadStateSet.valid()) _quadStateSet->releaseGLObjects(state);
|
||||||
|
if (_lineStateSet.valid()) _lineStateSet->releaseGLObjects(state);
|
||||||
|
if (_pointStateSet.valid()) _pointStateSet->releaseGLObjects(state);
|
||||||
|
|
||||||
|
for(ViewDrawableMap::const_iterator itr = _viewDrawableMap.begin();
|
||||||
|
itr != _viewDrawableMap.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
const PrecipitationDrawableSet& pds = itr->second;
|
||||||
|
if (pds._quadPrecipitationDrawable.valid()) pds._quadPrecipitationDrawable->releaseGLObjects(state);
|
||||||
|
if (pds._linePrecipitationDrawable.valid()) pds._linePrecipitationDrawable->releaseGLObjects(state);
|
||||||
|
if (pds._pointPrecipitationDrawable.valid()) pds._pointPrecipitationDrawable->releaseGLObjects(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,7 +871,24 @@ PrecipitationEffect::PrecipitationDrawable::PrecipitationDrawable(const Precipit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrecipitationEffect::PrecipitationDrawable::~PrecipitationDrawable()
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"PrecipitationEffect::~PrecipitationDrawable() "<<this<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrecipitationEffect::PrecipitationDrawable::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
|
{
|
||||||
|
Drawable::resizeGLObjectBuffers(maxSize);
|
||||||
|
|
||||||
|
if (_geometry) _geometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrecipitationEffect::PrecipitationDrawable::releaseGLObjects(osg::State* state) const
|
||||||
|
{
|
||||||
|
Drawable::releaseGLObjects(state);
|
||||||
|
|
||||||
|
if (_geometry) _geometry->releaseGLObjects(state);
|
||||||
|
}
|
||||||
|
|
||||||
void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
|
void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,11 @@ LightPointDrawable::LightPointDrawable(const LightPointDrawable& lpd,const osg::
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LightPointDrawable::~LightPointDrawable()
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"LightPointDrawable::~LightPointDrawable()"<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void LightPointDrawable::reset()
|
void LightPointDrawable::reset()
|
||||||
{
|
{
|
||||||
SizedLightPointList::iterator itr;
|
SizedLightPointList::iterator itr;
|
||||||
|
@ -102,7 +102,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~LightPointDrawable() {}
|
virtual ~LightPointDrawable();
|
||||||
|
|
||||||
osg::Endian _endian;
|
osg::Endian _endian;
|
||||||
|
|
||||||
|
@ -93,6 +93,32 @@ void SphereSegment::traverse(osg::NodeVisitor& nv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SphereSegment::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
|
{
|
||||||
|
if (_surfaceGeometry.valid()) _surfaceGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_spokesGeometry.valid()) _spokesGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_edgeLineGeometry.valid()) _edgeLineGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_sidesGeometry.valid()) _sidesGeometry->resizeGLObjectBuffers(maxSize);
|
||||||
|
|
||||||
|
if (_litOpaqueState.valid()) _litOpaqueState->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_unlitOpaqueState.valid()) _unlitOpaqueState->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_litTransparentState.valid()) _litTransparentState->resizeGLObjectBuffers(maxSize);
|
||||||
|
if (_unlitTransparentState.valid()) _unlitTransparentState->resizeGLObjectBuffers(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SphereSegment::releaseGLObjects(osg::State* state) const
|
||||||
|
{
|
||||||
|
if (_surfaceGeometry.valid()) _surfaceGeometry->releaseGLObjects(state);
|
||||||
|
if (_spokesGeometry.valid()) _spokesGeometry->releaseGLObjects(state);
|
||||||
|
if (_edgeLineGeometry.valid()) _edgeLineGeometry->releaseGLObjects(state);
|
||||||
|
if (_sidesGeometry.valid()) _sidesGeometry->releaseGLObjects(state);
|
||||||
|
|
||||||
|
if (_litOpaqueState.valid()) _litOpaqueState->releaseGLObjects(state);
|
||||||
|
if (_unlitOpaqueState.valid()) _unlitOpaqueState->releaseGLObjects(state);
|
||||||
|
if (_litTransparentState.valid()) _litTransparentState->releaseGLObjects(state);
|
||||||
|
if (_unlitTransparentState.valid()) _unlitTransparentState->releaseGLObjects(state);
|
||||||
|
}
|
||||||
|
|
||||||
osg::BoundingSphere SphereSegment::computeBound() const
|
osg::BoundingSphere SphereSegment::computeBound() const
|
||||||
{
|
{
|
||||||
_bbox.init();
|
_bbox.init();
|
||||||
|
Loading…
Reference in New Issue
Block a user