Skip to content

Commit

Permalink
More user friendly errors for --camera-position.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Oct 15, 2024
1 parent 5772688 commit 9edd8f9
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions common/lc_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,18 +614,29 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
{
if ((Options.SetCameraPosition = ParseFloatArray(9, Options.CameraPosition[0], true)))
{
if (Option == QLatin1String("--camera-position-ldraw"))
{
Options.CameraPosition[0] = lcVector3LDrawToLeoCAD(Options.CameraPosition[0]);
Options.CameraPosition[1] = lcVector3LDrawToLeoCAD(Options.CameraPosition[1]);
Options.CameraPosition[2] = lcVector3LDrawToLeoCAD(Options.CameraPosition[2]);
}

lcVector3 Front = Options.CameraPosition[1] - Options.CameraPosition[0];

if (Front.LengthSquared() < 1.0f || Options.CameraPosition[2].LengthSquared() < 1.0f || fabsf(lcDot(lcNormalize(Front), lcNormalize(Options.CameraPosition[2]))) > 0.99f)
if (Front.LengthSquared() < 0.1f)
{
Options.StdErr += tr("Invalid parameter value(s) specified for the '%1' option.\n").arg(Option);
Options.StdErr += tr("The camera position is too close to the camera target of the '%1' option.\n").arg(Option);
Options.ParseOK = false;
}
else if (Option == QLatin1String("--camera-position-ldraw"))
else if (Options.CameraPosition[2].LengthSquared() < 0.1f)
{
Options.CameraPosition[0] = lcVector3LDrawToLeoCAD(Options.CameraPosition[0]);
Options.CameraPosition[1] = lcVector3LDrawToLeoCAD(Options.CameraPosition[1]);
Options.CameraPosition[2] = lcVector3LDrawToLeoCAD(Options.CameraPosition[2]);
Options.StdErr += tr("Invalid up vector length specified for the '%1' option.\n").arg(Option);
Options.ParseOK = false;
}
else if (fabsf(lcDot(lcNormalize(Front), lcNormalize(Options.CameraPosition[2]))) > 0.99f)
{
Options.StdErr += tr("The up vector is parallel to the front vector specified for the '%1' option.\n").arg(Option);
Options.ParseOK = false;
}
}
}
Expand Down

0 comments on commit 9edd8f9

Please sign in to comment.