#4857 Avoid crash in annotations picking whith distorted view

This commit is contained in:
Jacob Støren
2019-10-29 13:54:32 +01:00
parent 469397bfd1
commit 2702c3b078

View File

@@ -1354,17 +1354,20 @@ void RiuViewerCommands::handleTextPicking( int winPosX, int winPosY, cvf::HitIte
ref<Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates( translatedMousePosX, translatedMousePosY ); ref<Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates( translatedMousePosX, translatedMousePosY );
for ( size_t pIdx = 0; pIdx < partCollection.size(); ++pIdx ) if ( ray.notNull() )
{ {
DrawableText* textDrawable = dynamic_cast<DrawableText*>( partCollection[pIdx]->drawable() ); for ( size_t pIdx = 0; pIdx < partCollection.size(); ++pIdx )
if ( textDrawable )
{ {
cvf::Vec3d ppoint; DrawableText* textDrawable = dynamic_cast<DrawableText*>(partCollection[pIdx]->drawable());
if ( textDrawable->rayIntersect( *ray, *( m_viewer->mainCamera() ), &ppoint ) ) if ( textDrawable )
{ {
cvf::ref<HitItem> hitItem = new HitItem( 0, ppoint ); cvf::Vec3d ppoint;
hitItem->setPart( partCollection[pIdx].p() ); if ( textDrawable->rayIntersect(*ray, *(m_viewer->mainCamera()), &ppoint) )
hitItems->add( hitItem.p() ); {
cvf::ref<HitItem> hitItem = new HitItem(0, ppoint);
hitItem->setPart(partCollection[pIdx].p());
hitItems->add(hitItem.p());
}
} }
} }
} }