Incorrect transformed bounds calculation
I'm upfront sorry for long text, but I tried to not only report issue but also show it's effects as I spent some time digging through this.
Problem:
The SetGeometryBounds
(click) calculates the transformed bounds incorrectly. It is not enough to take extreme points of bounding box as these may no longer be extremes after the transform is applied.
Solution:
All 8 corners of bounding box should be transformed to build new (transformed) bouding box.
More details:
It's easy to illustrate this. We start with axis aligned bounding box:
And we apply rotation along Z axis in MinPt:
The original extreme points now both lie in XZ plane and thus Y coordinate is 0 for both. If we reconstruct bounding box from these as is done in the linked function, the bounding box will be just flat rectangle.
As clipping planes for render view are determined using these bounds, it should result in clipped geometry.
Let's try an experiment:
- Create
Box
source - Set all it's dimensions (lenths to 2)
- With advanced view on, set transform matrix on representation as below:
- We are increasing scale so that bounding box of the real data doesn't somehow contribute bounding box that would hide the problem.
- We are rotating to reproduce problem description above (it's not enough to transform extremes)
I was puzzled at this point, but found explanation:
- If the rendering happens locally, we take different path - in
vtkPVRenderViewSynchronizeGeometryBounds
(click) we callthis->GetRenderer()->ComputeVisiblePropBounds(prop_bounds)
. This boils down to (for example) tovtkPVLODActor::GetBounds()
(click) which uses correct algorithm of taking all corners, transforming them all and building new bounding box from these. - However, in remote rendering we follow this code path (click) which retrieves the incorrectly computed bounds and we get this: