]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/warpzonelib/common.qc
todo
[divverent/nexuiz.git] / data / qcsrc / warpzonelib / common.qc
1 vector WarpZone_TransformVAngles(vector t, vector ang)
2 {
3         float roll;
4
5         roll = ang_z;
6         ang_z = 0;
7
8         /*
9         vector vf, vr, vu;
10         print(vtos(ang), " input\n");
11         makevectors(ang);
12         vf = v_forward;
13         vr = v_right;
14         vu = v_up;
15         print(vtos(vf), " -> ", vtos(AnglesTransform_Apply(t, vf)), "\n");
16         print(vtos(vr), " -> ", vtos(AnglesTransform_Apply(t, vr)), "\n");
17         print(vtos(vu), " -> ", vtos(AnglesTransform_Apply(t, vu)), "\n");
18         */
19
20         ang = AnglesTransform_ApplyToVAngles(t, ang);
21         // FIXME when a roll comes out and angle is near +/-90 degrees
22         // then roll can be incorporated into yaw and cancelled out
23
24         /*
25         print(vtos(ang), " output\n");
26         makevectors(ang);
27         print(vtos(vf), " -> ", vtos(v_forward), "\n");
28         print(vtos(vr), " -> ", vtos(v_right), "\n");
29         print(vtos(vu), " -> ", vtos(v_up), "\n");
30         */
31
32         ang = AnglesTransform_Normalize(ang, TRUE);
33
34         /*
35         print(vtos(ang), " output\n");
36         */
37
38         ang_z = roll;
39         return ang;
40 }
41
42 vector WarpZoneLib_BoxTouchesBrush_mins;
43 vector WarpZoneLib_BoxTouchesBrush_maxs;
44 entity WarpZoneLib_BoxTouchesBrush_ent;
45 entity WarpZoneLib_BoxTouchesBrush_ignore;
46 float WarpZoneLib_BoxTouchesBrush_Recurse()
47 {
48         float s;
49         entity se;
50         float f;
51
52         tracebox('0 0 0', WarpZoneLib_BoxTouchesBrush_mins, WarpZoneLib_BoxTouchesBrush_maxs, '0 0 0', MOVE_NOMONSTERS, WarpZoneLib_BoxTouchesBrush_ignore);
53 #ifdef CSQC
54         if (trace_networkentity)
55         {
56                 dprint("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush\n");
57                 // we cannot continue, as a player blocks us...
58                 // so, abort
59                 return 0;
60         }
61 #endif
62         if not(trace_ent)
63                 return 0;
64         if (trace_ent == WarpZoneLib_BoxTouchesBrush_ent)
65                 return 1;
66
67         
68
69         se = trace_ent;
70         s = se.solid;
71         se.solid = SOLID_NOT;
72         f = WarpZoneLib_BoxTouchesBrush_Recurse();
73         se.solid = s;
74
75         return f;
76 }
77
78 float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
79 {
80     float f, s;
81
82     if not(e.modelindex)
83         return 1;
84
85     s = e.solid;
86     e.solid = SOLID_BSP;
87     WarpZoneLib_BoxTouchesBrush_mins = mi;
88     WarpZoneLib_BoxTouchesBrush_maxs = ma;
89     WarpZoneLib_BoxTouchesBrush_ent = e;
90     WarpZoneLib_BoxTouchesBrush_ignore = ig;
91     f = WarpZoneLib_BoxTouchesBrush_Recurse();
92     e.solid = s;
93
94     return f;
95 }