mirror of
https://github.com/leozide/leocad
synced 2024-12-25 21:58:23 +01:00
Fixed train track gizmo drawing when a rotated connection has focus.
This commit is contained in:
parent
ff23653709
commit
24b7c43a09
3 changed files with 107 additions and 57 deletions
|
@ -379,24 +379,37 @@ void lcViewManipulator::DrawTrainTrack(lcPiece* Piece, lcContext* Context, float
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const lcMatrix44& Transform = Connections[ConnectionIndex].Transform;
|
const lcMatrix44& Transform = Connections[ConnectionIndex].Transform;
|
||||||
|
lcVector3 Start = Transform.GetTranslation();
|
||||||
|
lcVector3 Direction = lcVector3(Transform[0]) * 100;
|
||||||
|
|
||||||
|
if (Piece->GetFocusSection() >= LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST)
|
||||||
|
{
|
||||||
|
quint32 FocusIndex = Piece->GetFocusSection() - LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST;
|
||||||
|
|
||||||
|
if (FocusIndex != ConnectionIndex)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Start = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
|
Direction = lcVector3(100.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
lcVector3 Verts[static_cast<int>(lcTrainTrackType::Count) * 2];
|
lcVector3 Verts[static_cast<int>(lcTrainTrackType::Count) * 2];
|
||||||
int NumVerts = 0;
|
int NumVerts = 0;
|
||||||
|
|
||||||
Verts[NumVerts++] = Transform.GetTranslation() / OverlayScale;
|
Verts[NumVerts++] = Start / OverlayScale;
|
||||||
Verts[NumVerts++] = (Transform.GetTranslation() + lcVector3(Transform[0]) * 100) / OverlayScale;
|
Verts[NumVerts++] = (Start + Direction) / OverlayScale;
|
||||||
|
|
||||||
Verts[NumVerts++] = Transform.GetTranslation() / OverlayScale;
|
Verts[NumVerts++] = Verts[0];
|
||||||
Verts[NumVerts++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * 60)) * 100) / OverlayScale;
|
Verts[NumVerts++] = (Start + lcMul31(Direction, lcMatrix44RotationZ(LC_DTOR * 60))) / OverlayScale;
|
||||||
|
|
||||||
Verts[NumVerts++] = Transform.GetTranslation() / OverlayScale;
|
Verts[NumVerts++] = Verts[0];
|
||||||
Verts[NumVerts++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * -60)) * 100) / OverlayScale;
|
Verts[NumVerts++] = (Start + lcMul31(Direction, lcMatrix44RotationZ(LC_DTOR * -60))) / OverlayScale;
|
||||||
|
|
||||||
Verts[NumVerts++] = Transform.GetTranslation() / OverlayScale;
|
Verts[NumVerts++] = Verts[0];
|
||||||
Verts[NumVerts++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * 30)) * 100) / OverlayScale;
|
Verts[NumVerts++] = (Start + lcMul31(Direction, lcMatrix44RotationZ(LC_DTOR * 30))) / OverlayScale;
|
||||||
|
|
||||||
Verts[NumVerts++] = Transform.GetTranslation() / OverlayScale;
|
Verts[NumVerts++] = Verts[0];
|
||||||
Verts[NumVerts++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * -30)) * 100) / OverlayScale;
|
Verts[NumVerts++] = (Start + lcMul31(Direction, lcMatrix44RotationZ(LC_DTOR * -30))) / OverlayScale;
|
||||||
|
|
||||||
Context->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
Context->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -1268,6 +1268,88 @@ lcVector3 lcPiece::GetSectionPosition(quint32 Section) const
|
||||||
return lcVector3(0.0f, 0.0f, 0.0f);
|
return lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lcVector3 lcPiece::GetRotationCenter() const
|
||||||
|
{
|
||||||
|
const quint32 Section = GetFocusSection();
|
||||||
|
|
||||||
|
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
|
||||||
|
{
|
||||||
|
if (mPivotPointValid)
|
||||||
|
return lcMul31(mPivotMatrix.GetTranslation(), mModelWorld);
|
||||||
|
}
|
||||||
|
else if (mPieceInfo->GetSynthInfo())
|
||||||
|
{
|
||||||
|
if (Section >= LC_PIECE_SECTION_CONTROL_POINT_FIRST)
|
||||||
|
{
|
||||||
|
const quint32 ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_FIRST;
|
||||||
|
|
||||||
|
if (ControlPointIndex < mControlPoints.size())
|
||||||
|
{
|
||||||
|
const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform;
|
||||||
|
return lcMul31(Transform.GetTranslation(), mModelWorld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mPieceInfo->GetTrainTrackInfo())
|
||||||
|
{
|
||||||
|
if (Section >= LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST)
|
||||||
|
{
|
||||||
|
const quint32 ConnectionIndex = Section - LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST;
|
||||||
|
const std::vector<lcTrainTrackConnection>& Connections = mPieceInfo->GetTrainTrackInfo()->GetConnections();
|
||||||
|
|
||||||
|
if (ConnectionIndex < Connections.size())
|
||||||
|
{
|
||||||
|
const lcMatrix44& Transform = Connections[ConnectionIndex].Transform;
|
||||||
|
return lcMul(Transform, mModelWorld).GetTranslation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mModelWorld.GetTranslation();
|
||||||
|
}
|
||||||
|
|
||||||
|
lcMatrix33 lcPiece::GetRelativeRotation() const
|
||||||
|
{
|
||||||
|
const quint32 Section = GetFocusSection();
|
||||||
|
|
||||||
|
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
|
||||||
|
{
|
||||||
|
if (mPivotPointValid)
|
||||||
|
return lcMatrix33(lcMul(mModelWorld, mPivotMatrix));
|
||||||
|
else
|
||||||
|
return lcMatrix33(mModelWorld);
|
||||||
|
}
|
||||||
|
else if (mPieceInfo->GetSynthInfo())
|
||||||
|
{
|
||||||
|
if (Section >= LC_PIECE_SECTION_CONTROL_POINT_FIRST)
|
||||||
|
{
|
||||||
|
const quint32 ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_FIRST;
|
||||||
|
|
||||||
|
if (ControlPointIndex < mControlPoints.size())
|
||||||
|
{
|
||||||
|
const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform;
|
||||||
|
return lcMatrix33(lcMul(Transform, mModelWorld));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mPieceInfo->GetTrainTrackInfo())
|
||||||
|
{
|
||||||
|
if (Section >= LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST)
|
||||||
|
{
|
||||||
|
const quint32 ConnectionIndex = Section - LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST;
|
||||||
|
const std::vector<lcTrainTrackConnection>& Connections = mPieceInfo->GetTrainTrackInfo()->GetConnections();
|
||||||
|
|
||||||
|
if (ConnectionIndex < Connections.size())
|
||||||
|
{
|
||||||
|
const lcMatrix44& Transform = Connections[ConnectionIndex].Transform;
|
||||||
|
return lcMatrix33(lcMul(Transform, mModelWorld));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lcMatrix33Identity();
|
||||||
|
}
|
||||||
|
|
||||||
bool lcPiece::CanAddControlPoint() const
|
bool lcPiece::CanAddControlPoint() const
|
||||||
{
|
{
|
||||||
if (mControlPoints.size() >= LC_MAX_CONTROL_POINTS)
|
if (mControlPoints.size() >= LC_MAX_CONTROL_POINTS)
|
||||||
|
|
|
@ -283,53 +283,8 @@ public:
|
||||||
mRotation.ChangeKey(Rotation, Step, AddKey);
|
mRotation.ChangeKey(Rotation, Step, AddKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcVector3 GetRotationCenter() const
|
lcVector3 GetRotationCenter() const;
|
||||||
{
|
lcMatrix33 GetRelativeRotation() const;
|
||||||
const quint32 Section = GetFocusSection();
|
|
||||||
|
|
||||||
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
|
|
||||||
{
|
|
||||||
if (mPivotPointValid)
|
|
||||||
return lcMul31(mPivotMatrix.GetTranslation(), mModelWorld);
|
|
||||||
}
|
|
||||||
else if (Section >= LC_PIECE_SECTION_CONTROL_POINT_FIRST)
|
|
||||||
{
|
|
||||||
const quint32 ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_FIRST;
|
|
||||||
|
|
||||||
if (ControlPointIndex < mControlPoints.size())
|
|
||||||
{
|
|
||||||
const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform;
|
|
||||||
return lcMul31(Transform.GetTranslation(), mModelWorld);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mModelWorld.GetTranslation();
|
|
||||||
}
|
|
||||||
|
|
||||||
lcMatrix33 GetRelativeRotation() const
|
|
||||||
{
|
|
||||||
const quint32 Section = GetFocusSection();
|
|
||||||
|
|
||||||
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
|
|
||||||
{
|
|
||||||
if (mPivotPointValid)
|
|
||||||
return lcMatrix33(lcMul(mModelWorld, mPivotMatrix));
|
|
||||||
else
|
|
||||||
return lcMatrix33(mModelWorld);
|
|
||||||
}
|
|
||||||
else if (Section >= LC_PIECE_SECTION_CONTROL_POINT_FIRST)
|
|
||||||
{
|
|
||||||
const quint32 ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_FIRST;
|
|
||||||
|
|
||||||
if (ControlPointIndex < mControlPoints.size())
|
|
||||||
{
|
|
||||||
const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform;
|
|
||||||
return lcMatrix33(lcMul(Transform, mModelWorld));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lcMatrix33Identity();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetPivotPoint()
|
void ResetPivotPoint()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue