Dynamic delete node from group. #1050
Replies: 3 comments 1 reply
-
This should work as expected, more or less, with a couple of caveats. You don't need to recompile the group after you modify it like this. Also, at the present time low-level Vulkan objects aren't protected from deletion while they are still in use rendering the current frame (I think?) Applications that delete nodes maintain a C++ list or a non-rendered VSG group to keep deleted objects around for 2 or three frames before deleting them. |
Beta Was this translation helpful? Give feedback.
-
I have moved this thread to the Discussion forum as it'll likely be something that would benefit wider discussion that will be useful for others down the line, As Tim mentions you can delete children directly, but you need to mindful of subgraphs that have been rendered in the last few frames as Vulkan state associated with them may still be in use by one of these previous frames - the CPU and GPUs operate in a parallel, and the CPU frame may be several frames ahead of the current frame being rendered on the GPU. To avoid deleting objects that are still currently being rendering you need to temporarily cache the subgraphs scheduled for deletion. The VSG doesn't currently provide this for you, but it's a on my TODO list. It may require an explicit mechanism but there is also a chance I may be able to leverage the way the scene graph object holds the Vulkan objects. |
Beta Was this translation helpful? Give feedback.
-
I use a vsg::Operation as a deffered delete. This needs to be added with the ALL_FRAMES flag, so I don't call it directly, but have opDetach and opMerge structures as well. The frameDelay probably only needs to be 3. Robert, I won't send a PR because it's not obvious from the vsg code how you would like to implement something like this. I can't see any default Operations.
You can use it like this
Hope this helps. Regards, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
I'm trying to remove some nodes from a group, but something went wrong. The deleted nodes still seem to be drawn, and their positions and colors are wrong.
I'm new to vsg, and I can only find examples of adding node to group dynamically. I would like to know if dynamically deleting nodes from a group is currently supported.
Describe the solution you'd like
Something like
group->remove_if(function);
Describe alternatives you've considered
auto children = group->children;
auto itr = remove_if(children.begin(), children.end(), [](){ some judgment; });
children.erase(itr, children.end());
auto result = viewer->compileManager->compile(group);
updateViewer(*viewer, result);
Additional context

The green line in the picture appears incorrectly when I delete some outdated data.
Beta Was this translation helpful? Give feedback.
All reactions