coin
coin copied to clipboard
Improve auto clipping
While trying to fix an orthographic camera auto clipping problem in FreeCAD, I noticed that during camera motions, for both orthographic and perspective camera, the corners of a part are sometimes cut. See the attached video which is running at 5% the original speed.
https://github.com/coin3d/coin/assets/14298143/f2594dd8-e7a9-4223-9957-d32b4201d308
I think what happens is this: first the camera orientation and/or position is changed, then the scene is rendered, then the auto clipping runs. After the camera moved, the scene may no longer be completely in the viewing frustum. So there is maybe one frame that shows the cut corner before the auto clipping runs and renders the scene again. But if the camera is in motion then there are multiple consecutive frames and the cut corners are noticeable.
To fix this, I created 2 commits. The first commit runs the auto clipping before rendering the scene and this fixes the cut corner problem. Then I thought: if the auto clipping runs before rendering then it is no longer needed to use a clip sensor. So I removed the clip sensor and related methods in the second commit. I am not sure if I can just do that without breaking something for someone. Please let me know what you think :smiley: