Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
expandnode.qc File Reference
Include dependency graph for expandnode.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

float pathlib_expandnode_box (entity node, vector start, vector goal)
float pathlib_expandnode_star (entity node, vector start, vector goal)

Function Documentation

◆ pathlib_expandnode_box()

float pathlib_expandnode_box ( entity node,
vector start,
vector goal )

Definition at line 223 of file expandnode.qc.

224{
225 vector v;
226
227 for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
228 for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
229 for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
230 {
231 //if(vlen(v - node.origin))
232 pathlib_makenode(node,start,v,goal,pathlib_movecost);
233 }
234
235 return pathlib_open_cnt;
236}
var bool pathlib_makenode(entity parent, vector start, vector to, vector goal, float cost)
float pathlib_open_cnt
Definition pathlib.qh:42
float pathlib_movecost
Definition pathlib.qh:51
float pathlib_gridsize
Definition pathlib.qh:50
vector
Definition self.qh:92

References entity(), pathlib_gridsize, pathlib_makenode(), pathlib_movecost, pathlib_open_cnt, and vector.

Referenced by pathlib_astar(), and pathlib_makenode_adaptive().

◆ pathlib_expandnode_star()

float pathlib_expandnode_star ( entity node,
vector start,
vector goal )

Definition at line 95 of file expandnode.qc.

96{
97 vector point;
98
99 vector where = node.origin;
100
103
104 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
105 node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
106
107 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
108 {
109 LOG_TRACE("Node at ", vtos(node.origin), " not expanable");
110 return pathlib_open_cnt;
111 }
112
113 // Forward
114 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
115 {
116 point = where + f;
117 pathlib_makenode(node, start, point, goal, pathlib_movecost);
118 }
119
120 // Back
121 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
122 {
123 point = where - f;
124 pathlib_makenode(node, start, point, goal, pathlib_movecost);
125 }
126
127 // Right
128 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
129 {
130 point = where + r;
131 pathlib_makenode(node, start, point, goal, pathlib_movecost);
132 }
133
134 // Left
135 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
136 {
137 point = where - r;
138 pathlib_makenode(node, start, point, goal, pathlib_movecost);
139
140 }
141
142 // Forward-right
143 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
144 {
145 point = where + f + r;
146 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
147 }
148
149 // Forward-left
150 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
151 {
152 point = where + f - r;
153 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
154
155 }
156
157 // Back-right
158 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
159 {
160 point = where - f + r;
161 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
162 }
163
164 // Back-left
165 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
166 {
167 point = where - f - r;
168 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
169 }
170
171 return pathlib_open_cnt;
172}
#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
const float pathlib_node_edgeflag_forwardleft
Definition pathlib.qh:37
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 tile_check_plus2(entity this, vector where)
Definition utility.qc:112

References entity(), LOG_TRACE, pathlib_gridsize, pathlib_makenode(), pathlib_movecost, pathlib_movecost_diag, pathlib_node_edgeflag_back, pathlib_node_edgeflag_backleft, pathlib_node_edgeflag_backright, pathlib_node_edgeflag_forward, pathlib_node_edgeflag_forwardleft, pathlib_node_edgeflag_forwardright, pathlib_node_edgeflag_left, pathlib_node_edgeflag_none, pathlib_node_edgeflag_right, pathlib_node_edgeflag_unknown, pathlib_open_cnt, PLIB_FORWARD, PLIB_RIGHT, tile_check_plus2(), vector, and vtos().

Referenced by pathlib_astar(), and pathlib_makenode_adaptive().