forked from qoh/bl-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfov.cs
More file actions
33 lines (29 loc) · 715 Bytes
/
Copy pathfov.cs
File metadata and controls
33 lines (29 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Public: Test if a point is within a view cone.
//
// a - The origin of the cone.
// b - The point to test.
// vector - The direction of the cone.
// angle - The angle size of the cone (default: 90).
//
// Returns true or false.
function isWithinView(%a, %b, %vector, %angle)
{
if (%angle $= "")
{
%angle = 90;
}
%product = vectorDot(%vector, vectorNormalize(vectorSub(%b, %a)));
return %product >= 1 - (%angle / 360) * 2;
}
function Player::isWithinView(%this, %point, %angle)
{
if (%angle $= "")
{
%client = %this.getControllingClient();
if (isObject(%client))
{
%angle = %client.getControlCameraFOV();
}
}
return isWithinView(%this.getEyePoint(), %b, %this.getEyeVector(), %angle);
}