Skip to content

Commit

Permalink
refactor: early return
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigobasilio2022 committed Jan 30, 2024
1 parent 14ae557 commit ef07f27
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/Widgets/Manipulators/LineManipulator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ export function projectDisplayToLine(
renderer,
glRenderWindow
) {
const near = glRenderWindow.displayToWorld(x, y, 0, renderer);
const far = glRenderWindow.displayToWorld(x, y, 1, renderer);
const viewDir = [0, 0, 0];
vtkMath.subtract(far, near, viewDir);

const normal = [0, 0, 0];
vtkMath.cross(lineDirection, viewDir, normal);
vtkMath.cross(normal, viewDir, normal);
// if the active camera viewPlaneNormal and line direction are parallel, no change is allowed
const dotProduct = Math.abs(
vtkMath.dot(renderer.getActiveCamera().getViewPlaneNormal(), lineDirection)
Expand All @@ -28,6 +20,14 @@ export function projectDisplayToLine(
if (1 - dotProduct < EPSILON) {
return [];
}
const near = glRenderWindow.displayToWorld(x, y, 0, renderer);
const far = glRenderWindow.displayToWorld(x, y, 1, renderer);
const viewDir = [0, 0, 0];
vtkMath.subtract(far, near, viewDir);

const normal = [0, 0, 0];
vtkMath.cross(lineDirection, viewDir, normal);
vtkMath.cross(normal, viewDir, normal);

const numerator = vtkMath.dot(
[near[0] - lineOrigin[0], near[1] - lineOrigin[1], near[2] - lineOrigin[2]],
Expand Down

0 comments on commit ef07f27

Please sign in to comment.