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

be_aas_sample.c File Reference

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_libvar.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_interface.h"
#include "be_aas_funcs.h"
#include "be_aas_def.h"

Include dependency graph for be_aas_sample.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  aas_linkstack_t
struct  aas_tracestack_s

Defines

#define AAS_BoxOnPlaneSide(absmins, absmaxs, p)
#define AAS_OrthogonalToVectors(v1, v2, res)
#define BBOX_NORMAL_EPSILON   0.001
#define ON_EPSILON   0
#define TRACEPLANE_EPSILON   0.125

Typedefs

typedef aas_tracestack_s aas_tracestack_t

Functions

aas_link_tAAS_AASLinkEntity (vec3_t absmins, vec3_t absmaxs, int entnum)
aas_link_tAAS_AllocAASLink (void)
int AAS_AreaCluster (int areanum)
qboolean AAS_AreaEntityCollision (int areanum, vec3_t start, vec3_t end, int presencetype, int passent, aas_trace_t *trace)
aas_face_tAAS_AreaGroundFace (int areanum, vec3_t point)
int AAS_AreaInfo (int areanum, aas_areainfo_t *info)
int AAS_AreaPresenceType (int areanum)
int AAS_BBoxAreas (vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas)
int AAS_BoxOnPlaneSide2 (vec3_t absmins, vec3_t absmaxs, aas_plane_t *p)
vec_t AAS_BoxOriginDistanceFromPlane (vec3_t normal, vec3_t mins, vec3_t maxs, int side)
void AAS_DeAllocAASLink (aas_link_t *link)
void AAS_FacePlane (int facenum, vec3_t normal, float *dist)
void AAS_FreeAASLinkedEntities (void)
void AAS_FreeAASLinkHeap (void)
void AAS_InitAASLinkedEntities (void)
void AAS_InitAASLinkHeap (void)
qboolean AAS_InsideFace (aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon)
aas_link_tAAS_LinkEntityClientBBox (vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype)
aas_plane_tAAS_PlaneFromNum (int planenum)
int AAS_PointAreaNum (vec3_t point)
qboolean AAS_PointInsideFace (int facenum, vec3_t point, float epsilon)
int AAS_PointPresenceType (vec3_t point)
int AAS_PointReachabilityAreaIndex (vec3_t origin)
void AAS_PresenceTypeBoundingBox (int presencetype, vec3_t mins, vec3_t maxs)
int AAS_TraceAreas (vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas)
aas_trace_t AAS_TraceClientBBox (vec3_t start, vec3_t end, int presencetype, int passent)
aas_face_tAAS_TraceEndFace (aas_trace_t *trace)
void AAS_UnlinkFromAreas (aas_link_t *areas)

Variables

botlib_import_t botimport
int numaaslinks


Define Documentation

#define AAS_BoxOnPlaneSide absmins,
absmaxs,
p   ) 
 

Value:

(\
    ( (p)->type < 3) ?\
    (\
        ( (p)->dist <= (absmins)[(p)->type]) ?\
        (\
            1\
        )\
        :\
        (\
            ( (p)->dist >= (absmaxs)[(p)->type]) ?\
            (\
                2\
            )\
            :\
            (\
                3\
            )\
        )\
    )\
    :\
    (\
        AAS_BoxOnPlaneSide2((absmins), (absmaxs), (p))\
    )\
)

Definition at line 1161 of file be_aas_sample.c.

#define AAS_OrthogonalToVectors v1,
v2,
res   ) 
 

Value:

(res)[0] = ((v1)[1] * (v2)[2]) - ((v1)[2] * (v2)[1]);\
    (res)[1] = ((v1)[2] * (v2)[0]) - ((v1)[0] * (v2)[2]);\
    (res)[2] = ((v1)[0] * (v2)[1]) - ((v1)[1] * (v2)[0]);

Definition at line 913 of file be_aas_sample.c.

Referenced by AAS_InsideFace().

#define BBOX_NORMAL_EPSILON   0.001
 

Definition at line 51 of file be_aas_sample.c.

#define ON_EPSILON   0
 

Definition at line 53 of file be_aas_sample.c.

#define TRACEPLANE_EPSILON   0.125
 

Definition at line 55 of file be_aas_sample.c.


Typedef Documentation

typedef struct aas_tracestack_s aas_tracestack_t
 

Referenced by AAS_TraceAreas(), and AAS_TraceClientBBox().


