WS30: Fix crash on reset caused by VPBTechnique

This commit is contained in:
Stuart Buchanan 2021-08-01 20:48:27 +01:00
parent 4f01f758ae
commit dc1d6284fd
2 changed files with 9 additions and 3 deletions

View File

@ -2251,6 +2251,13 @@ void VPBTechnique::removeElevationConstraint(osg::ref_ptr<osg::Node> constraint)
_constraintGroup->removeChild(constraint.get()); _constraintGroup->removeChild(constraint.get());
} }
void VPBTechnique::clearElevationConstraints()
{
const std::lock_guard<std::mutex> lock(VPBTechnique::_constraint_mutex); // Lock the _constraintGroup for this scope
_constraintGroup = new osg::Group();
}
// Check a given vertex against any elevation constraints E.g. to ensure the terrain mesh doesn't // Check a given vertex against any elevation constraints E.g. to ensure the terrain mesh doesn't
// poke through any airport meshes. If such a constraint exists, the function will return a replacement // poke through any airport meshes. If such a constraint exists, the function will return a replacement
// vertex displaces such that it lies 1m below the contraint relative to the passed in origin. // vertex displaces such that it lies 1m below the contraint relative to the passed in origin.

View File

@ -95,6 +95,7 @@ class VPBTechnique : public TerrainTechnique
static void addElevationConstraint(osg::ref_ptr<osg::Node> constraint, osg::Group* terrain); static void addElevationConstraint(osg::ref_ptr<osg::Node> constraint, osg::Group* terrain);
static void removeElevationConstraint(osg::ref_ptr<osg::Node> constraint); static void removeElevationConstraint(osg::ref_ptr<osg::Node> constraint);
static osg::Vec3d checkAgainstElevationConstraints(osg::Vec3d origin, osg::Vec3d vertex, float vertex_gap); static osg::Vec3d checkAgainstElevationConstraints(osg::Vec3d origin, osg::Vec3d vertex, float vertex_gap);
static void clearElevationConstraints();
// LineFeatures and AreaFeatures are draped over the underlying mesh. // LineFeatures and AreaFeatures are draped over the underlying mesh.
static void addLineFeatureList(SGBucket bucket, LineFeatureBinList roadList); static void addLineFeatureList(SGBucket bucket, LineFeatureBinList roadList);
@ -183,7 +184,7 @@ class VPBTechnique : public TerrainTechnique
osg::ref_ptr<osg::Uniform> _filterMatrixUniform; osg::ref_ptr<osg::Uniform> _filterMatrixUniform;
osg::ref_ptr<SGReaderWriterOptions> _options; osg::ref_ptr<SGReaderWriterOptions> _options;
inline static osg::ref_ptr<osg::Group> _constraintGroup = new osg::Group();; inline static osg::ref_ptr<osg::Group> _constraintGroup = new osg::Group();
inline static std::mutex _constraint_mutex; // protects the _constraintGroup; inline static std::mutex _constraint_mutex; // protects the _constraintGroup;
typedef std::pair<SGBucket, LineFeatureBinList> BucketLineFeatureBinList; typedef std::pair<SGBucket, LineFeatureBinList> BucketLineFeatureBinList;
@ -198,10 +199,8 @@ class VPBTechnique : public TerrainTechnique
inline static std::list<BucketCoastlineBinList> _coastFeatureLists; inline static std::list<BucketCoastlineBinList> _coastFeatureLists;
inline static std::mutex _coastFeatureLists_mutex; // protects the _areaFeatureLists; inline static std::mutex _coastFeatureLists_mutex; // protects the _areaFeatureLists;
}; };
}; };
#endif #endif