]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/pathlib/expandnode.qc
fix warning
[divverent/nexuiz.git] / data / qcsrc / server / pathlib / expandnode.qc
1 vector plib_points2[8];
2 vector plib_points[8];
3 float  plib_fvals[8];
4
5 float pathlib_expandnode_starf(entity node, vector start, vector goal)
6 {
7     vector where,f,r,t;
8     float i,fc,fc2,c;
9     entity nap;
10
11     where = node.origin;
12
13     f = PLIB_FORWARD * pathlib_gridsize;
14     r = PLIB_RIGHT   * pathlib_gridsize;
15
16     // Forward
17     plib_points[0] = where + f;
18
19     // Back
20     plib_points[1] = where - f;
21
22     // Right
23     plib_points[2] = where + r;
24
25     // Left
26     plib_points[3] = where - r;
27
28     // Forward-right
29     plib_points[4] = where + f + r;
30
31     // Forward-left
32     plib_points[5] = where + f - r;
33
34     // Back-right
35     plib_points[6] = where - f + r;
36
37     // Back-left
38     plib_points[7] = where - f - r;
39
40     for(i=0;i < 8; ++i)
41     {
42         t = plib_points[i];
43         fc  = pathlib_heuristic(t,goal) + pathlib_cost(node,t,pathlib_gridsize);
44         plib_fvals[i] = fc;
45
46     }
47
48     fc = plib_fvals[0];
49     plib_points2[0] = plib_points[0];
50     vector bp;
51     bp = plib_points[0];
52     for(i = 0; i < 8; ++i)
53     {
54         c = 0;
55         nap = pathlib_nodeatpoint(plib_points[i]);
56         if(nap)
57             if(nap.owner == openlist)
58                 c = 1;
59         else
60             c = 1;
61
62         if(c)
63         if(plib_fvals[i] < fc)
64         {
65             bp = plib_points[i];
66             fc = plib_fvals[i];
67             plib_points2[fc2] = plib_points[i];
68             ++fc2;
69         }
70
71         /*
72         nap = pathlib_nodeatpoint(plib_points[i]);
73         if(nap)
74         if not nap.owner == closedlist)
75         {
76         }
77         */
78     }
79
80     pathlib_makenode(node,start,bp,goal,pathlib_gridsize);
81
82     for(i = 0; i < 3; ++i)
83     {
84         pathlib_makenode(node,start,plib_points2[i],goal,pathlib_gridsize);
85     }
86
87     return pathlib_open_cnt;
88 }
89
90 float pathlib_expandnode_star(entity node, vector start, vector goal)
91 {
92     vector point,where,f,r;
93
94     where = node.origin;
95
96     f = PLIB_FORWARD * pathlib_gridsize;
97     r = PLIB_RIGHT   * pathlib_gridsize;
98
99     // Forward
100     point = where + f;
101     pathlib_makenode(node,start,point,goal,pathlib_movecost);
102
103     // Back
104     point = where - f;
105     pathlib_makenode(node,start,point,goal,pathlib_movecost);
106
107     // Right
108     point = where + r;
109     pathlib_makenode(node,start,point,goal,pathlib_movecost);
110
111     // Left
112     point = where - r;
113     pathlib_makenode(node,start,point,goal,pathlib_movecost);
114
115     // Forward-right
116     point = where + f + r;
117     pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
118
119     // Forward-left
120     point = where + f - r;
121     pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
122
123     // Back-right
124     point = where - f + r;
125     pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
126
127     // Back-left
128     point = where - f - r;
129     pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
130
131     return pathlib_open_cnt;
132 }
133
134 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
135 {
136     vector point,where,f,r;
137
138     where = node.origin;
139
140     f = PLIB_FORWARD * pathlib_gridsize;
141     r = PLIB_RIGHT   * pathlib_gridsize;
142
143     // Forward
144     point = where + f;
145     pathlib_makenode(node,start,point,goal,pathlib_movecost);
146
147     // Back
148     point = where - f;
149     pathlib_makenode(node,start,point,goal,pathlib_movecost);
150
151     // Right
152     point = where + r;
153     pathlib_makenode(node,start,point,goal,pathlib_movecost);
154
155     // Left
156     point = where - r;
157     pathlib_makenode(node,start,point,goal,pathlib_movecost);
158
159     f = PLIB_FORWARD * pathlib_gridsize * 0.5;
160     r = PLIB_RIGHT   * pathlib_gridsize * 0.5;
161
162     // Forward-right
163     point = where + f + r;
164     pathlib_makenode(node,start,point,goal,pathlib_movecost);
165
166
167     // Forward-left
168     point = where + f - r;
169     pathlib_makenode(node,start,point,goal,pathlib_movecost);
170
171
172     // Back-right
173     point = where - f + r;
174     pathlib_makenode(node,start,point,goal,pathlib_movecost);
175
176     // Back-left
177     point = where - f - r;
178     pathlib_makenode(node,start,point,goal,pathlib_movecost);
179
180     return pathlib_open_cnt;
181 }
182
183 float pathlib_expandnode_box(entity node, vector start, vector goal)
184 {
185     vector v;
186
187     for(v_z = node.origin_z - pathlib_gridsize; v_z <= node.origin_z + pathlib_gridsize; v_z += pathlib_gridsize)
188     for(v_y = node.origin_y - pathlib_gridsize; v_y <= node.origin_y + pathlib_gridsize; v_y += pathlib_gridsize)
189     for(v_x = node.origin_x - pathlib_gridsize; v_x <= node.origin_x + pathlib_gridsize; v_x += pathlib_gridsize)
190     {
191         //if(vlen(v - node.origin))
192             pathlib_makenode(node,start,v,goal,pathlib_movecost);
193     }
194
195     return pathlib_open_cnt;
196 }