Function Documentation

aas_link_t* AAS_AASLinkEntity vec3_t  absmins,
vec3_t  absmaxs,
int  entnum
 

Definition at line 1223 of file be_aas_sample.c.

References AAS_AllocAASLink(), AAS_BoxOnPlaneSide2(), aas_link_t, aas_node_t, aas_plane_t, aasworld, aas_s::arealinkedentities, aas_link_s::areanum, botimport, aas_node_s::children, aas_link_s::entnum, aas_s::loaded, aas_link_s::next_area, aas_link_s::next_ent, aas_linkstack_t::nodenum, aas_s::nodes, aas_node_s::planenum, aas_s::planes, aas_link_s::prev_area, aas_link_s::prev_ent, and PRT_ERROR.

Referenced by AAS_BBoxAreas(), and AAS_LinkEntityClientBBox().

01224 {
01225     int side, nodenum;
01226     aas_linkstack_t linkstack[128];
01227     aas_linkstack_t *lstack_p;
01228     aas_node_t *aasnode;
01229     aas_plane_t *plane;
01230     aas_link_t *link, *areas;
01231 
01232     if (!aasworld.loaded)
01233     {
01234         botimport.Print(PRT_ERROR, "AAS_LinkEntity: aas not loaded\n");
01235         return NULL;
01236     } //end if
01237 
01238     areas = NULL;
01239     //
01240     lstack_p = linkstack;
01241     //we start with the whole line on the stack
01242     //start with node 1 because node zero is a dummy used for solid leafs
01243     lstack_p->nodenum = 1;      //starting at the root of the tree
01244     lstack_p++;
01245     
01246     while (1)
01247     {
01248         //pop up the stack
01249         lstack_p--;
01250         //if the trace stack is empty (ended up with a piece of the
01251         //line to be traced in an area)
01252         if (lstack_p < linkstack) break;
01253         //number of the current node to test the line against
01254         nodenum = lstack_p->nodenum;
01255         //if it is an area
01256         if (nodenum < 0)
01257         {
01258             //NOTE: the entity might have already been linked into this area
01259             // because several node children can point to the same area
01260             for (link = aasworld.arealinkedentities[-nodenum]; link; link = link->next_ent)
01261             {
01262                 if (link->entnum == entnum) break;
01263             } //end for
01264             if (link) continue;
01265             //
01266             link = AAS_AllocAASLink();
01267             if (!link) return areas;
01268             link->entnum = entnum;
01269             link->areanum = -nodenum;
01270             //put the link into the double linked area list of the entity
01271             link->prev_area = NULL;
01272             link->next_area = areas;
01273             if (areas) areas->prev_area = link;
01274             areas = link;
01275             //put the link into the double linked entity list of the area
01276             link->prev_ent = NULL;
01277             link->next_ent = aasworld.arealinkedentities[-nodenum];
01278             if (aasworld.arealinkedentities[-nodenum])
01279                     aasworld.arealinkedentities[-nodenum]->prev_ent = link;
01280             aasworld.arealinkedentities[-nodenum] = link;
01281             //
01282             continue;
01283         } //end if
01284         //if solid leaf
01285         if (!nodenum) continue;
01286         //the node to test against
01287         aasnode = &aasworld.nodes[nodenum];
01288         //the current node plane
01289         plane = &aasworld.planes[aasnode->planenum];
01290         //get the side(s) the box is situated relative to the plane
01291         side = AAS_BoxOnPlaneSide2(absmins, absmaxs, plane);
01292         //if on the front side of the node
01293         if (side & 1)
01294         {
01295             lstack_p->nodenum = aasnode->children[0];
01296             lstack_p++;
01297         } //end if
01298         if (lstack_p >= &linkstack[127])
01299         {
01300             botimport.Print(PRT_ERROR, "AAS_LinkEntity: stack overflow\n");
01301             break;
01302         } //end if
01303         //if on the back side of the node
01304         if (side & 2)
01305         {
01306             lstack_p->nodenum = aasnode->children[1];
01307             lstack_p++;
01308         } //end if
01309         if (lstack_p >= &linkstack[127])
01310         {
01311             botimport.Print(PRT_ERROR, "AAS_LinkEntity: stack overflow\n");
01312             break;
01313         } //end if
01314     } //end while
01315     return areas;
01316 } //end of the function AAS_AASLinkEntity

Here is the call graph for this function:

aas_link_t* AAS_AllocAASLink void   ) 
 

Definition at line 146 of file be_aas_sample.c.

References aas_link_t, aasworld, botimport, aas_s::freelinks, aas_link_s::next_ent, numaaslinks, aas_link_s::prev_ent, and PRT_FATAL.

Referenced by AAS_AASLinkEntity().

00147 {
00148     aas_link_t *link;
00149 
00150     link = aasworld.freelinks;
00151     if (!link)
00152     {
00153 #ifndef BSPC
00154         if (bot_developer)
00155 #endif
00156         {
00157             botimport.Print(PRT_FATAL, "empty aas link heap\n");
00158         } //end if
00159         return NULL;
00160     } //end if
00161     if (aasworld.freelinks) aasworld.freelinks = aasworld.freelinks->next_ent;
00162     if (aasworld.freelinks) aasworld.freelinks->prev_ent = NULL;
00163     numaaslinks--;
00164     return link;
00165 } //end of the function AAS_AllocAASLink

int AAS_AreaCluster int  areanum  ) 
 

Definition at line 308 of file be_aas_sample.c.

References aasworld, aas_s::areasettings, botimport, aas_areasettings_s::cluster, aas_s::numareas, and PRT_ERROR.

Referenced by AAS_FloodAreas(), AAS_FloodAreas_r(), and BotExportTest().

00309 {
00310     if (areanum <= 0 || areanum >= aasworld.numareas)
00311     {
00312         botimport.Print(PRT_ERROR, "AAS_AreaCluster: invalid area number\n");
00313         return 0;
00314     } //end if
00315     return aasworld.areasettings[areanum].cluster;
00316 } //end of the function AAS_AreaCluster

qboolean AAS_AreaEntityCollision int  areanum,
vec3_t  start,
vec3_t  end,
int  presencetype,
int  passent,
aas_trace_t trace
 

Definition at line 406 of file be_aas_sample.c.

References AAS_EntityCollision(), aas_link_t, AAS_PresenceTypeBoundingBox(), aas_trace_t, aasworld, aas_trace_s::area, aas_s::arealinkedentities, bsp_trace_t, Com_Memset(), CONTENTS_PLAYERCLIP, CONTENTS_SOLID, aas_trace_s::endpos, bsp_trace_s::endpos, bsp_trace_s::ent, aas_trace_s::ent, aas_link_s::entnum, bsp_trace_s::fraction, aas_link_s::next_ent, aas_trace_s::planenum, qboolean, bsp_trace_s::startsolid, aas_trace_s::startsolid, vec3_t, and VectorCopy.

Referenced by AAS_TraceClientBBox().

00408 {
00409     int collision;
00410     vec3_t boxmins, boxmaxs;
00411     aas_link_t *link;
00412     bsp_trace_t bsptrace;
00413 
00414     AAS_PresenceTypeBoundingBox(presencetype, boxmins, boxmaxs);
00415 
00416     Com_Memset(&bsptrace, 0, sizeof(bsp_trace_t)); //make compiler happy
00417     //assume no collision
00418     bsptrace.fraction = 1;
00419     collision = qfalse;
00420     for (link = aasworld.arealinkedentities[areanum]; link; link = link->next_ent)
00421     {
00422         //ignore the pass entity
00423         if (link->entnum == passent) continue;
00424         //
00425         if (AAS_EntityCollision(link->entnum, start, boxmins, boxmaxs, end,
00426                                                 CONTENTS_SOLID|CONTENTS_PLAYERCLIP, &bsptrace))
00427         {
00428             collision = qtrue;
00429         } //end if
00430     } //end for
00431     if (collision)
00432     {
00433         trace->startsolid = bsptrace.startsolid;
00434         trace->ent = bsptrace.ent;
00435         VectorCopy(bsptrace.endpos, trace->endpos);
00436         trace->area = 0;
00437         trace->planenum = 0;
00438         return qtrue;
00439     } //end if
00440     return qfalse;
00441 } //end of the function AAS_AreaEntityCollision

Here is the call graph for this function:

aas_face_t* AAS_AreaGroundFace int  areanum,
vec3_t  point
 

Definition at line 1018 of file be_aas_sample.c.

