This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| int | AAS_AlternativeRouteGoals (vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, aas_altroutegoal_t *altroutegoals, int maxaltroutegoals, int type) |
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 99 of file be_aas_routealt.c. References aas_altroutegoal_t, AAS_AltRoutingFloodCluster_r(), AAS_AreaReachability(), AAS_AreaTravelTimeToGoalArea(), AAS_ShowAreaPolygons(), aasworld, ALTROUTEGOAL_CLUSTERPORTALS, ALTROUTEGOAL_VIEWPORTALS, aas_altroutegoal_s::areanum, aas_s::areas, aas_s::areasettings, botimport, aas_area_s::center, clusterareas, Com_Memset(), aas_areasettings_s::contents, aas_altroutegoal_s::extratraveltime, midrangearea_s::goaltime, aas_altroutegoal_s::goaltraveltime, i, j, Log_Write(), midrangearea_t, midrangeareas, NULL, aas_s::numareas, numclusterareas, aas_altroutegoal_s::origin, PRT_MESSAGE, qtrue, midrangearea_s::starttime, aas_altroutegoal_s::starttraveltime, Sys_MilliSeconds(), type, midrangearea_s::valid, vec3_t, VectorAdd, VectorClear, VectorCopy, VectorLength(), VectorScale, and VectorSubtract. 00102 {
00103 #ifndef ENABLE_ALTROUTING
00104 return 0;
00105 #else
00106 int i, j, bestareanum;
00107 int numaltroutegoals, nummidrangeareas;
00108 int starttime, goaltime, goaltraveltime;
00109 float dist, bestdist;
00110 vec3_t mid, dir;
00111 #ifdef ALTROUTE_DEBUG
00112 int startmillisecs;
00113
00114 startmillisecs = Sys_MilliSeconds();
00115 #endif
00116
00117 if (!startareanum || !goalareanum)
00118 return 0;
00119 //travel time towards the goal area
00120 goaltraveltime = AAS_AreaTravelTimeToGoalArea(startareanum, start, goalareanum, travelflags);
00121 //clear the midrange areas
00122 Com_Memset(midrangeareas, 0, aasworld.numareas * sizeof(midrangearea_t));
00123 numaltroutegoals = 0;
00124 //
00125 nummidrangeareas = 0;
00126 //
00127 for (i = 1; i < aasworld.numareas; i++)
00128 {
00129 //
00130 if (!(type & ALTROUTEGOAL_ALL))
00131 {
00132 if (!(type & ALTROUTEGOAL_CLUSTERPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)))
00133 {
00134 if (!(type & ALTROUTEGOAL_VIEWPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL)))
00135 {
00136 continue;
00137 } //end if
00138 } //end if
00139 } //end if
00140 //if the area has no reachabilities
00141 if (!AAS_AreaReachability(i)) continue;
00142 //tavel time from the area to the start area
00143 starttime = AAS_AreaTravelTimeToGoalArea(startareanum, start, i, travelflags);
00144 if (!starttime) continue;
00145 //if the travel time from the start to the area is greater than the shortest goal travel time
00146 if (starttime > (float) 1.1 * goaltraveltime) continue;
00147 //travel time from the area to the goal area
00148 goaltime = AAS_AreaTravelTimeToGoalArea(i, NULL, goalareanum, travelflags);
00149 if (!goaltime) continue;
00150 //if the travel time from the area to the goal is greater than the shortest goal travel time
00151 if (goaltime > (float) 0.8 * goaltraveltime) continue;
00152 //this is a mid range area
00153 midrangeareas[i].valid = qtrue;
00154 midrangeareas[i].starttime = starttime;
00155 midrangeareas[i].goaltime = goaltime;
00156 Log_Write("%d midrange area %d", nummidrangeareas, i);
00157 nummidrangeareas++;
00158 } //end for
00159 //
00160 for (i = 1; i < aasworld.numareas; i++)
00161 {
00162 if (!midrangeareas[i].valid) continue;
00163 //get the areas in one cluster
00164 numclusterareas = 0;
00165 AAS_AltRoutingFloodCluster_r(i);
00166 //now we've got a cluster with areas through which an alternative route could go
00167 //get the 'center' of the cluster
00168 VectorClear(mid);
00169 for (j = 0; j < numclusterareas; j++)
00170 {
00171 VectorAdd(mid, aasworld.areas[clusterareas[j]].center, mid);
00172 } //end for
00173 VectorScale(mid, 1.0 / numclusterareas, mid);
00174 //get the area closest to the center of the cluster
00175 bestdist = 999999;
00176 bestareanum = 0;
00177 for (j = 0; j < numclusterareas; j++)
00178 {
00179 VectorSubtract(mid, aasworld.areas[clusterareas[j]].center, dir);
00180 dist = VectorLength(dir);
00181 if (dist < bestdist)
00182 {
00183 bestdist = dist;
00184 bestareanum = clusterareas[j];
00185 } //end if
00186 } //end for
00187 //now we've got an area for an alternative route
00188 //FIXME: add alternative goal origin
00189 VectorCopy(aasworld.areas[bestareanum].center, altroutegoals[numaltroutegoals].origin);
00190 altroutegoals[numaltroutegoals].areanum = bestareanum;
00191 altroutegoals[numaltroutegoals].starttraveltime = midrangeareas[bestareanum].starttime;
00192 altroutegoals[numaltroutegoals].goaltraveltime = midrangeareas[bestareanum].goaltime;
00193 altroutegoals[numaltroutegoals].extratraveltime =
00194 (midrangeareas[bestareanum].starttime + midrangeareas[bestareanum].goaltime) -
00195 goaltraveltime;
00196 numaltroutegoals++;
00197 //
00198 #ifdef ALTROUTE_DEBUG
00199 AAS_ShowAreaPolygons(bestareanum, 1, qtrue);
00200 #endif
00201 //don't return more than the maximum alternative route goals
00202 if (numaltroutegoals >= maxaltroutegoals) break;
00203 } //end for
00204 #ifdef ALTROUTE_DEBUG
00205 botimport.Print(PRT_MESSAGE, "alternative route goals in %d msec\n", Sys_MilliSeconds() - startmillisecs);
00206 #endif
00207 return numaltroutegoals;
00208 #endif
00209 } //end of the function AAS_AlternativeRouteGoals
|
Here is the call graph for this function:

1.3.9.1