Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

be_aas_debug.c

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 
00023 /*****************************************************************************
00024  * name:        be_aas_debug.c
00025  *
00026  * desc:        AAS debug code
00027  *
00028  * $Archive: /MissionPack/code/botlib/be_aas_debug.c $
00029  *
00030  *****************************************************************************/
00031 
00032 #include "../game/q_shared.h"
00033 #include "l_memory.h"
00034 #include "l_script.h"
00035 #include "l_precomp.h"
00036 #include "l_struct.h"
00037 #include "l_libvar.h"
00038 #include "aasfile.h"
00039 #include "../game/botlib.h"
00040 #include "../game/be_aas.h"
00041 #include "be_interface.h"
00042 #include "be_aas_funcs.h"
00043 #include "be_aas_def.h"
00044 
00045 #define MAX_DEBUGLINES              1024
00046 #define MAX_DEBUGPOLYGONS           8192
00047 
00048 int debuglines[MAX_DEBUGLINES];
00049 int debuglinevisible[MAX_DEBUGLINES];
00050 int numdebuglines;
00051 
00052 static int debugpolygons[MAX_DEBUGPOLYGONS];
00053 
00054 //===========================================================================
00055 //
00056 // Parameter:               -
00057 // Returns:                 -
00058 // Changes Globals:     -
00059 //===========================================================================
00060 void AAS_ClearShownPolygons(void)
00061 {
00062     int i;
00063 //*
00064     for (i = 0; i < MAX_DEBUGPOLYGONS; i++)
00065     {
00066         if (debugpolygons[i]) botimport.DebugPolygonDelete(debugpolygons[i]);
00067         debugpolygons[i] = 0;
00068     } //end for
00069 //*/
00070 /*
00071     for (i = 0; i < MAX_DEBUGPOLYGONS; i++)
00072     {
00073         botimport.DebugPolygonDelete(i);
00074         debugpolygons[i] = 0;
00075     } //end for
00076 */
00077 } //end of the function AAS_ClearShownPolygons
00078 //===========================================================================
00079 //
00080 // Parameter:               -
00081 // Returns:                 -
00082 // Changes Globals:     -
00083 //===========================================================================
00084 void AAS_ShowPolygon(int color, int numpoints, vec3_t *points)
00085 {
00086     int i;
00087 
00088     for (i = 0; i < MAX_DEBUGPOLYGONS; i++)
00089     {
00090         if (!debugpolygons[i])
00091         {
00092             debugpolygons[i] = botimport.DebugPolygonCreate(color, numpoints, points);
00093             break;
00094         } //end if
00095     } //end for
00096 } //end of the function AAS_ShowPolygon
00097 //===========================================================================
00098 //
00099 // Parameter:               -
00100 // Returns:                 -
00101 // Changes Globals:     -
00102 //===========================================================================
00103 void AAS_ClearShownDebugLines(void)
00104 {
00105     int i;
00106 
00107     //make all lines invisible
00108     for (i = 0; i < MAX_DEBUGLINES; i++)
00109     {
00110         if (debuglines[i])
00111         {
00112             //botimport.DebugLineShow(debuglines[i], NULL, NULL, LINECOLOR_NONE);
00113             botimport.DebugLineDelete(debuglines[i]);
00114             debuglines[i] = 0;
00115             debuglinevisible[i] = qfalse;
00116         } //end if
00117     } //end for
00118 } //end of the function AAS_ClearShownDebugLines
00119 //===========================================================================
00120 //
00121 // Parameter:               -
00122 // Returns:                 -
00123 // Changes Globals:     -
00124 //===========================================================================
00125 void AAS_DebugLine(vec3_t start, vec3_t end, int color)
00126 {
00127     int line;
00128 
00129     for (line = 0; line < MAX_DEBUGLINES; line++)
00130     {
00131         if (!debuglines[line])
00132         {
00133             debuglines[line] = botimport.DebugLineCreate();
00134             debuglinevisible[line] = qfalse;
00135             numdebuglines++;
00136         } //end if
00137         if (!debuglinevisible[line])
00138         {
00139             botimport.DebugLineShow(debuglines[line], start, end, color);
00140             debuglinevisible[line] = qtrue;
00141             return;
00142         } //end else
00143     } //end for
00144 } //end of the function AAS_DebugLine
00145 //===========================================================================
00146 //
00147 // Parameter:           -
00148 // Returns:             -
00149 // Changes Globals:     -
00150 //===========================================================================
00151 void AAS_PermanentLine(vec3_t start, vec3_t end, int color)
00152 {
00153     int line;
00154 
00155     line = botimport.DebugLineCreate();
00156     botimport.DebugLineShow(line, start, end, color);
00157 } //end of the function AAS_PermenentLine
00158 //===========================================================================
00159 //
00160 // Parameter:           -
00161 // Returns:             -
00162 // Changes Globals:     -
00163 //===========================================================================
00164 void AAS_DrawPermanentCross(vec3_t origin, float size, int color)
00165 {
00166     int i, debugline;
00167     vec3_t start, end;
00168 
00169     for (i = 0; i < 3; i++)
00170     {
00171         VectorCopy(origin, start);
00172         start[i] += size;
00173         VectorCopy(origin, end);
00174         end[i] -= size;
00175         AAS_DebugLine(start, end, color);
00176         debugline = botimport.DebugLineCreate();
00177         botimport.DebugLineShow(debugline, start, end, color);
00178     } //end for
00179 } //end of the function AAS_DrawPermanentCross
00180 //===========================================================================
00181 //
00182 // Parameter:               -
00183 // Returns:                 -
00184 // Changes Globals:     -
00185 //===========================================================================
00186 void AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color)
00187 {
00188     int n0, n1, n2, j, line, lines[2];
00189     vec3_t start1, end1, start2, end2;
00190 
00191     //make a cross in the hit plane at the hit point
00192     VectorCopy(point, start1);
00193     VectorCopy(point, end1);
00194     VectorCopy(point, start2);
00195     VectorCopy(point, end2);
00196 
00197     n0 = type % 3;
00198     n1 = (type + 1) % 3;
00199     n2 = (type + 2) % 3;
00200     start1[n1] -= 6;
00201     start1[n2] -= 6;
00202     end1[n1] += 6;
00203     end1[n2] += 6;
00204     start2[n1] += 6;
00205     start2[n2] -= 6;
00206     end2[n1] -= 6;
00207     end2[n2] += 6;
00208 
00209     start1[n0] = (dist - (start1[n1] * normal[n1] +
00210                 start1[n2] * normal[n2])) / normal[n0];
00211     end1[n0] = (dist - (end1[n1] * normal[n1] +
00212                 end1[n2] * normal[n2])) / normal[n0];
00213     start2[n0] = (dist - (start2[n1] * normal[n1] +
00214                 start2[n2] * normal[n2])) / normal[n0];
00215     end2[n0] = (dist - (end2[n1] * normal[n1] +
00216                 end2[n2] * normal[n2])) / normal[n0];
00217 
00218     for (j = 0, line = 0; j < 2 && line < MAX_DEBUGLINES; line++)
00219     {
00220         if (!debuglines[line])
00221         {
00222             debuglines[line] = botimport.DebugLineCreate();
00223             lines[j++] = debuglines[line];
00224             debuglinevisible[line] = qtrue;
00225             numdebuglines++;
00226         } //end if
00227         else if (!debuglinevisible[line])
00228         {
00229             lines[j++] = debuglines[line];
00230             debuglinevisible[line] = qtrue;
00231         } //end else
00232     } //end for
00233     botimport.DebugLineShow(lines[0], start1, end1, color);
00234     botimport.DebugLineShow(lines[1], start2, end2, color);
00235 } //end of the function AAS_DrawPlaneCross
00236 //===========================================================================
00237 //
00238 // Parameter:               -
00239 // Returns:                 -
00240 // Changes Globals:     -
00241 //===========================================================================
00242 void AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs)
00243 {
00244     vec3_t bboxcorners[8];
00245     int lines[3];
00246     int i, j, line;
00247 
00248     //upper corners
00249     bboxcorners[0][0] = origin[0] + maxs[0];
00250     bboxcorners[0][1] = origin[1] + maxs[1];
00251     bboxcorners[0][2] = origin[2] + maxs[2];
00252     //
00253     bboxcorners[1][0] = origin[0] + mins[0];
00254     bboxcorners[1][1] = origin[1] + maxs[1];
00255     bboxcorners[1][2] = origin[2] + maxs[2];
00256     //
00257     bboxcorners[2][0] = origin[0] + mins[0];
00258     bboxcorners[2][1] = origin[1] + mins[1];
00259     bboxcorners[2][2] = origin[2] + maxs[2];
00260     //
00261     bboxcorners[3][0] = origin[0] + maxs[0];
00262     bboxcorners[3][1] = origin[1] + mins[1];
00263     bboxcorners[3][2] = origin[2] + maxs[2];
00264     //lower corners
00265     Com_Memcpy(bboxcorners[4], bboxcorners[0], sizeof(vec3_t) * 4);
00266     for (i = 0; i < 4; i++) bboxcorners[4 + i][2] = origin[2] + mins[2];
00267     //draw bounding box
00268     for (i = 0; i < 4; i++)
00269     {
00270         for (j = 0, line = 0; j < 3 && line < MAX_DEBUGLINES; line++)
00271         {
00272             if (!debuglines[line])
00273             {
00274                 debuglines[line] = botimport.DebugLineCreate();
00275                 lines[j++] = debuglines[line];
00276                 debuglinevisible[line] = qtrue;
00277                 numdebuglines++;
00278             } //end if
00279             else if (!debuglinevisible[line])
00280             {
00281                 lines[j++] = debuglines[line];
00282                 debuglinevisible[line] = qtrue;
00283             } //end else
00284         } //end for
00285         //top plane
00286         botimport.DebugLineShow(lines[0], bboxcorners[i],
00287                                     bboxcorners[(i+1)&3], LINECOLOR_RED);
00288         //bottom plane
00289         botimport.DebugLineShow(lines[1], bboxcorners[4+i],
00290                                     bboxcorners[4+((i+1)&3)], LINECOLOR_RED);
00291         //vertical lines
00292         botimport.DebugLineShow(lines[2], bboxcorners[i],
00293                                     bboxcorners[4+i], LINECOLOR_RED);
00294     } //end for
00295 } //end of the function AAS_ShowBoundingBox
00296 //===========================================================================
00297 //
00298 // Parameter:               -
00299 // Returns:                 -
00300 // Changes Globals:     -
00301 //===========================================================================
00302 void AAS_ShowFace(int facenum)
00303 {
00304     int i, color, edgenum;
00305     aas_edge_t *edge;
00306     aas_face_t *face;
00307     aas_plane_t *plane;
00308     vec3_t start, end;
00309 
00310     color = LINECOLOR_YELLOW;
00311     //check if face number is in range
00312     if (facenum >= aasworld.numfaces)
00313     {
00314         botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
00315     } //end if
00316     face = &aasworld.faces[facenum];
00317     //walk through the edges of the face
00318     for (i = 0; i < face->numedges; i++)
00319     {
00320         //edge number
00321         edgenum = abs(aasworld.edgeindex[face->firstedge + i]);
00322         //check if edge number is in range
00323         if (edgenum >= aasworld.numedges)
00324         {
00325             botimport.Print(PRT_ERROR, "edgenum %d out of range\n", edgenum);
00326         } //end if
00327         edge = &aasworld.edges[edgenum];
00328         if (color == LINECOLOR_RED) color = LINECOLOR_GREEN;
00329         else if (color == LINECOLOR_GREEN) color = LINECOLOR_BLUE;
00330         else if (color == LINECOLOR_BLUE) color = LINECOLOR_YELLOW;
00331         else color = LINECOLOR_RED;
00332         AAS_DebugLine(aasworld.vertexes[edge->v[0]],
00333                                         aasworld.vertexes[edge->v[1]],
00334                                         color);
00335     } //end for
00336     plane = &aasworld.planes[face->planenum];
00337     edgenum = abs(aasworld.edgeindex[face->firstedge]);
00338     edge = &aasworld.edges[edgenum];
00339     VectorCopy(aasworld.vertexes[edge->v[0]], start);
00340     VectorMA(start, 20, plane->normal, end);
00341     AAS_DebugLine(start, end, LINECOLOR_RED);
00342 } //end of the function AAS_ShowFace
00343 //===========================================================================
00344 //
00345 // Parameter:               -
00346 // Returns:                 -
00347 // Changes Globals:     -
00348 //===========================================================================
00349 void AAS_ShowFacePolygon(int facenum, int color, int flip)
00350 {
00351     int i, edgenum, numpoints;
00352     vec3_t points[128];
00353     aas_edge_t *edge;
00354     aas_face_t *face;
00355 
00356     //check if face number is in range
00357     if (facenum >= aasworld.numfaces)
00358     {
00359         botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
00360     } //end if
00361     face = &aasworld.faces[facenum];
00362     //walk through the edges of the face
00363     numpoints = 0;
00364     if (flip)
00365     {
00366         for (i = face->numedges-1; i >= 0; i--)
00367         {
00368             //edge number
00369             edgenum = aasworld.edgeindex[face->firstedge + i];
00370             edge = &aasworld.edges[abs(edgenum)];
00371             VectorCopy(aasworld.vertexes[edge->v[edgenum < 0]], points[numpoints]);
00372             numpoints++;
00373         } //end for
00374     } //end if
00375     else
00376     {
00377         for (i = 0; i < face->numedges; i++)
00378         {
00379             //edge number
00380             edgenum = aasworld.edgeindex[face->firstedge + i];
00381             edge = &aasworld.edges[abs(edgenum)];
00382             VectorCopy(aasworld.vertexes[edge->v[edgenum < 0]], points[numpoints]);
00383             numpoints++;
00384         } //end for
00385     } //end else
00386     AAS_ShowPolygon(color, numpoints, points);
00387 } //end of the function AAS_ShowFacePolygon
00388 //===========================================================================
00389 //
00390 // Parameter:               -
00391 // Returns:                 -
00392 // Changes Globals:     -
00393 //===========================================================================
00394 void AAS_ShowArea(int areanum, int groundfacesonly)
00395 {
00396     int areaedges[MAX_DEBUGLINES];
00397     int numareaedges, i, j, n, color = 0, line;
00398     int facenum, edgenum;
00399     aas_area_t *area;
00400     aas_face_t *face;
00401     aas_edge_t *edge;
00402 
00403     //
00404     numareaedges = 0;
00405     //
00406     if (areanum < 0 || areanum >= aasworld.numareas)
00407     {
00408         botimport.Print(PRT_ERROR, "area %d out of range [0, %d]\n",
00409                                 areanum, aasworld.numareas);
00410         return;
00411     } //end if
00412     //pointer to the convex area
00413     area = &aasworld.areas[areanum];
00414     //walk through the faces of the area
00415     for (i = 0; i < area->numfaces; i++)
00416     {
00417         facenum = abs(aasworld.faceindex[area->firstface + i]);
00418         //check if face number is in range
00419         if (facenum >= aasworld.numfaces)
00420         {
00421             botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
00422         } //end if
00423         face = &aasworld.faces[facenum];
00424         //ground faces only
00425         if (groundfacesonly)
00426         {
00427             if (!(face->faceflags & (FACE_GROUND | FACE_LADDER))) continue;
00428         } //end if
00429         //walk through the edges of the face
00430         for (j = 0; j < face->numedges; j++)
00431         {
00432             //edge number
00433             edgenum = abs(aasworld.edgeindex[face->firstedge + j]);
00434             //check if edge number is in range
00435             if (edgenum >= aasworld.numedges)
00436             {
00437                 botimport.Print(PRT_ERROR, "edgenum %d out of range\n", edgenum);
00438             } //end if
00439             //check if the edge is stored already
00440             for (n = 0; n < numareaedges; n++)
00441             {
00442                 if (areaedges[n] == edgenum) break;
00443             } //end for
00444             if (n == numareaedges && numareaedges < MAX_DEBUGLINES)
00445             {
00446                 areaedges[numareaedges++] = edgenum;
00447             } //end if
00448         } //end for
00449         //AAS_ShowFace(facenum);
00450     } //end for
00451     //draw all the edges
00452     for (n = 0; n < numareaedges; n++)
00453     {
00454         for (line = 0; line < MAX_DEBUGLINES; line++)
00455         {
00456             if (!debuglines[line])
00457             {
00458                 debuglines[line] = botimport.DebugLineCreate();
00459                 debuglinevisible[line] = qfalse;
00460                 numdebuglines++;
00461             } //end if
00462             if (!debuglinevisible[line])
00463             {
00464                 break;
00465             } //end else
00466         } //end for
00467         if (line >= MAX_DEBUGLINES) return;
00468         edge = &aasworld.edges[areaedges[n]];
00469         if (color == LINECOLOR_RED) color = LINECOLOR_BLUE;
00470         else if (color == LINECOLOR_BLUE) color = LINECOLOR_GREEN;
00471         else if (color == LINECOLOR_GREEN) color = LINECOLOR_YELLOW;
00472         else color = LINECOLOR_RED;
00473         botimport.DebugLineShow(debuglines[line],
00474                                     aasworld.vertexes[edge->v[0]],
00475                                     aasworld.vertexes[edge->v[1]],
00476                                     color);
00477         debuglinevisible[line] = qtrue;
00478     } //end for*/
00479 } //end of the function AAS_ShowArea
00480 //===========================================================================
00481 //
00482 // Parameter:               -
00483 // Returns:                 -
00484 // Changes Globals:     -
00485 //===========================================================================
00486 void AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly)
00487 {
00488     int i, facenum;
00489     aas_area_t *area;
00490     aas_face_t *face;
00491 
00492     //
00493     if (areanum < 0 || areanum >= aasworld.numareas)
00494     {
00495         botimport.Print(PRT_ERROR, "area %d out of range [0, %d]\n",
00496                                 areanum, aasworld.numareas);
00497         return;
00498     } //end if
00499     //pointer to the convex area
00500     area = &aasworld.areas[areanum];
00501     //walk through the faces of the area
00502     for (i = 0; i < area->numfaces; i++)
00503     {
00504         facenum = abs(aasworld.faceindex[area->firstface + i]);
00505         //check if face number is in range
00506         if (facenum >= aasworld.numfaces)
00507         {
00508             botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
00509         } //end if
00510         face = &aasworld.faces[facenum];
00511         //ground faces only
00512         if (groundfacesonly)
00513         {
00514             if (!(face->faceflags & (FACE_GROUND | FACE_LADDER))) continue;
00515         } //end if
00516         AAS_ShowFacePolygon(facenum, color, face->frontarea != areanum);
00517     } //end for
00518 } //end of the function AAS_ShowAreaPolygons
00519 //===========================================================================
00520 //
00521 // Parameter:               -
00522 // Returns:                 -
00523 // Changes Globals:     -
00524 //===========================================================================
00525 void AAS_DrawCross(vec3_t origin, float size, int color)
00526 {
00527     int i;
00528     vec3_t start, end;
00529 
00530     for (i = 0; i < 3; i++)
00531     {
00532         VectorCopy(origin, start);
00533         start[i] += size;
00534         VectorCopy(origin, end);
00535         end[i] -= size;
00536         AAS_DebugLine(start, end, color);
00537     } //end for
00538 } //end of the function AAS_DrawCross
00539 //===========================================================================
00540 //
00541 // Parameter:               -
00542 // Returns:                 -
00543 // Changes Globals:     -
00544 //===========================================================================
00545 void AAS_PrintTravelType(int traveltype)
00546 {
00547 #ifdef DEBUG
00548     char *str;
00549     //
00550     switch(traveltype & TRAVELTYPE_MASK)
00551     {
00552         case TRAVEL_INVALID: str = "TRAVEL_INVALID"; break;
00553         case TRAVEL_WALK: str = "TRAVEL_WALK"; break;
00554         case TRAVEL_CROUCH: str = "TRAVEL_CROUCH"; break;
00555         case TRAVEL_BARRIERJUMP: str = "TRAVEL_BARRIERJUMP"; break;
00556         case TRAVEL_JUMP: str = "TRAVEL_JUMP"; break;
00557         case TRAVEL_LADDER: str = "TRAVEL_LADDER"; break;
00558         case TRAVEL_WALKOFFLEDGE: str = "TRAVEL_WALKOFFLEDGE"; break;
00559         case TRAVEL_SWIM: str = "TRAVEL_SWIM"; break;
00560         case TRAVEL_WATERJUMP: str = "TRAVEL_WATERJUMP"; break;
00561         case TRAVEL_TELEPORT: str = "TRAVEL_TELEPORT"; break;
00562         case TRAVEL_ELEVATOR: str = "TRAVEL_ELEVATOR"; break;
00563         case TRAVEL_ROCKETJUMP: str = "TRAVEL_ROCKETJUMP"; break;
00564         case TRAVEL_BFGJUMP: str = "TRAVEL_BFGJUMP"; break;
00565         case TRAVEL_GRAPPLEHOOK: str = "TRAVEL_GRAPPLEHOOK"; break;
00566         case TRAVEL_JUMPPAD: str = "TRAVEL_JUMPPAD"; break;
00567         case TRAVEL_FUNCBOB: str = "TRAVEL_FUNCBOB"; break;
00568         default: str = "UNKNOWN TRAVEL TYPE"; break;
00569     } //end switch
00570     botimport.Print(PRT_MESSAGE, "%s", str);
00571 #endif
00572 } //end of the function AAS_PrintTravelType
00573 //===========================================================================
00574 //
00575 // Parameter:               -
00576 // Returns:                 -
00577 // Changes Globals:     -
00578 //===========================================================================
00579 void AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor)
00580 {
00581     vec3_t dir, cross, p1, p2, up = {0, 0, 1};
00582     float dot;
00583 
00584     VectorSubtract(end, start, dir);
00585     VectorNormalize(dir);
00586     dot = DotProduct(dir, up);
00587     if (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);
00588     else CrossProduct(dir, up, cross);
00589 
00590     VectorMA(end, -6, dir, p1);
00591     VectorCopy(p1, p2);
00592     VectorMA(p1, 6, cross, p1);
00593     VectorMA(p2, -6, cross, p2);
00594 
00595     AAS_DebugLine(start, end, linecolor);
00596     AAS_DebugLine(p1, end, arrowcolor);
00597     AAS_DebugLine(p2, end, arrowcolor);
00598 } //end of the function AAS_DrawArrow
00599 //===========================================================================
00600 //
00601 // Parameter:               -
00602 // Returns:                 -
00603 // Changes Globals:     -
00604 //===========================================================================
00605 void AAS_ShowReachability(aas_reachability_t *reach)
00606 {
00607     vec3_t dir, cmdmove, velocity;
00608     float speed, zvel;
00609     aas_clientmove_t move;
00610 
00611     AAS_ShowAreaPolygons(reach->areanum, 5, qtrue);
00612     //AAS_ShowArea(reach->areanum, qtrue);
00613     AAS_DrawArrow(reach->start, reach->end, LINECOLOR_BLUE, LINECOLOR_YELLOW);
00614     //
00615     if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP ||
00616         (reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE)
00617     {
00618         AAS_HorizontalVelocityForJump(aassettings.phys_jumpvel, reach->start, reach->end, &speed);
00619         //
00620         VectorSubtract(reach->end, reach->start, dir);
00621         dir[2] = 0;
00622         VectorNormalize(dir);
00623         //set the velocity
00624         VectorScale(dir, speed, velocity);
00625         //set the command movement
00626         VectorClear(cmdmove);
00627         cmdmove[2] = aassettings.phys_jumpvel;
00628         //
00629         AAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,
00630                                     velocity, cmdmove, 3, 30, 0.1f,
00631                                     SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|
00632                                     SE_ENTERLAVA|SE_HITGROUNDDAMAGE, 0, qtrue);
00633         //
00634         if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP)
00635         {
00636             AAS_JumpReachRunStart(reach, dir);
00637             AAS_DrawCross(dir, 4, LINECOLOR_BLUE);
00638         } //end if
00639     } //end if
00640     else if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_ROCKETJUMP)
00641     {
00642         zvel = AAS_RocketJumpZVelocity(reach->start);
00643         AAS_HorizontalVelocityForJump(zvel, reach->start, reach->end, &speed);
00644         //
00645         VectorSubtract(reach->end, reach->start, dir);
00646         dir[2] = 0;
00647         VectorNormalize(dir);
00648         //get command movement
00649         VectorScale(dir, speed, cmdmove);
00650         VectorSet(velocity, 0, 0, zvel);
00651         //
00652         AAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,
00653                                     velocity, cmdmove, 30, 30, 0.1f,
00654                                     SE_ENTERWATER|SE_ENTERSLIME|
00655                                     SE_ENTERLAVA|SE_HITGROUNDDAMAGE|
00656                                     SE_TOUCHJUMPPAD|SE_HITGROUNDAREA, reach->areanum, qtrue);
00657     } //end else if
00658     else if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD)
00659     {
00660         VectorSet(cmdmove, 0, 0, 0);
00661         //
00662         VectorSubtract(reach->end, reach->start, dir);
00663         dir[2] = 0;
00664         VectorNormalize(dir);
00665         //set the velocity
00666         //NOTE: the edgenum is the horizontal velocity
00667         VectorScale(dir, reach->edgenum, velocity);
00668         //NOTE: the facenum is the Z velocity
00669         velocity[2] = reach->facenum;
00670         //
00671         AAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,
00672                                     velocity, cmdmove, 30, 30, 0.1f,
00673                                     SE_ENTERWATER|SE_ENTERSLIME|
00674                                     SE_ENTERLAVA|SE_HITGROUNDDAMAGE|
00675                                     SE_TOUCHJUMPPAD|SE_HITGROUNDAREA, reach->areanum, qtrue);
00676     } //end else if
00677 } //end of the function AAS_ShowReachability
00678 //===========================================================================
00679 //
00680 // Parameter:               -
00681 // Returns:                 -
00682 // Changes Globals:     -
00683 //===========================================================================
00684 void AAS_ShowReachableAreas(int areanum)
00685 {
00686     aas_areasettings_t *settings;
00687     static aas_reachability_t reach;
00688     static int index, lastareanum;
00689     static float lasttime;
00690 
00691     if (areanum != lastareanum)
00692     {
00693         index = 0;
00694         lastareanum = areanum;
00695     } //end if
00696     settings = &aasworld.areasettings[areanum];
00697     //
00698     if (!settings->numreachableareas) return;
00699     //
00700     if (index >= settings->numreachableareas) index = 0;
00701     //
00702     if (AAS_Time() - lasttime > 1.5)
00703     {
00704         Com_Memcpy(&reach, &aasworld.reachability[settings->firstreachablearea + index], sizeof(aas_reachability_t));
00705         index++;
00706         lasttime = AAS_Time();
00707         AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
00708         botimport.Print(PRT_MESSAGE, "\n");
00709     } //end if
00710     AAS_ShowReachability(&reach);
00711 } //end of the function ShowReachableAreas
00712 
00713 void AAS_FloodAreas_r(int areanum, int cluster, int *done)
00714 {
00715     int nextareanum, i, facenum;
00716     aas_area_t *area;
00717     aas_face_t *face;
00718     aas_areasettings_t *settings;
00719     aas_reachability_t *reach;
00720 
00721     AAS_ShowAreaPolygons(areanum, 1, qtrue);
00722     //pointer to the convex area
00723     area = &aasworld.areas[areanum];
00724     settings = &aasworld.areasettings[areanum];
00725     //walk through the faces of the area
00726     for (i = 0; i < area->numfaces; i++)
00727     {
00728         facenum = abs(aasworld.faceindex[area->firstface + i]);
00729         face = &aasworld.faces[facenum];
00730         if (face->frontarea == areanum)
00731             nextareanum = face->backarea;
00732         else
00733             nextareanum = face->frontarea;
00734         if (!nextareanum)
00735             continue;
00736         if (done[nextareanum])
00737             continue;
00738         done[nextareanum] = qtrue;
00739         if (aasworld.areasettings[nextareanum].contents & AREACONTENTS_VIEWPORTAL)
00740             continue;
00741         if (AAS_AreaCluster(nextareanum) != cluster)
00742             continue;
00743         AAS_FloodAreas_r(nextareanum, cluster, done);
00744     } //end for
00745     //
00746     for (i = 0; i < settings->numreachableareas; i++)
00747     {
00748         reach = &aasworld.reachability[settings->firstreachablearea + i];
00749         nextareanum = reach->areanum;
00750         if (!nextareanum)
00751             continue;
00752         if (done[nextareanum])
00753             continue;
00754         done[nextareanum] = qtrue;
00755         if (aasworld.areasettings[nextareanum].contents & AREACONTENTS_VIEWPORTAL)
00756             continue;
00757         if (AAS_AreaCluster(nextareanum) != cluster)
00758             continue;
00759         /*
00760         if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE)
00761         {
00762             AAS_DebugLine(reach->start, reach->end, 1);
00763         }
00764         */
00765         AAS_FloodAreas_r(nextareanum, cluster, done);
00766     }
00767 }
00768 
00769 void AAS_FloodAreas(vec3_t origin)
00770 {
00771     int areanum, cluster, *done;
00772 
00773     done = (int *) GetClearedMemory(aasworld.numareas * sizeof(int));
00774     areanum = AAS_PointAreaNum(origin);
00775     cluster = AAS_AreaCluster(areanum);
00776     AAS_FloodAreas_r(areanum, cluster, done);
00777 }

Generated on Thu Aug 25 12:37:09 2005 for Quake III Arena by  doxygen 1.3.9.1