Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Jul 27, 2024
1 parent 14f1c44 commit c5fa405
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,8 @@ private RayCastFace rayCastFace(Direction direction, Vector3d origin, Vector3d d
Vector3d v2 = box.getPoint(vertexIndices.z());
Vector3d v3 = box.getPoint(vertexIndices.w());
double v = Math.max(
Intersectiond.intersectRayTriangleFront(
origin.x(), origin.y(), origin.z(),
dir.x(), dir.y(), dir.z(),
v0.x(), v0.y(), v0.z(),
v1.x(), v1.y(), v1.z(),
v2.x(), v2.y(), v2.z(),
epsilon
),
Intersectiond.intersectRayTriangleFront(
origin.x(), origin.y(), origin.z(),
dir.x(), dir.y(), dir.z(),
v2.x(), v2.y(), v2.z(),
v3.x(), v3.y(), v3.z(),
v0.x(), v0.y(), v0.z(),
epsilon
)
Intersectiond.intersectRayTriangleFront(origin, dir, v0, v1, v2, epsilon),
Intersectiond.intersectRayTriangleFront(origin, dir, v2, v3, v0, epsilon)
);
if (v == -1.0) {
return RayCastFace.MISSED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* License as published by the Free Software Foundation;
* only version 2.1 of the License.
*/

package freeworld.math;
Expand Down Expand Up @@ -95,4 +95,19 @@ public static double intersectRayTriangleFront(
double invDet = 1.0 / det;
return (edge2X * qvecX + edge2Y * qvecY + edge2Z * qvecZ) * invDet;
}

public static double intersectRayTriangleFront(
Vector3d origin, Vector3d dir,
Vector3d v0, Vector3d v1, Vector3d v2,
double epsilon
) {
return intersectRayTriangleFront(
origin.x(), origin.y(), origin.z(),
dir.x(), dir.y(), dir.z(),
v0.x(), v0.y(), v0.z(),
v1.x(), v1.y(), v1.z(),
v2.x(), v2.y(), v2.z(),
epsilon
);
}
}

0 comments on commit c5fa405

Please sign in to comment.