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

be_aas_bspc.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 #include "../game/q_shared.h"
00024 #include "../bspc/l_log.h"
00025 #include "../bspc/l_qfiles.h"
00026 #include "../botlib/l_memory.h"
00027 #include "../botlib/l_script.h"
00028 #include "../botlib/l_precomp.h"
00029 #include "../botlib/l_struct.h"
00030 #include "../botlib/aasfile.h"
00031 #include "../game/botlib.h"
00032 #include "../game/be_aas.h"
00033 #include "../botlib/be_aas_def.h"
00034 #include "../qcommon/cm_public.h"
00035 
00036 //#define BSPC
00037 
00038 extern botlib_import_t botimport;
00039 extern  qboolean capsule_collision;
00040 
00041 botlib_import_t botimport;
00042 clipHandle_t worldmodel;
00043 
00044 void Error (char *error, ...);
00045 
00046 //===========================================================================
00047 //
00048 // Parameter:               -
00049 // Returns:                 -
00050 // Changes Globals:     -
00051 //===========================================================================
00052 void AAS_Error(char *fmt, ...)
00053 {
00054     va_list argptr;
00055     char text[1024];
00056 
00057     va_start(argptr, fmt);
00058     vsprintf(text, fmt, argptr);
00059     va_end(argptr);
00060 
00061     Error(text);
00062 } //end of the function AAS_Error
00063 //===========================================================================
00064 //
00065 // Parameter:               -
00066 // Returns:                 -
00067 // Changes Globals:     -
00068 //===========================================================================
00069 int Sys_MilliSeconds(void)
00070 {
00071     return clock() * 1000 / CLOCKS_PER_SEC;
00072 } //end of the function Sys_MilliSeconds
00073 //===========================================================================
00074 //
00075 // Parameter:               -
00076 // Returns:                 -
00077 // Changes Globals:     -
00078 //===========================================================================
00079 void AAS_DebugLine(vec3_t start, vec3_t end, int color)
00080 {
00081 } //end of the function AAS_DebugLine
00082 //===========================================================================
00083 //
00084 // Parameter:               -
00085 // Returns:                 -
00086 // Changes Globals:     -
00087 //===========================================================================
00088 void AAS_ClearShownDebugLines(void)
00089 {
00090 } //end of the function AAS_ClearShownDebugLines
00091 //===========================================================================
00092 //
00093 // Parameter:               -
00094 // Returns:                 -
00095 // Changes Globals:     -
00096 //===========================================================================
00097 char *BotImport_BSPEntityData(void)
00098 {
00099     return CM_EntityString();
00100 } //end of the function AAS_GetEntityData
00101 //===========================================================================
00102 //
00103 // Parameter:               -
00104 // Returns:                 -
00105 // Changes Globals:     -
00106 //===========================================================================
00107 void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
00108 {
00109     trace_t result;
00110 
00111     CM_BoxTrace(&result, start, end, mins, maxs, worldmodel, contentmask, capsule_collision);
00112 
00113     bsptrace->allsolid = result.allsolid;
00114     bsptrace->contents = result.contents;
00115     VectorCopy(result.endpos, bsptrace->endpos);
00116     bsptrace->ent = result.entityNum;
00117     bsptrace->fraction = result.fraction;
00118     bsptrace->exp_dist = 0;
00119     bsptrace->plane.dist = result.plane.dist;
00120     VectorCopy(result.plane.normal, bsptrace->plane.normal);
00121     bsptrace->plane.signbits = result.plane.signbits;
00122     bsptrace->plane.type = result.plane.type;
00123     bsptrace->sidenum = 0;
00124     bsptrace->startsolid = result.startsolid;
00125     bsptrace->surface.flags = result.surfaceFlags;
00126 } //end of the function BotImport_Trace
00127 //===========================================================================
00128 //
00129 // Parameter:               -
00130 // Returns:                 -
00131 // Changes Globals:     -
00132 //===========================================================================
00133 int BotImport_PointContents(vec3_t p)
00134 {
00135     return CM_PointContents(p, worldmodel);
00136 } //end of the function BotImport_PointContents
00137 //===========================================================================
00138 //
00139 // Parameter:               -
00140 // Returns:                 -
00141 // Changes Globals:     -
00142 //===========================================================================
00143 void *BotImport_GetMemory(int size)
00144 {
00145     return GetMemory(size);
00146 } //end of the function BotImport_GetMemory
00147 //===========================================================================
00148 //
00149 // Parameter:           -
00150 // Returns:             -
00151 // Changes Globals:     -
00152 //===========================================================================
00153 void BotImport_Print(int type, char *fmt, ...)
00154 {
00155     va_list argptr;
00156     char buf[1024];
00157 
00158     va_start(argptr, fmt);
00159     vsprintf(buf, fmt, argptr);
00160     printf(buf);
00161     if (buf[0] != '\r') Log_Write(buf);
00162     va_end(argptr);
00163 } //end of the function BotImport_Print
00164 //===========================================================================
00165 //
00166 // Parameter:           -
00167 // Returns:             -
00168 // Changes Globals:     -
00169 //===========================================================================
00170 void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin)
00171 {
00172     clipHandle_t h;
00173     vec3_t mins, maxs;
00174     float max;
00175     int i;
00176 
00177     h = CM_InlineModel(modelnum);
00178     CM_ModelBounds(h, mins, maxs);
00179     //if the model is rotated
00180     if ((angles[0] || angles[1] || angles[2]))
00181     {   // expand for rotation
00182 
00183         max = RadiusFromBounds(mins, maxs);
00184         for (i = 0; i < 3; i++)
00185         {
00186             mins[i] = (mins[i] + maxs[i]) * 0.5 - max;
00187             maxs[i] = (mins[i] + maxs[i]) * 0.5 + max;
00188         } //end for
00189     } //end if
00190     if (outmins) VectorCopy(mins, outmins);
00191     if (outmaxs) VectorCopy(maxs, outmaxs);
00192     if (origin) VectorClear(origin);
00193 } //end of the function BotImport_BSPModelMinsMaxsOrigin
00194 //===========================================================================
00195 //
00196 // Parameter:           -
00197 // Returns:             -
00198 // Changes Globals:     -
00199 //===========================================================================
00200 void Com_DPrintf(char *fmt, ...)
00201 {
00202     va_list argptr;
00203     char buf[1024];
00204 
00205     va_start(argptr, fmt);
00206     vsprintf(buf, fmt, argptr);
00207     printf(buf);
00208     if (buf[0] != '\r') Log_Write(buf);
00209     va_end(argptr);
00210 } //end of the function Com_DPrintf
00211 //===========================================================================
00212 //
00213 // Parameter:           -
00214 // Returns:             -
00215 // Changes Globals:     -
00216 //===========================================================================
00217 int COM_Compress( char *data_p ) {
00218     return strlen(data_p);
00219 }
00220 //===========================================================================
00221 //
00222 // Parameter:           -
00223 // Returns:             -
00224 // Changes Globals:     -
00225 //===========================================================================
00226 void Com_Memset (void* dest, const int val, const size_t count) {
00227     memset(dest, val, count);
00228 }
00229 //===========================================================================
00230 //
00231 // Parameter:           -
00232 // Returns:             -
00233 // Changes Globals:     -
00234 //===========================================================================
00235 void Com_Memcpy (void* dest, const void* src, const size_t count) {
00236     memcpy(dest, src, count);
00237 }
00238 //===========================================================================
00239 //
00240 // Parameter:               -
00241 // Returns:                 -
00242 // Changes Globals:     -
00243 //===========================================================================
00244 void AAS_InitBotImport(void)
00245 {
00246     botimport.BSPEntityData = BotImport_BSPEntityData;
00247     botimport.GetMemory = BotImport_GetMemory;
00248     botimport.FreeMemory = FreeMemory;
00249     botimport.Trace = BotImport_Trace;
00250     botimport.PointContents = BotImport_PointContents;
00251     botimport.Print = BotImport_Print;
00252     botimport.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
00253 } //end of the function AAS_InitBotImport
00254 //===========================================================================
00255 //
00256 // Parameter:               -
00257 // Returns:                 -
00258 // Changes Globals:     -
00259 //===========================================================================
00260 void AAS_CalcReachAndClusters(struct quakefile_s *qf)
00261 {
00262     float time;
00263 
00264     Log_Print("loading collision map...\n");
00265     //
00266     if (!qf->pakfile[0]) strcpy(qf->pakfile, qf->filename);
00267     //load the map
00268     CM_LoadMap((char *) qf, qfalse, &aasworld.bspchecksum);
00269     //get a handle to the world model
00270     worldmodel = CM_InlineModel(0);     // 0 = world, 1 + are bmodels
00271     //initialize bot import structure
00272     AAS_InitBotImport();
00273     //load the BSP entity string
00274     AAS_LoadBSPFile();
00275     //init physics settings
00276     AAS_InitSettings();
00277     //initialize AAS link heap
00278     AAS_InitAASLinkHeap();
00279     //initialize the AAS linked entities for the new map
00280     AAS_InitAASLinkedEntities();
00281     //reset all reachabilities and clusters
00282     aasworld.reachabilitysize = 0;
00283     aasworld.numclusters = 0;
00284     //set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach)
00285     AAS_SetViewPortalsAsClusterPortals();
00286     //calculate reachabilities
00287     AAS_InitReachability();
00288     time = 0;
00289     while(AAS_ContinueInitReachability(time)) time++;
00290     //calculate clusters
00291     AAS_InitClustering();
00292 } //end of the function AAS_CalcReachAndClusters

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