Skip to content

Commit 56a57d1

Browse files
committed
makeMovementBuildBody: startMeshFromBody option
1 parent 126163c commit 56a57d1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

source/MRMesh/MRMovementBuildBody.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Mesh makeMovementBuildBody( const Contours3f& bodyContours, const Contours3f& tr
2222
trajC.erase( std::unique( trajC.begin(), trajC.end() ), trajC.end() );
2323

2424
AffineXf3f xf;
25+
std::optional<AffineXf3f> xf0Inv;
2526
Vector3f trans;
2627
Matrix3f prevHalfRot;
2728
Matrix3f accumRot;
@@ -173,6 +174,12 @@ Mesh makeMovementBuildBody( const Contours3f& bodyContours, const Contours3f& tr
173174
}
174175
}
175176
xf = AffineXf3f::translation( trans ) * AffineXf3f::xfAround( scaling * accumRot, center );
177+
if ( params.startMeshFromBody )
178+
{
179+
if ( !xf0Inv )
180+
xf0Inv = xf.inverse();
181+
xf = *xf0Inv * xf;
182+
}
176183
if ( params.b2tXf )
177184
xf = xf * ( *params.b2tXf );
178185

source/MRMesh/MRMovementBuildBody.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ struct MovementBuildBodyParams
1212
/// according to its rotation
1313
/// otherwise body movement will be done without any rotation
1414
bool allowRotation{ true };
15+
1516
/// point in body space that follows trajectory
1617
/// if not set body bounding box center is used
1718
std::optional<Vector3f> center;
19+
1820
/// facing direction of body, used for initial rotation (if allowRotation)
1921
/// if not set body accumulative normal is used
2022
std::optional<Vector3f> bodyNormal;
23+
2124
/// optional transform body space to trajectory space
2225
const AffineXf3f* b2tXf{ nullptr };
26+
27+
/// if true, then body-contours will be located exactly on resulting mesh
28+
bool startMeshFromBody{ false };
2329
};
2430

2531
/// makes mesh by moving `body` along `trajectory`

0 commit comments

Comments
 (0)