Skip to content

Scale object with Transform Object plugin#330

Merged
oitel merged 17 commits intomasterfrom
object_transform_scaling
Aug 5, 2022
Merged

Scale object with Transform Object plugin#330
oitel merged 17 commits intomasterfrom
object_transform_scaling

Conversation

@oitel
Copy link
Contributor

@oitel oitel commented Aug 2, 2022

No description provided.

@oitel oitel requested a review from Grantim August 2, 2022 15:53
Comment on lines +255 to +256
scaleMode_ = ( modifier == GLFW_MOD_CONTROL );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be controlled from plugin, not from widget

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


const auto scale = ( newScaling - prevScaling_ ) + Vector3f::diagonal( 1 );
auto addXf = xf * AffineXf3f::xfAround( Matrix3f::scale( scale ), center_ ) * xf.inverse();
addXf_( addXf );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not apply scale xf to widget

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

bool ObjectTransformWidget::onMouseDown_( Viewer::MouseButton button, int )
bool ObjectTransformWidget::onMouseDown_( Viewer::MouseButton button, int modifier )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unised modifier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


// Changes controls xf (controls will affect object in basis of new xf)
// note that rotation is applied around 0 coordinate in world space, so use xfAround to process rotation around user defined center
void setControlsXf( const AffineXf3f& xf );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public methods with hidden implementation should have MRVIEWER_API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +99 to +118
void decomposeQR( const Matrix3f& m, Matrix3f& q, Matrix3f& r )
{
Eigen::HouseholderQR<Eigen::MatrixXf> qr( toEigen( m ) );
q = fromEigen( Eigen::Matrix3f{ qr.householderQ() } );
r = fromEigen( Eigen::Matrix3f{ qr.matrixQR() } );
r.y.x = r.z.x = r.z.y = 0;
}

void decomposePositiveQR( const Matrix3f& m, Matrix3f& q, Matrix3f& r )
{
decomposeQR( m, q, r );
Matrix3f sign;
for ( int i = 0; i < 3; ++i )
{
if ( r[i][i] < 0 )
sign[i][i] = -1;
}
q = q * sign;
r = sign * r;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have same funcitons in ImGuiMenu, mb make separate functoin like extractScale( AffineXf3f& xf ) to separate scale from rigid transform somewhere in MRMesh project?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented.

Copy link
Contributor

@Grantim Grantim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you reset thresholdDot in create or reset function (https://github.com/MeshInspector/MeshInspectorCode/issues/872)

Comment on lines +9 to +10
template <typename T>
void decomposeXf( const AffineXf3<T>& xf, Matrix3<T>& rotation, Matrix3<T>& scaling )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comment this function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Comment on lines 126 to 129
SceneRoot::get().addChild( activeLine_ );
controlsRoot_->setXf( worldXf );
setControlsXf( worldXf );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please set default mode (Translation) in create or mb better reset function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


AxisTransformMode axisTransformMode_{ Translation };

float sumScale_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add init vaule

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

bool picked_{ false };
bool pickThrough_{ false };

std::function<void( float )> scaleTooltipCallback_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to reset it in create or reset function (like other callbacks)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +56 to +62
enum AxisTransformMode
{
Translation,
Scaling,
};
AxisTransformMode getAxisTransformMode() const { return axisTransformMode_; };
void setAxisTransformMode( AxisTransformMode mode ) { axisTransformMode_ = mode; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add commets about this structure and how scale works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@oitel oitel merged commit 169cfea into master Aug 5, 2022
@oitel oitel deleted the object_transform_scaling branch August 5, 2022 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants