Better piece insert position when using the keyboard.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "lc_array.h"
|
|
||||||
#include "lc_math.h"
|
#include "lc_math.h"
|
||||||
|
|
||||||
class Project;
|
class Project;
|
||||||
|
|||||||
+7
-7
@@ -2273,9 +2273,9 @@ lcMatrix33 lcModel::GetRelativeRotation() const
|
|||||||
|
|
||||||
void lcModel::AddPiece()
|
void lcModel::AddPiece()
|
||||||
{
|
{
|
||||||
PieceInfo* CurPiece = gMainWindow->GetCurrentPieceInfo();
|
PieceInfo* PieceInfo = gMainWindow->GetCurrentPieceInfo();
|
||||||
|
|
||||||
if (!CurPiece)
|
if (!PieceInfo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcPiece* Last = mPieces.empty() ? nullptr : mPieces[mPieces.size() - 1];
|
lcPiece* Last = mPieces.empty() ? nullptr : mPieces[mPieces.size() - 1];
|
||||||
@@ -2290,11 +2290,12 @@ void lcModel::AddPiece()
|
|||||||
}
|
}
|
||||||
|
|
||||||
lcMatrix44 WorldMatrix;
|
lcMatrix44 WorldMatrix;
|
||||||
|
const lcBoundingBox& PieceInfoBoundingBox = PieceInfo->GetBoundingBox();
|
||||||
|
|
||||||
if (Last)
|
if (Last)
|
||||||
{
|
{
|
||||||
const lcBoundingBox& BoundingBox = Last->GetBoundingBox();
|
const lcBoundingBox& LastBoundingBox = Last->GetBoundingBox();
|
||||||
lcVector3 Dist(0, 0, BoundingBox.Max.z - BoundingBox.Min.z);
|
lcVector3 Dist(0, 0, LastBoundingBox.Max.z - PieceInfoBoundingBox.Min.z);
|
||||||
Dist = SnapPosition(Dist);
|
Dist = SnapPosition(Dist);
|
||||||
|
|
||||||
WorldMatrix = Last->mModelWorld;
|
WorldMatrix = Last->mModelWorld;
|
||||||
@@ -2302,11 +2303,10 @@ void lcModel::AddPiece()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const lcBoundingBox& BoundingBox = CurPiece->GetBoundingBox();
|
WorldMatrix = lcMatrix44Translation(lcVector3(0.0f, 0.0f, -PieceInfoBoundingBox.Min.z));
|
||||||
WorldMatrix = lcMatrix44Translation(lcVector3(0.0f, 0.0f, -BoundingBox.Min.z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lcPiece* Piece = new lcPiece(CurPiece);
|
lcPiece* Piece = new lcPiece(PieceInfo);
|
||||||
Piece->Initialize(WorldMatrix, mCurrentStep);
|
Piece->Initialize(WorldMatrix, mCurrentStep);
|
||||||
Piece->SetColorIndex(gMainWindow->mColorIndex);
|
Piece->SetColorIndex(gMainWindow->mColorIndex);
|
||||||
AddPiece(Piece);
|
AddPiece(Piece);
|
||||||
|
|||||||
Reference in New Issue
Block a user