MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / hover_

Method hover_

source/MRViewer/MRObjectTransformWidget.cpp:700–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

698}
699
700ControlBit TransformControls::hover_( bool pickThrough )
701{
702 int hoveredInd = findHoveredIndex_();
703
704 auto& linesArray = hoveredInd < 3 ? translateLines_ : rotateLines_;
705 if ( hoveredInd > 2 )
706 hoveredInd -= 3;
707
708 auto dropCurrentObj = [&] ()
709 {
710 if ( hoveredObject_ )
711 {
712 auto color = hoveredObject_->getFrontColor( true );
713 hoveredObject_->setFrontColor( color, false );
714 assert( hoveredInd >= 0 );
715 linesArray[hoveredInd]->setFrontColor( params_.helperLineColor, false );
716 linesArray[hoveredInd]->setLineWidth( 1.0f );
717 }
718 hoveredObject_.reset();
719 hoveredInd = -1;
720 };
721
722 std::vector<VisualObject*> objsToPick_;
723 objsToPick_.reserve( 6 );
724 auto hoveredViewportId = getViewerInstance().getHoveredViewportId();
725
726 if ( pickThrough )
727 {
728 for ( auto obj : translateControls_ )
729 {
730 if ( obj->isVisible( hoveredViewportId ) )
731 objsToPick_.push_back( obj.get() );
732 }
733 for ( auto obj : rotateControls_ )
734 {
735 if ( obj->isVisible( hoveredViewportId ) )
736 objsToPick_.push_back( obj.get() );
737 }
738 }
739
740 const auto& vp = getViewerInstance().viewport( hoveredViewportId );
741
742 auto [obj, pick] = pickThrough ? vp.pickRenderObject( objsToPick_ ) : vp.pick_render_object();
743 if ( !obj )
744 {
745 dropCurrentObj();
746 return ControlBit::None;
747 }
748 auto meshObj = std::dynamic_pointer_cast< ObjectMesh >( obj );
749 if ( !meshObj )
750 {
751 dropCurrentObj();
752 return ControlBit::None;
753 }
754 bool isControl = meshObj->parent() == translateControls_[0]->parent();
755 if ( !isControl )
756 {
757 dropCurrentObj();

Callers

nothing calls this directly

Calls 11

getHoveredViewportIdMethod · 0.80
isVisibleMethod · 0.80
push_backMethod · 0.80
pickRenderObjectMethod · 0.80
pick_render_objectMethod · 0.80
setFrontColorMethod · 0.45
setLineWidthMethod · 0.45
resetMethod · 0.45
reserveMethod · 0.45
getMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected