|
|
@ -0,0 +1,13 @@ |
|
|
|
```csharp |
|
|
|
public static class Geometry { |
|
|
|
public static bool PointInCone( |
|
|
|
float visionRangeSq, float fovCos, Vector2 eyePos, Vector2 direction, Vector2 test) { |
|
|
|
Vector2 delta = Vector2.Subtract(test, eyePos); |
|
|
|
if (delta.LengthSquared() > visionRangeSq) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
float dot = Vector2.Dot(Vector2.Normalize(direction), Vector2.Normalize(delta)); |
|
|
|
return dot > fovCos; |
|
|
|
} |
|
|
|
} |
|
|
|
``` |