f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Bug with collinear `--up` and `--camera-direction`

Open snoyer opened this issue 9 months ago • 3 comments

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:

  1. Open a file with --up and --camera-direction set to collinear values, for example:
  • f3d testing/data/dragon.vtu --up=0,1,0 --camera-direction=0,2,0
  • f3d testing/data/dragon.vtu --up=z --camera-direction=-z
  1. 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

snoyer avatar Mar 06 '25 07:03 snoyer

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.

19jrushlow avatar May 24 '25 22:05 19jrushlow

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?

skusel avatar Jun 11 '25 00:06 skusel

That sounds fine indeed:)

mwestphal avatar Jun 11 '25 03:06 mwestphal