2019-11-05
去年,公司项目在三维交互中提出了一项需求。在QGLWidget上构造的右键菜单中直接删除点选中的对象。对于被选择的普通三维对象,弹出的右键菜单删除它是没有问题的,但是,删除overlay层控件时,却导致OSG内部崩溃。我查看了一下OSG源代码,发现是设计之初没有考虑过这个需求。然而,实现这个功能patch却是很简单的,只需要修改两个文件,并且,需要定制osgWidget::WindowManager,重新实现removeChild(Node *child)。具体修改代码如下:
src/osgWidget/WindowManager.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/osgWidget/WindowManager.cpp b/src/osgWidget/WindowManager.cpp
index 7bccbd348..d4561f790 100644
--- a/src/osgWidget/WindowManager.cpp
+++ b/src/osgWidget/WindowManager.cpp
@@ -634,4 +634,14 @@ osg::Camera* WindowManager::createParentOrthoCamera() {
return camera;
}
+void WindowManager::setLastEventNull()
+{
+ this->_lastEvent = nullptr;
+}
+
+const osgWidget::EventInterface* WindowManager::lastEvent()
+{
+ return this->_lastEvent ;
+}
+
}
include/osgWidget/WindowManager | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/osgWidget/WindowManager

最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



