Unstable 1.2.4.0

This commit is contained in:
Markus Isberg
2023-11-30 13:53:00 +02:00
parent 8a2e2ea0ae
commit fb5ea537bf
210 changed files with 4201 additions and 1283 deletions
@@ -0,0 +1,21 @@
using Microsoft.Xna.Framework;
namespace Barotrauma;
readonly record struct Triangle2D(Vector2 A, Vector2 B, Vector2 C)
{
public bool Contains(Vector2 point)
{
// Get the half-plane that the point lands in, for each side of the triangle
int halfPlaneAb = MathUtils.VectorOrientation(A, B, point);
int halfPlaneBc = MathUtils.VectorOrientation(B, C, point);
int halfPlaneCa = MathUtils.VectorOrientation(C, A, point);
// The intersection of three half-planes derived from the three sides of the triangle
// is the triangle itself, so check for the point being in those three half-planes
bool allNonNegative = halfPlaneAb >= 0 && halfPlaneBc >= 0 && halfPlaneCa >= 0;
bool allNonPositive = halfPlaneAb <= 0 && halfPlaneBc <= 0 && halfPlaneCa <= 0;
return allNonNegative || allNonPositive;
}
}