osgearth2.5 对controls Container里addControl作了修改,所有从Control 继承来的控件容器和addChild一起放在同一节点下面,不再单独放置,即addchild包括了addcontrol .但在ControlCanvas类中源码仍然使用Control* control = static_cast<Control*>( getChild(i) );control->handle(ea, aa, _context);进行强制转换,这对于不是从Control类继承来的子节点是不对的.参考源码controls.cpp中其它类并没这样使用.如.Control*
c = dynamic_cast<Control*>( rowGroup->getChild(j) ); if ( c ){ c->draw( cx );} .所以解决办法 Control* control = dynamic_cast<Control*>( getChild(i) );if ( NULL == control ){continue;}
osgearth2.5 Container
最新推荐文章于 2022-12-07 20:57:40 发布
本文分析了osgEarth 2.5版本中controlsContainer内addControl方法的改动导致的问题,并提出了解决方案。由于源码中使用了不恰当的强制类型转换,这可能导致对非Control类子节点的错误处理。文章推荐使用动态类型转换来规避这一问题。
5177

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



