Windows bug fix: Variable array length

This commit is contained in:
cambrialas 2024-12-05 14:28:03 +01:00
parent 49f74696b5
commit fbbd275c62
3 changed files with 14 additions and 12 deletions

View file

@ -5,7 +5,6 @@
#include "piece.h" #include "piece.h"
#include "lc_application.h" #include "lc_application.h"
#include <iostream>
// todo: // todo:
// auto replace cross when going over a straight section // auto replace cross when going over a straight section
// redo gizmo // redo gizmo

View file

@ -28,7 +28,7 @@ public:
return relatedPieces[index]; return relatedPieces[index];
} }
int Size() size_t Size()
{ {
return relatedPieces.size(); return relatedPieces.size();
} }

View file

@ -384,9 +384,10 @@ void lcViewManipulator::DrawTrainTrack(lcPiece* Piece, lcContext* Context, float
lcRelatedPiecesGroup* releatedPieces = Connections[ConnectionIndex].relatedPiecesGroup; lcRelatedPiecesGroup* releatedPieces = Connections[ConnectionIndex].relatedPiecesGroup;
int noOfPieces = releatedPieces->Size(); int noOfPieces = releatedPieces->Size();
lcVector3 Verts[noOfPieces * 2]; int NumVerts = noOfPieces * 2;
int NumVerts = 0; std::vector<lcVector3> Verts;
Verts.resize(NumVerts);
int degreeStep = 0; int degreeStep = 0;
@ -394,14 +395,15 @@ void lcViewManipulator::DrawTrainTrack(lcPiece* Piece, lcContext* Context, float
degreeStep = 120 / (noOfPieces - 1); degreeStep = 120 / (noOfPieces - 1);
} }
int VertsIdx = 0;
for(int pieceNo = 0; pieceNo < noOfPieces; pieceNo++) { for(int pieceNo = 0; pieceNo < noOfPieces; pieceNo++) {
Verts[NumVerts++] = Transform.GetTranslation() / OverlayScale; Verts[VertsIdx++] = Transform.GetTranslation() / OverlayScale;
Verts[NumVerts++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * (-60 + (degreeStep * pieceNo) ))) * 100) / OverlayScale; Verts[VertsIdx++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * (-60 + (degreeStep * pieceNo) ))) * 100) / OverlayScale;
} }
Context->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Context->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
Context->SetVertexBufferPointer(Verts); Context->SetVertexBufferPointer(Verts.data());
Context->ClearIndexBuffer(); Context->ClearIndexBuffer();
Context->SetVertexFormatPosition(3); Context->SetVertexFormatPosition(3);
@ -978,11 +980,12 @@ std::pair<lcTrackTool, quint32> lcViewManipulator::UpdateSelectMove()
const lcMatrix44& Transform = Connections[ConnectionIndex].Transform; const lcMatrix44& Transform = Connections[ConnectionIndex].Transform;
lcRelatedPiecesGroup* releatedPieces = Connections[ConnectionIndex].relatedPiecesGroup; lcRelatedPiecesGroup* releatedPieces = Connections[ConnectionIndex].relatedPiecesGroup;
int noOfPieces = releatedPieces->Size(); int noOfPieces = releatedPieces->Size();
int NumVerts = noOfPieces;
lcVector3 Verts[noOfPieces]; std::vector<lcVector3> Verts;
Verts.resize(NumVerts);
int NumVerts = 0;
int degreeStep = 0; int degreeStep = 0;
@ -990,8 +993,8 @@ std::pair<lcTrackTool, quint32> lcViewManipulator::UpdateSelectMove()
degreeStep = 120 / (noOfPieces - 1); degreeStep = 120 / (noOfPieces - 1);
} }
for(int pieceNo = 0; pieceNo < noOfPieces; pieceNo++) { for(int VertexIndex = 0; VertexIndex < noOfPieces; VertexIndex++) {
Verts[NumVerts++] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * (-60 + (degreeStep * pieceNo) ))) * 100) / 1; Verts[VertexIndex] = (Transform.GetTranslation() + lcMul31(lcVector3(Transform[0]), lcMatrix44RotationZ(LC_DTOR * (-60 + (degreeStep * VertexIndex) ))) * 100) / 1;
} }
for (int VertexIndex = 0; VertexIndex < NumVerts; VertexIndex++) for (int VertexIndex = 0; VertexIndex < NumVerts; VertexIndex++)