References aas_area_t, aas_face_t, AAS_InsideFace(), aasworld, abs(), aas_s::areas, f, aas_face_s::faceflags, aas_s::faceindex, aas_s::faces, aas_area_s::firstface, i, aas_s::loaded, aas_plane_s::normal, aas_area_s::numfaces, aas_face_s::planenum, aas_s::planes, point, up, vec3_t, VectorCopy, and VectorNegate.

01019 {
01020     int i, facenum;
01021     vec3_t up = {0, 0, 1};
01022     vec3_t normal;
01023     aas_area_t *area;
01024     aas_face_t *face;
01025 
01026     if (!aasworld.loaded) return NULL;
01027 
01028     area = &aasworld.areas[areanum];
01029     for (i = 0; i < area->numfaces; i++)
01030     {
01031         facenum = aasworld.faceindex[area->firstface + i];
01032         face = &aasworld.faces[abs(facenum)];
01033         //if this is a ground face
01034         if (face->faceflags & FACE_GROUND)
01035         {
01036             //get the up or down normal
01037             if (aasworld.planes[face->planenum].normal[2] < 0) VectorNegate(up, normal);
01038             else VectorCopy(up, normal);
01039             //check if the point is in the face
01040             if (AAS_InsideFace(face, normal, point, 0.01f)) return face;
01041         } //end if
01042     } //end for
01043     return NULL;
01044 } //end of the function AAS_AreaGroundFace

Here is the call graph for this function:

int AAS_AreaInfo int  areanum,
aas_areainfo_t info
 

Definition at line 1363 of file be_aas_sample.c.

References aas_areainfo_t, aas_areasettings_t, aasworld, aas_areasettings_s::areaflags, aas_s::areas, aas_s::areasettings, botimport, aas_area_s::center, aas_areainfo_s::center, aas_areainfo_s::cluster, aas_areasettings_s::cluster, aas_areainfo_s::contents, aas_areasettings_s::contents, aas_areainfo_s::flags, aas_area_s::maxs, aas_areainfo_s::maxs, aas_area_s::mins, aas_areainfo_s::mins, aas_s::numareas, aas_areainfo_s::presencetype, aas_areasettings_s::presencetype, PRT_ERROR, and VectorCopy.

01364 {
01365     aas_areasettings_t *settings;
01366     if (!info)
01367         return 0;
01368     if (areanum <= 0 || areanum >= aasworld.numareas)
01369     {
01370         botimport.Print(PRT_ERROR, "AAS_AreaInfo: areanum %d out of range\n", areanum);
01371         return 0;
01372     } //end if
01373     settings = &aasworld.areasettings[areanum];
01374     info->cluster = settings->cluster;
01375     info->contents = settings->contents;
01376     info->flags = settings->areaflags;
01377     info->presencetype = settings->presencetype;
01378     VectorCopy(aasworld.areas[areanum].mins, info->mins);
01379     VectorCopy(aasworld.areas[areanum].maxs, info->maxs);
01380     VectorCopy(aasworld.areas[areanum].center, info->center);
01381     return sizeof(aas_areainfo_t);
01382 } //end of the function AAS_AreaInfo

int AAS_AreaPresenceType int  areanum  ) 
 

Definition at line 324 of file be_aas_sample.c.

References aasworld, aas_s::areasettings, botimport, aas_s::loaded, aas_s::numareas, aas_areasettings_s::presencetype, and PRT_ERROR.

Referenced by AAS_Reachability_Grapple(), and BotTravel_Walk().

00325 {
00326     if (!aasworld.loaded) return 0;
00327     if (areanum <= 0 || areanum >= aasworld.numareas)
00328     {
00329         botimport.Print(PRT_ERROR, "AAS_AreaPresenceType: invalid area number\n");
00330         return 0;
00331     } //end if
00332     return aasworld.areasettings[areanum].presencetype;
00333 } //end of the function AAS_AreaPresenceType

int AAS_BBoxAreas vec3_t  absmins,
vec3_t  absmaxs,
int *  areas,
int  maxareas
 

Definition at line 1340 of file be_aas_sample.c.

References AAS_AASLinkEntity(), aas_link_t, AAS_UnlinkFromAreas(), aas_link_s::areanum, and aas_link_s::next_area.

