Skip to content

Commit

Permalink
Used in to reduce struct copying in EarClipping.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Jan 5, 2025
1 parent 2ec3461 commit 8b5ea63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions FinModelUtility/Formats/Vrml/Vrml/src/util/EarClipping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ private bool IsConvex_(ConnectionEdge curPoint) {
return orientation == 1;
}

private bool IsPointInTriangle_(Vector3 prevPoint,
Vector3 curPoint,
Vector3 nextPoint,
private bool IsPointInTriangle_(in Vector3 prevPoint,
in Vector3 curPoint,
in Vector3 nextPoint,
List<ConnectionEdge> nonConvexPoints) {
foreach (var nonConvexPoint in nonConvexPoints) {
if (nonConvexPoint.Origin.Equals(prevPoint) ||
Expand Down
19 changes: 9 additions & 10 deletions FinModelUtility/Formats/Vrml/Vrml/src/util/Misc.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System.Numerics;

using fin.math.floats;
using fin.math.matrix.three;

namespace vrml.util;

class Misc {
public static int GetOrientation(Vector3 v0,
Vector3 v1,
Vector3 v2,
Vector3 normal) {
public static int GetOrientation(in Vector3 v0,
in Vector3 v1,
in Vector3 v2,
in Vector3 normal) {
var res = Vector3.Cross(v0 - v1, v2 - v1);
if (res.Length().IsRoughly0()) {
return 0;
Expand All @@ -22,11 +21,11 @@ public static int GetOrientation(Vector3 v0,
return -1;
}

public static bool PointInOrOnTriangle(Vector3 prevPoint,
Vector3 curPoint,
Vector3 nextPoint,
Vector3 nonConvexPoint,
Vector3 normal) {
public static bool PointInOrOnTriangle(in Vector3 prevPoint,
in Vector3 curPoint,
in Vector3 nextPoint,
in Vector3 nonConvexPoint,
in Vector3 normal) {
var res0 = Misc.GetOrientation(prevPoint, nonConvexPoint, curPoint, normal);
var res1 = Misc.GetOrientation(curPoint, nonConvexPoint, nextPoint, normal);
var res2
Expand Down

0 comments on commit 8b5ea63

Please sign in to comment.