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

Method processRotation_

source/MRViewer/MRObjectTransformWidget.cpp:402–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402void ObjectTransformWidget::processRotation_( Axis ax, bool press )
403{
404 const auto& mousePos = getViewerInstance().mouseController().getMousePos();
405 auto& viewport = getViewerInstance().viewport();
406 auto viewportPoint = getViewerInstance().screenToViewport( Vector3f( float( mousePos.x ), float( mousePos.y ), 0.f ), viewport.id );
407 auto line = viewport.unprojectPixelRay( Vector2f( viewportPoint.x, viewportPoint.y ) );
408
409 auto xf = controlsRoot_->xf( viewport.id );
410 const auto& wCenter = controls_->getCenter();
411 auto wRadius = controls_->getRadius();
412 auto zeroPoint = xf( wCenter + baseAxis[( int( ax ) + 1 ) % 3] * wRadius );
413 auto norm = xf.A * ( baseAxis[int( ax )] );
414 auto centerTransformed = xf( wCenter );
415 auto angle = findAngleDegOfPick( centerTransformed, zeroPoint, norm, line, viewport, viewportPoint );
416
417 if ( press )
418 {
419 accumAngle_ = 0.0f;
420 startAngle_ = angle;
421 }
422
423 auto addXf = AffineXf3f::xfAround( Matrix3f::rotation( xf.A * baseAxis[int( ax )], angle - startAngle_ ), centerTransformed );
424
425 addXf_( addXf );
426 accumAngle_ += ( angle - startAngle_ );
427
428 if ( accumAngle_ > PI_F )
429 accumAngle_ = accumAngle_ - 2.0f * PI_F;
430 else if ( accumAngle_ < -PI_F )
431 accumAngle_ = 2.0f * PI_F + accumAngle_;
432
433 if ( controls_ )
434 controls_->updateRotation( ax, controlsRoot_->xf( viewport.id ), startAngle_, startAngle_ + accumAngle_, viewport.id );
435}
436
437void ObjectTransformWidget::setControlsXf_( const AffineXf3f& xf, bool updateScaled, ViewportId id )
438{

Callers

nothing calls this directly

Calls 7

findAngleDegOfPickFunction · 0.85
screenToViewportMethod · 0.80
unprojectPixelRayMethod · 0.80
updateRotationMethod · 0.80
xfMethod · 0.45
getCenterMethod · 0.45
getRadiusMethod · 0.45

Tested by

no test coverage detected