01341 {
01342     aas_link_t *linkedareas, *link;
01343     int num;
01344 
01345     linkedareas = AAS_AASLinkEntity(absmins, absmaxs, -1);
01346     num = 0;
01347     for (link = linkedareas; link; link = link->next_area)
01348     {
01349         areas[num] = link->areanum;
01350         num++;
01351         if (num >= maxareas)
01352             break;
01353     } //end for
01354     AAS_UnlinkFromAreas(linkedareas);
01355     return num;
01356 } //end of the function AAS_BBoxAreas

Here is the call graph for this function:

int AAS_BoxOnPlaneSide2 vec3_t  absmins,
vec3_t  absmaxs,
aas_plane_t p
 

Definition at line 1127 of file be_aas_sample.c.

References aas_plane_t, aas_plane_s::dist, DotProduct, i, aas_plane_s::normal, p, and vec3_t.

Referenced by AAS_AASLinkEntity().

01128 {
01129     int i, sides;
01130     float dist1, dist2;
01131     vec3_t corners[2];
01132 
01133     for (i = 0; i < 3; i++)
01134     {
01135         if (p->normal[i] < 0)
01136         {
01137             corners[0][i] = absmins[i];
01138             corners[1][i] = absmaxs[i];
01139         } //end if
01140         else
01141         {
01142             corners[1][i] = absmins[i];
01143             corners[0][i] = absmaxs[i];
01144         } //end else
01145     } //end for
01146     dist1 = DotProduct(p->normal, corners[0]) - p->dist;
01147     dist2 = DotProduct(p->normal, corners[1]) - p->dist;
01148     sides = 0;
01149     if (dist1 >= 0) sides = 1;
01150     if (dist2 < 0) sides |= 2;
01151 
01152     return sides;
01153 } //end of the function AAS_BoxOnPlaneSide2

vec_t AAS_BoxOriginDistanceFromPlane vec3_t  normal,
vec3_t  mins,
vec3_t  maxs,
int  side
 

Definition at line 366 of file be_aas_sample.c.

References DotProduct, i, v1, v2, vec3_t, vec_t, VectorCopy, and VectorInverse().

00367 {
00368     vec3_t v1, v2;
00369     int i;
00370 
00371     //swap maxs and mins when on the other side of the plane
00372     if (side)
00373     {
00374         //get a point of the box that would be one of the first
00375         //to collide with the plane
00376         for (i = 0; i < 3; i++)
00377         {
00378             if (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = maxs[i];
00379             else if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = mins[i];
00380             else v1[i] = 0;
00381         } //end for
00382     } //end if
00383     else
00384     {
00385         //get a point of the box that would be one of the first
00386         //to collide with the plane
00387         for (i = 0; i < 3; i++)
00388         {
00389             if (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = mins[i];
00390             else if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = maxs[i];
00391             else v1[i] = 0;
00392         } //end for
00393     } //end else
00394     //
00395     VectorCopy(normal, v2);
00396     VectorInverse(v2);
00397 //  VectorNegate(normal, v2);
00398     return DotProduct(v1, v2);
00399 } //end of the function AAS_BoxOriginDistanceFromPlane

Here is the call graph for this function:

void AAS_DeAllocAASLink aas_link_t link  ) 
 

Definition at line 172 of file be_aas_sample.c.

References aas_link_t, aasworld, aas_s::freelinks, aas_link_s::next_area, aas_link_s::next_ent, numaaslinks, aas_link_s::prev_area, and aas_link_s::prev_ent.

Referenced by AAS_UnlinkFromAreas().

00173 {
00174     if (aasworld.freelinks) aasworld.freelinks->prev_ent = link;
00175     link->prev_ent = NULL;
00176     link->next_ent = aasworld.freelinks;
00177     link->prev_area = NULL;
00178     link->next_area = NULL;
00179     aasworld.freelinks = link;
00180     numaaslinks++;
00181 } //end of the function AAS_DeAllocAASLink

void AAS_FacePlane int  facenum,
vec3_t  normal,
float *  dist
 

Definition at line 1052 of file be_aas_sample.c.

References aas_plane_t, aasworld, aas_plane_s::dist, aas_s::faces, aas_plane_s::normal, aas_face_s::planenum, aas_s::planes, and VectorCopy.

01053 {
01054     aas_plane_t *plane;
01055 
01056     plane = &aasworld.planes[aasworld.faces[facenum].planenum];
01057     VectorCopy(plane->normal, normal);
01058     *dist = plane->dist;
01059 } //end of the function AAS_FacePlane

void AAS_FreeAASLinkedEntities void   ) 
 

Definition at line 201 of file be_aas_sample.c.

References aasworld, aas_s::arealinkedentities, and FreeMemory().

Referenced by AAS_Shutdown().

00202 {
00203     if (aasworld.arealinkedentities) FreeMemory(aasworld.arealinkedentities);
00204     aasworld.arealinkedentities = NULL;
00205 } //end of the function AAS_InitAASLinkedEntities

Here is the call graph for this function:

void AAS_FreeAASLinkHeap void   ) 
 

Definition at line 134 of file be_aas_sample.c.

References aasworld, FreeMemory(), aas_s::linkheap, and aas_s::linkheapsize.

Referenced by AAS_Shutdown().

00135 {
00136     if (aasworld.linkheap) FreeMemory(aasworld.linkheap);
00137     aasworld.linkheap = NULL;
00138     aasworld.linkheapsize = 0;
00139 } //end of the function AAS_FreeAASLinkHeap

Here is the call graph for this function:

void AAS_InitAASLinkedEntities void   ) 
 

Definition at line 188 of file be_aas_sample.c.

References aas_link_t, aasworld, aas_s::arealinkedentities, FreeMemory(), GetClearedHunkMemory(), aas_s::loaded, and aas_s::numareas.

Referenced by AAS_CalcReachAndClusters(), and AAS_LoadMap().

00189 {
00190     if (!aasworld.loaded) return;
00191     if (aasworld.arealinkedentities) FreeMemory(aasworld.arealinkedentities);
00192     aasworld.arealinkedentities = (aas_link_t **) GetClearedHunkMemory(
00193                         aasworld.numareas * sizeof(aas_link_t *));
00194 } //end of the function AAS_InitAASLinkedEntities

Here is the call graph for this function:

void AAS_InitAASLinkHeap void   ) 
 

Definition at line 96 of file be_aas_sample.c.

References aas_link_t, aasworld, aas_s::freelinks, GetHunkMemory(), i, LibVarValue(), aas_s::linkheap, aas_s::linkheapsize, aas_link_s::next_ent, numaaslinks, and aas_link_s::prev_ent.

Referenced by AAS_CalcReachAndClusters(), and AAS_LoadMap().

00097 {
00098     int i, max_aaslinks;
00099 
00100     max_aaslinks = aasworld.linkheapsize;
00101     //if there's no link heap present
00102     if (!aasworld.linkheap)
00103     {
00104 #ifdef BSPC
00105         max_aaslinks = 6144;
00106 #else
00107         max_aaslinks = (int) LibVarValue("max_aaslinks", "6144");
00108 #endif
00109         if (max_aaslinks < 0) max_aaslinks = 0;
00110         aasworld.linkheapsize = max_aaslinks;
00111         aasworld.linkheap = (aas_link_t *) GetHunkMemory(max_aaslinks * sizeof(aas_link_t));
00112     } //end if
00113     //link the links on the heap
00114     aasworld.linkheap[0].prev_ent = NULL;
00115     aasworld.linkheap[0].next_ent = &aasworld.linkheap[1];
00116     for (i = 1; i < max_aaslinks-1; i++)
00117     {
00118         aasworld.linkheap[i].prev_ent = &aasworld.linkheap[i - 1];
00119         aasworld.linkheap[i].next_ent = &aasworld.linkheap[i + 1];
00120     } //end for
00121     aasworld.linkheap[max_aaslinks-1].prev_ent = &aasworld.linkheap[max_aaslinks-2];
00122     aasworld.linkheap[max_aaslinks-1].next_ent = NULL;
00123     //pointer to the first free link
00124     aasworld.freelinks = &aasworld.linkheap[0];
00125     //
00126     numaaslinks = max_aaslinks;
00127 } //end of the function AAS_InitAASLinkHeap

Here is the call graph for this function:

qboolean AAS_InsideFace aas_face_t face,
vec3_t  pnormal,
vec3_t  point,
float  epsilon
 

Definition at line 926 of file be_aas_sample.c.

References aas_edge_t, aas_face_t, AAS_OrthogonalToVectors, aasworld, abs(), botimport, DotProduct, aas_s::edgeindex, aas_s::edges, aas_face_s::firstedge, i, aas_s::loaded, aas_face_s::numedges, point, PRT_MESSAGE, qboolean, aas_edge_s::v, vec3_t, VectorCopy, VectorSubtract, and aas_s::vertexes.

