Commit e01e219c authored by Mathieu Malaterre's avatar Mathieu Malaterre

FIX: There were degenerate cases where the view up was aligned with Rz

parent 7337f37a
......@@ -26,7 +26,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkFollower, "1.44");
vtkCxxRevisionMacro(vtkFollower, "1.45");
vtkStandardNewMacro(vtkFollower);
vtkCxxSetObjectMacro(vtkFollower,Camera,vtkCamera);
......@@ -107,10 +107,22 @@ void vtkFollower::GetMatrix(vtkMatrix4x4 *result)
}
}
vtkMath::Cross(vup,Rz,Rx);
vtkMath::Normalize(Rx);
vtkMath::Cross(Rz,Rx,Ry);
// We cannot directly use the vup angle since it can be aligned with Rz:
//vtkMath::Cross(vup,Rz,Rx);
//vtkMath::Normalize(Rx);
//vtkMath::Cross(Rz,Rx,Ry);
//instead use the view right angle:
double dop[3], vur[3];
this->Camera->GetDirectionOfProjection(dop);
vtkMath::Cross(dop,vup,vur);
vtkMath::Normalize(vur);
vtkMath::Cross(Rz, vur, Ry);
vtkMath::Normalize(Ry);
vtkMath::Cross(Ry,Rz,Rx);
matrix->Element[0][0] = Rx[0];
matrix->Element[1][0] = Rx[1];
matrix->Element[2][0] = Rx[2];
......@@ -120,10 +132,10 @@ void vtkFollower::GetMatrix(vtkMatrix4x4 *result)
matrix->Element[0][2] = Rz[0];
matrix->Element[1][2] = Rz[1];
matrix->Element[2][2] = Rz[2];
this->Transform->Concatenate(matrix);
}
// translate to projection reference point PRP
// this is the camera's position blasted through
// the current matrix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment