Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the polygon outlines #2700

Open
pks23 opened this issue Feb 5, 2025 · 5 comments
Open

Hide the polygon outlines #2700

pks23 opened this issue Feb 5, 2025 · 5 comments
Assignees
Labels
defect It's busted

Comments

@pks23
Copy link

pks23 commented Feb 5, 2025

osgEarth Version (required): 3.7

Description of the problem: Not able to the polygon outlines

What you have tried: Added custom shader for hiding the polygon by objectid.

I am working with osgEarth’s C++ API and have loaded a shapefile as a FeatureModelLayer. I need to hide the polygons upon selection, which I have achieved using shaders (making the polygon transparent) and objectid. However, the polygon outlines are still visible because they are rendered by LineDrawable.

To hide the outlines, I attempted to find the corresponding geode using nodeIntersector to get the LineGroup containing the outlines. I then used the following code to identify the LineDrawable:

osgEarth::LineGroup group = findAllNodesByTypeosgEarth::LineGroup(lyrNode).at(0);

Despite enabling feature indexing for the FeatureSource, the LineDrawable objects are not tagged with objectid.

Upon debugging, I found that in the BuildGeometryFilter class, the processLines function uses this line for tagging:

if (context.featureIndex())

{

context.featureIndex()->tagDrawable(drawable, input); 

}

However, the tagDrawable function only tags geometry class objects and does not tag the node, which prevents me from hiding the outlines effectively.

Could you please help identify a solution to hide the polygon outlines?

@gwaldron gwaldron added the support Support questions label Feb 5, 2025
@gwaldron
Copy link
Owner

Ok, I am a little confused here.

Are you saying that LineDrawables are not getting an object id?

Is all this stuff about LineGroups and nodes just your attempt at a workaround?

I added some polygon outlines to feature_polygons.earth and they are tagged just fine according to the picker.

@pks23
Copy link
Author

pks23 commented Feb 13, 2025

I wrote a custom shader to hide a polygon using its ObjectID, and it works fine. But the polygon's outline is still visible. I tried to find the drawable for the outline, but it doesn’t have an ObjectID, so I couldn’t identify it.

@gwaldron
Copy link
Owner

Object IDs are not stored in the scene graph, but rather in the ObjectIndex so you need to call

std::set<ObjectID> object_ids;
ObjectIndex::getObjectIDs(drawable, object_ids);

@pks23
Copy link
Author

pks23 commented Feb 19, 2025

I used ObjectIndex to find the ID:

auto group = findAllNodesByTypeosgEarth::LineGroup(lyrNode).at(0);
auto drawable = dynamic_castosgEarth::LineDrawable* (group->getChild(0)->asDrawable());
std::set object_ids;
obi->getObjectIDs(drawable, object_ids);

But getObjectIDs function returns while attempting to cast drawable as geometry.

bool ObjectIndex::getObjectIDs(const osg::Drawable* drawable, std::set& output) const
{
if (!drawable) return false;

// It returns from this line
const osg::Geometry* geometry = drawable->asGeometry();
if (!geometry) return false;

const ObjectIDArray* oids = dynamic_cast<const ObjectIDArray*>(geometry->getVertexAttribArray(_attribLocation));
if ( !oids ) return false;
if (oids->empty()) return false;
for (ObjectIDArray::const_iterator i = oids->begin(); i != oids->end(); ++i)
    output.insert( *i );
return true;

}

The same issue occurs when ObjectIndex attempts to tag the drawable, the function returns after the asGeometry() call.

gwaldron added a commit that referenced this issue Feb 19, 2025
…t to not work on non-Geometry Drawables (like LineDrawable), #2700
@gwaldron
Copy link
Owner

Hey, now we are getting somewhere! Thanks for tracking down this bug. I have pushed a fix for this - please test and report back.

@gwaldron gwaldron added defect It's busted and removed support Support questions labels Feb 19, 2025
@gwaldron gwaldron self-assigned this Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect It's busted
Projects
None yet
Development

No branches or pull requests

2 participants