Referenced by AAS_AreaGroundFace(), and AAS_TraceEndFace().

00927 {
00928     int i, firstvertex, edgenum;
00929     vec3_t v0;
00930     vec3_t edgevec, pointvec, sepnormal;
00931     aas_edge_t *edge;
00932 #ifdef AAS_SAMPLE_DEBUG
00933     int lastvertex = 0;
00934 #endif //AAS_SAMPLE_DEBUG
00935 
00936     if (!aasworld.loaded) return qfalse;
00937 
00938     for (i = 0; i < face->numedges; i++)
00939     {
00940         edgenum = aasworld.edgeindex[face->firstedge + i];
00941         edge = &aasworld.edges[abs(edgenum)];
00942         //get the first vertex of the edge
00943         firstvertex = edgenum < 0;
00944         VectorCopy(aasworld.vertexes[edge->v[firstvertex]], v0);
00945         //edge vector
00946         VectorSubtract(aasworld.vertexes[edge->v[!firstvertex]], v0, edgevec);
00947         //
00948 #ifdef AAS_SAMPLE_DEBUG
00949         if (lastvertex && lastvertex != edge->v[firstvertex])
00950         {
00951             botimport.Print(PRT_MESSAGE, "winding not counter clockwise\n");
00952         } //end if
00953         lastvertex = edge->v[!firstvertex];
00954 #endif //AAS_SAMPLE_DEBUG
00955         //vector from first edge point to point possible in face
00956         VectorSubtract(point, v0, pointvec);
00957         //get a vector pointing inside the face orthogonal to both the
00958         //edge vector and the normal vector of the plane the face is in
00959         //this vector defines a plane through the origin (first vertex of
00960         //edge) and through both the edge vector and the normal vector
00961         //of the plane
00962         AAS_OrthogonalToVectors(edgevec, pnormal, sepnormal);
00963         //check on wich side of the above plane the point is
00964         //this is done by checking the sign of the dot product of the
00965         //vector orthogonal vector from above and the vector from the
00966         //origin (first vertex of edge) to the point 
00967         //if the dotproduct is smaller than zero the point is outside the face
00968         if (DotProduct(pointvec, sepnormal) < -epsilon) return qfalse;
00969     } //end for
00970     return qtrue;
00971 } //end of the function AAS_InsideFace

Here is the call graph for this function:

aas_link_t* AAS_LinkEntityClientBBox vec3_t  absmins,
vec3_t  absmaxs,
int  entnum,
int  presencetype
 

Definition at line 1323 of file be_aas_sample.c.

References AAS_AASLinkEntity(), aas_link_t, AAS_PresenceTypeBoundingBox(), vec3_t, and VectorSubtract.

Referenced by AAS_BestReachableArea(), AAS_BestReachableFromJumpPadArea(), AAS_Reachability_JumpPad(), AAS_Reachability_Teleport(), and AAS_UpdateEntity().

01324 {
01325     vec3_t mins, maxs;
01326     vec3_t newabsmins, newabsmaxs;
01327 
01328     AAS_PresenceTypeBoundingBox(presencetype, mins, maxs);
01329     VectorSubtract(absmins, maxs, newabsmins);
01330     VectorSubtract(absmaxs, mins, newabsmaxs);
01331     //relink the entity
01332     return AAS_AASLinkEntity(newabsmins, newabsmaxs, entnum);
01333 } //end of the function AAS_LinkEntityClientBBox

Here is the call graph for this function:

aas_plane_t* AAS_PlaneFromNum int  planenum  ) 
 

Definition at line 1389 of file be_aas_sample.c.

References aas_plane_t, aasworld, aas_s::loaded, and aas_s::planes.

Referenced by AAS_ClientMovementPrediction(), and AAS_OnGround().

01390 {
01391     if (!aasworld.loaded) return 0;
01392 
01393     return &aasworld.planes[planenum];
01394 } //end of the function AAS_PlaneFromNum

int AAS_PointAreaNum vec3_t  point  ) 
 

Definition at line 213 of file be_aas_sample.c.

References aas_node_t, aas_plane_t, aasworld, botimport, aas_node_s::children, aas_plane_s::dist, DotProduct, aas_s::loaded, aas_s::nodes, aas_plane_s::normal, aas_s::numnodes, aas_s::numplanes, aas_node_s::planenum, aas_s::planes, point, PRT_ERROR, PRT_MESSAGE, and vec_t.

