-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupport.cs
43 lines (37 loc) · 1.65 KB
/
support.cs
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
34
35
36
37
38
39
40
41
42
43
function BTZ_posInBox(%position, %boxPos, %boxScale)
{
if(mAbs(getWord(%position, 0) - getWord(%boxPos, 0)) < getWord(%boxScale, 0) / 2)
if(mAbs(getWord(%position, 1) - getWord(%boxPos, 1)) < getWord(%boxScale, 1) / 2)
return true;
return false;
}
function BTZ_posInWorldbox(%pos, %worldbox)
{
%neg = getWords(%worldbox, 0, 2); //negative xyz corner of the box
%pos = getWords(%worldbox, 3, 5); //positive xyz corner of the box
%px = getWord(%pos, 0);
%py = getWord(%pos, 1);
%pz = getWord(%pos, 2);
return %px > getWord(%neg, 0) && %py > getWord(%neg, 1) && %pz > getWord(%neg, 2)
&& %px < getWord(%pos, 0) && %py < getWord(%pos, 1) && %pz < getWord(%pos, 2);
}
function BTZ_posInBox3D(%position, %boxPos, %boxScale)
{
if(mAbs(getWord(%position, 0) - getWord(%boxPos, 0)) < getWord(%boxScale, 0) / 2)
if(mAbs(getWord(%position, 1) - getWord(%boxPos, 1)) < getWord(%boxScale, 1) / 2)
return mAbs(getWord(%position, 2) - getWord(%boxPos, 2)) < getWord(%boxScale, 2) / 2;
return false;
}
function BTZ_getBoxOverlap(%box_pos0, %box_scale0, %box_pos1, %box_scale1)
{
%box_posX0 = getWord(%box_pos0, 0);
%box_posY0 = getWord(%box_pos0, 1);
%box_posZ0 = getWord(%box_pos0, 2);
%box_posX1 = getWord(%box_pos1, 0);
%box_posY1 = getWord(%box_pos1, 1);
%box_posZ1 = getWord(%box_pos1, 2);
%x = (mAbs(%box_posX0 - %box_posX1) * 2) <= (getWord(%box_scale0, 0) + getWord(%box_scale1, 0));
%y = (mAbs(%box_posY0 - %box_posY1) * 2) <= (getWord(%box_scale0, 1) + getWord(%box_scale1, 1));
%z = (mAbs(%box_posZ0 - %box_posZ1) * 2) <= (getWord(%box_scale0, 2) + getWord(%box_scale1, 2));
return %x && %y && %z;
}