Bug with collinear `--up` and `--camera-direction`
Describe the bug
The initial camera setup doesn't work when --up and --camera-direction values are collinear.
To Reproduce Steps to reproduce the behavior:
- Open a file with
--upand--camera-directionset to collinear values, for example:
f3d testing/data/dragon.vtu --up=0,1,0 --camera-direction=0,2,0f3d testing/data/dragon.vtu --up=z --camera-direction=-z
- model isn't shown, or maybe the camera is inside of the model?
F3D Information
Happens on current master but already present in 3.0
Additional context
Offsetting the directions ever so slightly avoids the problem (eg.--up=0,1,0 --camera-direction=0,1,0.000000001) so it's probably just a matter of adding a check to avoid exact collinearity
I noticed when I press 7 to set the camera to top view, the model displays until I click and drag to change the perspective. This is probably related.
I'd be interested in working on this if that's ok.
This problem seems to occur whenever cam->OrthongonalizeViewUp() transforms the up vector into a zero vector.
I could check if cam->OrthongonalizeViewUp() transforms the up vector into a zero vector whenever it is called in /src/library/src/camera_impl.cxx. If it does, I could add 128 * std::numeric_limits<double> to each value in the original up vector until cam->OrthongonalizeViewUp() does not produce the zero vector, which would take at most 3 iterations. Do you think this is a fair approach?
That sounds fine indeed:)