more refactoring
This commit is contained in:
parent
d61f46d07a
commit
886d2a88b0
13 changed files with 592 additions and 573 deletions
20
Sledgemapper/Utils.cs
Normal file
20
Sledgemapper/Utils.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
private static float Sign(Point p1, Point p2, Point p3) { return (p1.X - p3.X) * (p2.Y - p3.Y) - (p2.X - p3.X) * (p1.Y - p3.Y); }
|
||||
|
||||
public static bool PointInTri(Point pt, Point v1, Point v2, Point v3)
|
||||
{
|
||||
bool b1, b2, b3;
|
||||
b1 = Sign(pt, v1, v2) < 0.0f;
|
||||
b2 = Sign(pt, v2, v3) < 0.0f;
|
||||
b3 = Sign(pt, v3, v1) < 0.0f;
|
||||
return ((b1 == b2) && (b2 == b3));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue