Added support for different connection types.
This commit is contained in:
@@ -1808,13 +1808,17 @@ void lcPiecesLibrary::GetParts(std::vector<PieceInfo*>& Parts) const
|
||||
Parts.emplace_back(PartIt.second);
|
||||
}
|
||||
|
||||
std::vector<PieceInfo*> lcPiecesLibrary::GetTrainTrackParts(const lcTrainTrackInfo* TrainTrackInfo) const
|
||||
std::vector<PieceInfo*> lcPiecesLibrary::GetTrainTrackParts(quint32 ConnectionType) const
|
||||
{
|
||||
std::vector<PieceInfo*> Parts;
|
||||
|
||||
for (const auto& [Name, Info] : mPieces)
|
||||
if (Info->GetTrainTrackInfo())
|
||||
{
|
||||
lcTrainTrackInfo* TrainTrackInfo = Info->GetTrainTrackInfo();
|
||||
|
||||
if (TrainTrackInfo && TrainTrackInfo->CanConnectTo(ConnectionType))
|
||||
Parts.emplace_back(Info);
|
||||
}
|
||||
|
||||
return Parts;
|
||||
}
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ public:
|
||||
void GetCategoryEntries(int CategoryIndex, bool GroupPieces, std::vector<PieceInfo*>& SinglePieces, std::vector<PieceInfo*>& GroupedPieces);
|
||||
void GetCategoryEntries(const char* CategoryKeywords, bool GroupPieces, std::vector<PieceInfo*>& SinglePieces, std::vector<PieceInfo*>& GroupedPieces);
|
||||
void GetParts(std::vector<PieceInfo*>& Parts) const;
|
||||
std::vector<PieceInfo*> GetTrainTrackParts(const lcTrainTrackInfo* TrainTrackInfo) const;
|
||||
std::vector<PieceInfo*> GetTrainTrackParts(quint32 ConnectionType) const;
|
||||
|
||||
std::vector<PieceInfo*> GetPartsFromSet(const std::vector<std::string>& PartIds) const;
|
||||
std::string GetPartId(const PieceInfo* Info) const;
|
||||
|
||||
@@ -4436,7 +4436,6 @@ void lcModel::InsertPieceToolClicked(PieceInfo* Info, const lcMatrix44& WorldMat
|
||||
Piece->UpdatePosition(mCurrentStep);
|
||||
AddPiece(Piece);
|
||||
|
||||
|
||||
gMainWindow->UpdateTimeline(false, false);
|
||||
ClearSelectionAndSetFocus(Piece, LC_PIECE_SECTION_POSITION, false);
|
||||
|
||||
|
||||
+14
-16
@@ -7,8 +7,6 @@
|
||||
|
||||
// todo:
|
||||
// auto replace cross when going over a straight section
|
||||
// redo gizmo
|
||||
// add cross to gizmo
|
||||
// move config to json
|
||||
// add other track types
|
||||
// set focus connection after adding
|
||||
@@ -21,8 +19,8 @@ void lcTrainTrackInit(lcPiecesLibrary* Library)
|
||||
{
|
||||
lcTrainTrackInfo* TrainTrackInfo = new lcTrainTrackInfo();
|
||||
|
||||
TrainTrackInfo->AddConnection({lcMatrix44Translation(lcVector3(160.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-160.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection(lcMatrix44Translation(lcVector3(160.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-160.0f, 0.0f, 0.0f)), 0);
|
||||
|
||||
Info->SetTrainTrackInfo(TrainTrackInfo);
|
||||
}
|
||||
@@ -36,8 +34,8 @@ void lcTrainTrackInit(lcPiecesLibrary* Library)
|
||||
const float CurveX = sinf(LC_DTOR * 11.25f) * 800.0f;
|
||||
const float CurveY = (cosf(LC_DTOR * 11.25f) * 800.0f) - 800.0f;
|
||||
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(-11.25f * LC_DTOR), lcVector3(CurveX, CurveY, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(-168.75f * LC_DTOR), lcVector3(-CurveX, CurveY, 0.0f))});
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(-11.25f * LC_DTOR), lcVector3(CurveX, CurveY, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(-168.75f * LC_DTOR), lcVector3(-CurveX, CurveY, 0.0f)), 0);
|
||||
|
||||
Info->SetTrainTrackInfo(TrainTrackInfo);
|
||||
}
|
||||
@@ -51,9 +49,9 @@ void lcTrainTrackInit(lcPiecesLibrary* Library)
|
||||
{
|
||||
lcTrainTrackInfo* TrainTrackInfo = new lcTrainTrackInfo();
|
||||
|
||||
TrainTrackInfo->AddConnection({lcMatrix44Translation(lcVector3(320.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-320.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(22.5f * LC_DTOR), lcVector3(BranchX, BranchY, 0.0f))});
|
||||
TrainTrackInfo->AddConnection(lcMatrix44Translation(lcVector3(320.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-320.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(22.5f * LC_DTOR), lcVector3(BranchX, BranchY, 0.0f)), 0);
|
||||
|
||||
Info->SetTrainTrackInfo(TrainTrackInfo);
|
||||
}
|
||||
@@ -64,9 +62,9 @@ void lcTrainTrackInit(lcPiecesLibrary* Library)
|
||||
{
|
||||
lcTrainTrackInfo* TrainTrackInfo = new lcTrainTrackInfo();
|
||||
|
||||
TrainTrackInfo->AddConnection({lcMatrix44Translation(lcVector3(320.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-320.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(-22.5f * LC_DTOR), lcVector3(BranchX, -BranchY, 0.0f))});
|
||||
TrainTrackInfo->AddConnection(lcMatrix44Translation(lcVector3(320.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-320.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(-22.5f * LC_DTOR), lcVector3(BranchX, -BranchY, 0.0f)), 0);
|
||||
|
||||
Info->SetTrainTrackInfo(TrainTrackInfo);
|
||||
}
|
||||
@@ -77,10 +75,10 @@ void lcTrainTrackInit(lcPiecesLibrary* Library)
|
||||
{
|
||||
lcTrainTrackInfo* TrainTrackInfo = new lcTrainTrackInfo();
|
||||
|
||||
TrainTrackInfo->AddConnection({lcMatrix44Translation(lcVector3(160.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(LC_PI / 2.0f), lcVector3(0.0f, 160.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-160.0f, 0.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection({lcMatrix44(lcMatrix33RotationZ(-LC_PI / 2.0f), lcVector3(0.0f, -160.0f, 0.0f))});
|
||||
TrainTrackInfo->AddConnection(lcMatrix44Translation(lcVector3(160.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(LC_PI / 2.0f), lcVector3(0.0f, 160.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(LC_PI), lcVector3(-160.0f, 0.0f, 0.0f)), 0);
|
||||
TrainTrackInfo->AddConnection(lcMatrix44(lcMatrix33RotationZ(-LC_PI / 2.0f), lcVector3(0.0f, -160.0f, 0.0f)), 0);
|
||||
|
||||
Info->SetTrainTrackInfo(TrainTrackInfo);
|
||||
}
|
||||
|
||||
+12
-2
@@ -8,6 +8,7 @@ class lcPiecesLibrary;
|
||||
struct lcTrainTrackConnection
|
||||
{
|
||||
lcMatrix44 Transform;
|
||||
quint32 Type;
|
||||
};
|
||||
|
||||
enum class lcTrainTrackType
|
||||
@@ -30,9 +31,9 @@ public:
|
||||
static std::optional<lcMatrix44> CalculateTransformToConnection(const lcMatrix44& ConnectionTransform, PieceInfo* Info, quint32 ConnectionIndex);
|
||||
static int GetPieceConnectionIndex(const lcPiece* Piece1, int ConnectionIndex1, const lcPiece* Piece2);
|
||||
|
||||
void AddConnection(const lcTrainTrackConnection& TrainTrackConnection)
|
||||
void AddConnection(const lcMatrix44 &Transform, quint32 Type)
|
||||
{
|
||||
mConnections.emplace_back(TrainTrackConnection);
|
||||
mConnections.emplace_back(lcTrainTrackConnection{Transform, Type});
|
||||
}
|
||||
|
||||
const std::vector<lcTrainTrackConnection>& GetConnections() const
|
||||
@@ -40,6 +41,15 @@ public:
|
||||
return mConnections;
|
||||
}
|
||||
|
||||
bool CanConnectTo(quint32 ConnectionType) const
|
||||
{
|
||||
for (const lcTrainTrackConnection& Connection : mConnections)
|
||||
if (Connection.Type == ConnectionType)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<lcTrainTrackConnection> mConnections;
|
||||
};
|
||||
|
||||
+7
-1
@@ -322,7 +322,13 @@ void lcView::ShowTrainTrackPopup()
|
||||
if (!TrainTrackInfo)
|
||||
return;
|
||||
|
||||
PieceInfo* Info = lcShowTrainTrackPopup(mWidget, TrainTrackInfo);
|
||||
if (mTrackToolSection < LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST)
|
||||
return;
|
||||
|
||||
int ConnectionIndex = mTrackToolSection - LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST;
|
||||
quint32 ConnectionType = TrainTrackInfo->GetConnections()[ConnectionIndex].Type;
|
||||
|
||||
PieceInfo* Info = lcShowTrainTrackPopup(mWidget, ConnectionType);
|
||||
|
||||
if (Info)
|
||||
{
|
||||
|
||||
+4
-4
@@ -229,7 +229,7 @@ void lcPieceIdPickerPopup::Close()
|
||||
Menu->close();
|
||||
}
|
||||
|
||||
lcTrainTrackPickerPopup::lcTrainTrackPickerPopup(QWidget* Parent, const lcTrainTrackInfo* TrainTrackInfo)
|
||||
lcTrainTrackPickerPopup::lcTrainTrackPickerPopup(QWidget* Parent, quint32 ConnectionType)
|
||||
: QWidget(Parent)
|
||||
{
|
||||
QVBoxLayout* Layout = new QVBoxLayout(this);
|
||||
@@ -240,7 +240,7 @@ lcTrainTrackPickerPopup::lcTrainTrackPickerPopup(QWidget* Parent, const lcTrainT
|
||||
mPartSelectionListView->setMinimumWidth(450);
|
||||
mPartSelectionListView->setDragEnabled(false);
|
||||
|
||||
std::vector<PieceInfo*> Parts = lcGetPiecesLibrary()->GetTrainTrackParts(TrainTrackInfo);
|
||||
std::vector<PieceInfo*> Parts = lcGetPiecesLibrary()->GetTrainTrackParts(ConnectionType);
|
||||
|
||||
mPartSelectionListView->SetCustomParts(Parts);
|
||||
|
||||
@@ -280,11 +280,11 @@ void lcTrainTrackPickerPopup::Close()
|
||||
Menu->close();
|
||||
}
|
||||
|
||||
PieceInfo* lcShowTrainTrackPopup(QWidget* Parent, const lcTrainTrackInfo* TrainTrackInfo)
|
||||
PieceInfo* lcShowTrainTrackPopup(QWidget* Parent, quint32 ConnectionType)
|
||||
{
|
||||
std::unique_ptr<QMenu> Menu(new QMenu(Parent));
|
||||
QWidgetAction* Action = new QWidgetAction(Menu.get());
|
||||
lcTrainTrackPickerPopup* Popup = new lcTrainTrackPickerPopup(Menu.get(), TrainTrackInfo);
|
||||
lcTrainTrackPickerPopup* Popup = new lcTrainTrackPickerPopup(Menu.get(), ConnectionType);
|
||||
|
||||
Action->setDefaultWidget(Popup);
|
||||
Menu->addAction(Action);
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@
|
||||
|
||||
class lcPartSelectionWidget;
|
||||
class lcPartSelectionListView;
|
||||
class lcTrainTrackInfo;
|
||||
|
||||
QString lcFormatValue(float Value, int Precision);
|
||||
QString lcFormatValueLocalized(float Value);
|
||||
@@ -197,7 +196,7 @@ class lcTrainTrackPickerPopup : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lcTrainTrackPickerPopup(QWidget* Parent, const lcTrainTrackInfo* TrainTrackInfo);
|
||||
lcTrainTrackPickerPopup(QWidget* Parent, quint32 ConnectionType);
|
||||
|
||||
PieceInfo* GetPickedTrainTrack() const
|
||||
{
|
||||
@@ -216,7 +215,7 @@ protected:
|
||||
PieceInfo* mPickedTrainTrack = nullptr;
|
||||
};
|
||||
|
||||
PieceInfo* lcShowTrainTrackPopup(QWidget* Parent, const lcTrainTrackInfo* TrainTrackInfo);
|
||||
PieceInfo* lcShowTrainTrackPopup(QWidget* Parent, quint32 ConnectionType);
|
||||
|
||||
class lcColorDialogPopup : public QWidget
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user