Referenced by AAS_AgainstLadder(), AAS_BestReachableArea(), AAS_ClientMovementPrediction(), AAS_FloodAreas(), AAS_NearbySolidOrGap(), AAS_PointPresenceType(), AAS_PointReachabilityAreaIndex(), AAS_RandomGoalArea(), AAS_Reachability_Elevator(), AAS_Reachability_FuncBobbing(), AAS_Reachability_Grapple(), AAS_Reachability_Ladder(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_Teleport(), AAS_Reachability_WalkOffLedge(), AAS_Reachability_WeaponJump(), BotFuzzyPointReachabilityArea(), BotInitInfoEntities(), BotTravel_Grapple(), and BotTravel_Jump().

00214 {
00215     int nodenum;
00216     vec_t   dist;
00217     aas_node_t *node;
00218     aas_plane_t *plane;
00219 
00220     if (!aasworld.loaded)
00221     {
00222         botimport.Print(PRT_ERROR, "AAS_PointAreaNum: aas not loaded\n");
00223         return 0;
00224     } //end if
00225 
00226     //start with node 1 because node zero is a dummy used for solid leafs
00227     nodenum = 1;
00228     while (nodenum > 0)
00229     {
00230 //      botimport.Print(PRT_MESSAGE, "[%d]", nodenum);
00231 #ifdef AAS_SAMPLE_DEBUG
00232         if (nodenum >= aasworld.numnodes)
00233         {
00234             botimport.Print(PRT_ERROR, "nodenum = %d >= aasworld.numnodes = %d\n", nodenum, aasworld.numnodes);
00235             return 0;
00236         } //end if
00237 #endif //AAS_SAMPLE_DEBUG
00238         node = &aasworld.nodes[nodenum];
00239 #ifdef AAS_SAMPLE_DEBUG
00240         if (node->planenum < 0 || node->planenum >= aasworld.numplanes)
00241         {
00242             botimport.Print(PRT_ERROR, "node->planenum = %d >= aasworld.numplanes = %d\n", node->planenum, aasworld.numplanes);
00243             return 0;
00244         } //end if
00245 #endif //AAS_SAMPLE_DEBUG
00246         plane = &aasworld.planes[node->planenum];
00247         dist = DotProduct(point, plane->normal) - plane->dist;
00248         if (dist > 0) nodenum = node->children[0];
00249         else nodenum = node->children[1];
00250     } //end while
00251     if (!nodenum)
00252     {
00253 #ifdef AAS_SAMPLE_DEBUG
00254         botimport.Print(PRT_MESSAGE, "in solid\n");
00255 #endif //AAS_SAMPLE_DEBUG
00256         return 0;
00257     } //end if
00258     return -nodenum;
00259 } //end of the function AAS_PointAreaNum

qboolean AAS_PointInsideFace int  facenum,
vec3_t  point,
float  epsilon
 

Definition at line 978 of file be_aas_sample.c.

References aas_edge_t, aas_face_t, aas_plane_t, aasworld, abs(), CrossProduct(), DotProduct, aas_s::edgeindex, aas_s::edges, aas_s::faces, aas_face_s::firstedge, i, aas_s::loaded, aas_plane_s::normal, aas_face_s::numedges, aas_face_s::planenum, aas_s::planes, point, qboolean, aas_edge_s::v, v1, v2, vec3_t, vec_t, VectorSubtract, and aas_s::vertexes.

Referenced by AAS_AgainstLadder(), and AAS_FindFaceReachabilities().

00979 {
00980     int i, firstvertex, edgenum;
00981     vec_t *v1, *v2;
00982     vec3_t edgevec, pointvec, sepnormal;
00983     aas_edge_t *edge;
00984     aas_plane_t *plane;
00985     aas_face_t *face;
00986 
00987     if (!aasworld.loaded) return qfalse;
00988 
00989     face = &aasworld.faces[facenum];
00990     plane = &aasworld.planes[face->planenum];
00991     //
00992     for (i = 0; i < face->numedges; i++)
00993     {
00994         edgenum = aasworld.edgeindex[face->firstedge + i];
00995         edge = &aasworld.edges[abs(edgenum)];
00996         //get the first vertex of the edge
00997         firstvertex = edgenum < 0;
00998         v1 = aasworld.vertexes[edge->v[firstvertex]];
00999         v2 = aasworld.