Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
expandnode.qc
Go to the documentation of this file.
1#include "expandnode.qh"
2
5
6/*
7vector plib_points2[8];
8vector plib_points[8];
9float plib_fvals[8];
10
11float pathlib_expandnode_starf(entity node, vector start, vector goal)
12{
13 float fc;
14
15 vector where = node.origin;
16
17 vector f = PLIB_FORWARD * pathlib_gridsize;
18 vector r = PLIB_RIGHT * pathlib_gridsize;
19
20 // Forward
21 plib_points[0] = where + f;
22
23 // Back
24 plib_points[1] = where - f;
25
26 // Right
27 plib_points[2] = where + r;
28
29 // Left
30 plib_points[3] = where - r;
31
32 // Forward-right
33 plib_points[4] = where + f + r;
34
35 // Forward-left
36 plib_points[5] = where + f - r;
37
38 // Back-right
39 plib_points[6] = where - f + r;
40
41 // Back-left
42 plib_points[7] = where - f - r;
43
44 for(int i=0;i < 8; ++i)
45 {
46 vector t = plib_points[i];
47 fc = pathlib_heuristic(t,goal) + pathlib_cost(node, t, pathlib_gridsize);
48 plib_fvals[i] = fc;
49
50 }
51
52 fc = plib_fvals[0];
53 plib_points2[0] = plib_points[0];
54 vector bp;
55 bp = plib_points[0];
56 int fc2 = 0;
57 for(int i = 0; i < 8; ++i)
58 {
59 bool c = false;
60 entity nap = pathlib_nodeatpoint(plib_points[i]);
61 if(nap)
62 {
63 if(nap.owner == openlist)
64 c = true;
65 }
66 else
67 c = true;
68
69 if(c)
70 if(plib_fvals[i] < fc)
71 {
72 bp = plib_points[i];
73 fc = plib_fvals[i];
74 plib_points2[fc2] = plib_points[i];
75 ++fc2;
76 }
77
78 //nap = pathlib_nodeatpoint(plib_points[i]);
79 //if(nap)
80 //if not nap.owner == closedlist)
81 //{
82 //}
83 }
84
85 pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
86
87 for(int i = 0; i < 3; ++i)
88 {
89 pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
90 }
91
92 return pathlib_open_cnt;
93}
94*/
95
97{
98 vector point;
99
100 vector where = node.origin;
101
104
105 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
106 node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
107
108 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
109 {
110 LOG_TRACE("Node at ", vtos(node.origin), " not expanable");
111 return pathlib_open_cnt;
112 }
113
114 // Forward
115 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
116 {
117 point = where + f;
118 pathlib_makenode(node, start, point, goal, pathlib_movecost);
119 }
120
121 // Back
122 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
123 {
124 point = where - f;
125 pathlib_makenode(node, start, point, goal, pathlib_movecost);
126 }
127
128 // Right
129 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
130 {
131 point = where + r;
132 pathlib_makenode(node, start, point, goal, pathlib_movecost);
133 }
134
135 // Left
136 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
137 {
138 point = where - r;
139 pathlib_makenode(node, start, point, goal, pathlib_movecost);
140
141 }
142
143 // Forward-right
144 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
145 {
146 point = where + f + r;
147 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
148 }
149
150 // Forward-left
151 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
152 {
153 point = where + f - r;
154 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
155
156 }
157
158 // Back-right
159 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
160 {
161 point = where - f + r;
162 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
163 }
164
165 // Back-left
166 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
167 {
168 point = where - f - r;
169 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
170 }
171
172 return pathlib_open_cnt;
173}
174
175/*
176float pathlib_expandnode_octagon(entity node, vector start, vector goal)
177{
178 vector point;
179
180 vector where = node.origin;
181
182 vector f = PLIB_FORWARD * pathlib_gridsize;
183 vector r = PLIB_RIGHT * pathlib_gridsize;
184
185 // Forward
186 point = where + f;
187 pathlib_makenode(node, start, point, goal, pathlib_movecost);
188
189 // Back
190 point = where - f;
191 pathlib_makenode(node, start, point, goal, pathlib_movecost);
192
193 // Right
194 point = where + r;
195 pathlib_makenode(node, start, point, goal, pathlib_movecost);
196
197 // Left
198 point = where - r;
199 pathlib_makenode(node, start, point, goal, pathlib_movecost);
200
201 f = PLIB_FORWARD * pathlib_gridsize * 0.5;
202 r = PLIB_RIGHT * pathlib_gridsize * 0.5;
203
204 // Forward-right
205 point = where + f + r;
206 pathlib_makenode(node, start, point, goal, pathlib_movecost);
207
208 // Forward-left
209 point = where + f - r;
210 pathlib_makenode(node, start, point, goal, pathlib_movecost);
211
212 // Back-right
213 point = where - f + r;
214 pathlib_makenode(node, start, point, goal, pathlib_movecost);
215
216 // Back-left
217 point = where - f - r;
218 pathlib_makenode(node, start, point, goal, pathlib_movecost);
219
220 return pathlib_open_cnt;
221}
222*/
223
225{
226 vector v;
227
228 for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
229 for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
230 for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
231 {
232 //if(vlen(v - node.origin))
233 pathlib_makenode(node,start,v,goal,pathlib_movecost);
234 }
235
236 return pathlib_open_cnt;
237}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float pathlib_expandnode_star(entity node, vector start, vector goal)
Definition expandnode.qc:96
float pathlib_expandnode_box(entity node, vector start, vector goal)
#define LOG_TRACE(...)
Definition log.qh:76
string vtos(vector v)
const float pathlib_node_edgeflag_forwardright
Definition pathlib.qh:38
float pathlib_movecost_diag
Definition pathlib.qh:52
const vector PLIB_FORWARD
Definition pathlib.qh:13
const float pathlib_node_edgeflag_backright
Definition pathlib.qh:36
const float pathlib_node_edgeflag_forward
Definition pathlib.qh:33
const float pathlib_node_edgeflag_left
Definition pathlib.qh:31
var bool pathlib_makenode(entity parent, vector start, vector to, vector goal, float cost)
const float pathlib_node_edgeflag_forwardleft
Definition pathlib.qh:37
float pathlib_open_cnt
Definition pathlib.qh:42
const float pathlib_node_edgeflag_right
Definition pathlib.qh:32
const float pathlib_node_edgeflag_unknown
Definition pathlib.qh:30
const float pathlib_node_edgeflag_backleft
Definition pathlib.qh:35
const vector PLIB_RIGHT
Definition pathlib.qh:15
const float pathlib_node_edgeflag_back
Definition pathlib.qh:34
const float pathlib_node_edgeflag_none
Definition pathlib.qh:39
float pathlib_movecost
Definition pathlib.qh:51
float pathlib_gridsize
Definition pathlib.qh:50
vector
Definition self.qh:92
float tile_check_plus2(entity this, vector where)
Definition utility.qc:112