Merge pull request #44 from j6t/master

Fortify against random control points in imported files.
This commit is contained in:
Leonardo Zide 2017-04-16 19:03:19 -07:00 committed by GitHub
commit 16bf9c7502
2 changed files with 7 additions and 3 deletions

View file

@ -761,7 +761,11 @@ lcuint32 lcPiece::GetAllowedTransforms() const
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
return LC_OBJECT_TRANSFORM_MOVE_X | LC_OBJECT_TRANSFORM_MOVE_Y | LC_OBJECT_TRANSFORM_MOVE_Z | LC_OBJECT_TRANSFORM_ROTATE_X | LC_OBJECT_TRANSFORM_ROTATE_Y | LC_OBJECT_TRANSFORM_ROTATE_Z;
if (mPieceInfo->GetSynthInfo()->IsCurve())
lcSynthInfo* SynthInfo = mPieceInfo->GetSynthInfo();
if (!SynthInfo)
return 0;
if (SynthInfo->IsCurve())
return LC_OBJECT_TRANSFORM_MOVE_X | LC_OBJECT_TRANSFORM_MOVE_Y | LC_OBJECT_TRANSFORM_MOVE_Z | LC_OBJECT_TRANSFORM_ROTATE_X | LC_OBJECT_TRANSFORM_ROTATE_Y | LC_OBJECT_TRANSFORM_ROTATE_Z | LC_OBJECT_TRANSFORM_SCALE_X;
else
return LC_OBJECT_TRANSFORM_MOVE_Z;

View file

@ -745,7 +745,7 @@ void View::DrawSelectMoveOverlay()
lcPiece* Piece = (lcPiece*)Focus;
lcuint32 Section = Piece->GetFocusSection();
if (Section >= LC_PIECE_SECTION_CONTROL_POINT_1 && Section <= LC_PIECE_SECTION_CONTROL_POINT_8 && Piece->mPieceInfo->GetSynthInfo()->IsCurve())
if (Section >= LC_PIECE_SECTION_CONTROL_POINT_1 && Section <= LC_PIECE_SECTION_CONTROL_POINT_8 && Piece->mPieceInfo->GetSynthInfo() && Piece->mPieceInfo->GetSynthInfo()->IsCurve())
{
int ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_1;
float Strength = Piece->GetControlPoints()[ControlPointIndex].Scale;
@ -1796,7 +1796,7 @@ void View::UpdateTrackTool()
lcPiece* Piece = (lcPiece*)Focus;
if (ControlPointIndex != -1 && Piece->mPieceInfo->GetSynthInfo()->IsCurve())
if (ControlPointIndex != -1 && Piece->mPieceInfo->GetSynthInfo() && Piece->mPieceInfo->GetSynthInfo()->IsCurve())
{
float Strength = Piece->GetControlPoints()[ControlPointIndex].Scale;
const float ScaleStart = (2.0f - OverlayScaleRadius) * OverlayScale + Strength;