Skip to content

Commit

Permalink
Refactors code to make it more readeable and efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
kidharb committed Mar 12, 2024
1 parent 7dec4a7 commit fd67399
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions library/VTKExtensions/Rendering/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1358,16 +1358,12 @@ void vtkF3DRenderer::SetUseOrthographicProjection(bool use)

if (use)
{
this->UseOrthographicProjection = use;

const double distance = std::sqrt(vtkMath::Distance2BetweenPoints(position, focal));
const double parallelScale = distance * tan(angle / 2);
camera->SetParallelScale(parallelScale);
}
else
{
this->UseOrthographicProjection = !use;

const double distance = camera->GetParallelScale() / tan(angle / 2);
double direction[3];
vtkMath::Subtract(position, focal, direction);
Expand All @@ -1377,6 +1373,7 @@ void vtkF3DRenderer::SetUseOrthographicProjection(bool use)
vtkMath::Add(focal, direction, newPosition);
camera->SetPosition(newPosition);
}
this->UseOrthographicProjection = use;
camera->SetParallelProjection(use);
this->ResetCameraClippingRange();
}
Expand Down

0 comments on commit fd67399

Please sign in to comment.