osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

FeatureNode not updating in update callback

Open gwaldron opened this issue 3 years ago • 3 comments

Discussed in https://github.com/gwaldron/osgearth/discussions/2068

Originally posted by keince May 18, 2022 I have a FeatureNode that contains one feature that is a single line segment. I can create the feature just fine and have it display on the map. However, when I try to update the feature endpoint positions in an update callback attached to the FeatureNode, the line disappears once I call FeatureNode->dirty(). If does appear to be updating the endpoint positions because once I pause the updates in the callback, the line reappears with the updated endpoints.

Any ideas on why this is happening? I thought that it was sufficient to call dirty() on the FeatureNode if the feature is modified.

Any help would be appreciated...

-S

gwaldron avatar May 20 '22 13:05 gwaldron

@keince Could you provide a simple way for us to reproduce the issue? (Perhaps by modifying some code in osgearth_annotation.cpp)

gwaldron avatar May 20 '22 13:05 gwaldron

Glenn,

Let me be more specific in what I'm doing in my implementation.

I've got a tool that is subclassed off of osgGA::GUIEventHandler and that handler is added to a view. Inside of this handler, I have a FeatureNode object. The handler's handle() method is used to create the line segment with the mouse (LMB PUSH creates the start point, DRAG updates the endpoint, LMB RELEASE sets the endpoint). Once the line segment or feature is created, I'm using an update callback attached to the featureNode to update the endpoint positions of the feature from an external source. When I update the positions in the update callback, I call featureNode->dirty() which should update the line endpoints on the map. Instead, the line disappears. Interestingly, when I pause the updates in the update callback, the line reappears with the updated positions indicating that it is being updated on the dirty() call. It's just not rendering on the map during the update.

I hope this helps in describing the problem in more detail.

I'm not sure I can replicate in osgearth_annotation.cpp. I will investigate further to see what I can do.

-Shayne

keince avatar May 24 '22 22:05 keince

This is essentially what TerrainGUI is doing with the _measureCursor feature node, except that it's using SingleThreaded mode so can simply update it directly. But it might be a handy template for making a reproduction case if you haven't already figured this out.

gwaldron avatar Jun 06 '22 16:06 gwaldron