gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.48k stars 773 forks source link

the function setVisible of FeatureModelLayer is invalid #2605

Open zyxgis opened 1 month ago

zyxgis commented 1 month ago

i use vcpkg toolchain to compile osgearth

this is my osgearth's version infos:

osgearth_versiond.exe --caps [osgearth info] Hello, world. [osgearth info] [Capabilities] osgEarth Version: 3.6.0 build 158 [osgearth info] [Capabilities] GDAL Version: 3.9.0 [osgearth info] [Capabilities] OSG Version: 3.6.5 [osgearth info] [Capabilities] OSG GL3 Features: yes [osgearth info] [Capabilities] OSG FFP Available: no [osgearth info] [Capabilities] CPU Cores: 12 [osgearth info] [Capabilities] GL_VENDOR: Intel [osgearth info] [Capabilities] GL_RENDERER: Intel(R) UHD Graphics 630 [osgearth info] [Capabilities] GL_VERSION: 3.3.0 - Build 31.0.101.2127 [osgearth info] [Capabilities] GL CORE Profile: yes [osgearth info] Goodbye.

my codes is :

osgEarth::OGRFeatureSource *featureSource = new osgEarth::OGRFeatureSource();
featureSource->setName("vector-1");
featureSource->setURL("E:/osgearth/data/world.shp"); // 
//this->getMapNode()->getMap()->addLayer(featureSource);
//
osgEarth::Style style;
style.getOrCreateSymbol<osgEarth::LineSymbol>()->stroke().mutable_value().color() = osgEarth::Color::Yellow;
style.getOrCreateSymbol<osgEarth::LineSymbol>()->stroke().mutable_value().width() = 2.0f;
style.getOrCreateSymbol<osgEarth::LineSymbol>()->tessellationSize() = osgEarth::Distance(100, osgEarth::Units::KILOMETERS);
style.getOrCreate<osgEarth::AltitudeSymbol>()->clamping() = osgEarth::AltitudeSymbol::CLAMP_TO_TERRAIN;
style.getOrCreate<osgEarth::AltitudeSymbol>()->technique() = osgEarth::AltitudeSymbol::TECHNIQUE_GPU;
style.getOrCreate<osgEarth::RenderSymbol>()->depthOffset().mutable_value().enabled() = true;
//
osgEarth::FeatureModelLayer *featureModelLayer = new osgEarth::FeatureModelLayer();
featureModelLayer->setFeatureSource(featureSource);
osgEarth::StyleSheet *styleSheet = new osgEarth::StyleSheet();
styleSheet->addStyle(style);
featureModelLayer->setStyleSheet(styleSheet);
featureModelLayer->setName(filename);
this->getMapNode()->getMap()->addLayer(featureModelLayer);

......

featureModelLayer->setVisible(false);  // the setVisible function is invalid, the featureModelLayer is still visible.
gwaldron commented 1 month ago

Unfortunately I am unable to reproduce this due to the crash when using TECHNIQUE_GPU. I would recommend avoiding that option though; try TECHNIQUE_DRAPE instead.

gwaldron commented 2 weeks ago

I believe the problem here is a conflict between the VisibleLayer's culling callback (which permits culling to happen even when a layer is invisible) and the ClampableNode/DrapeableNode (which don't add leaves to the normal render graph during cull).