mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +01:00
Try to place new pieces near existing parts or the origin #548.
This commit is contained in:
parent
1925c476d6
commit
e5a8eebdb8
1 changed files with 14 additions and 1 deletions
|
@ -433,15 +433,28 @@ lcMatrix44 View::GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) co
|
|||
Point = lcMul31(Point, InverseMatrix);
|
||||
}
|
||||
|
||||
const lcBoundingBox& BoundingBox = Info->GetBoundingBox();
|
||||
lcVector3 Intersection;
|
||||
|
||||
const lcBoundingBox& BoundingBox = Info->GetBoundingBox();
|
||||
if (lcLineSegmentPlaneIntersection(&Intersection, ClickPoints[0], ClickPoints[1], lcVector4(0, 0, 1, BoundingBox.Min.z)))
|
||||
{
|
||||
Intersection = ActiveModel->SnapPosition(Intersection);
|
||||
return lcMatrix44Translation(Intersection);
|
||||
}
|
||||
|
||||
lcVector3 Position;
|
||||
|
||||
if (!ActiveModel->GetFocusPosition(Position))
|
||||
Position = ActiveModel->GetSelectionOrModelCenter();
|
||||
|
||||
lcVector3 FrontVector(mCamera->mTargetPosition - mCamera->mPosition);
|
||||
|
||||
if (lcLineSegmentPlaneIntersection(&Intersection, ClickPoints[0], ClickPoints[1], lcVector4(FrontVector, -lcDot(FrontVector, Position))))
|
||||
{
|
||||
Intersection = ActiveModel->SnapPosition(Intersection);
|
||||
return lcMatrix44Translation(Intersection);
|
||||
}
|
||||
|
||||
return lcMatrix44Translation(UnprojectPoint(lcVector3((float)mMouseX, (float)mMouseY, 0.9f)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue