Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

track.h File Reference

#include "genesis.h"
#include "bit.h"
#include "genvsi.h"

Go to the source code of this file.

Compounds

struct  Track
struct  TrackCB
struct  TrackData
struct  TrackPt

Defines

#define MAX_TRACKS   100
#define MAX_TRACK_POINTS   30
#define MAX_TRACK_VIS   20
#define TRACK_TYPE_UP   1
#define TRACK_TYPE_DOWN   2
#define TRACK_TYPE_ELEVATOR_UP   3
#define TRACK_TYPE_ELEVATOR_DOWN   4
#define TRACK_TYPE_MOVING_PLAT   5
#define TRACK_TYPE_SCAN   6
#define TRACK_TYPE_HIDE   7
#define TRACK_TYPE_EXIT   8
#define TRACK_TYPE_SCAN_HEALTH   9
#define TRACK_TYPE_TRAVERSE   10
#define TRACK_TYPE_SCAN_LOOP   11
#define TRACK_TYPE_SCAN_WEAPON_AMMO   12
#define TRACK_TYPE_TRAVERSE_DOOR   13
#define TRACK_TYPE_TRAVERSE_ONEWAY   14
#define TRACK_FLAG_LOOP   BIT(0)
#define POINT_TYPE_JUMP   1
#define POINT_TYPE_WAIT_POINT_DIST   2
#define POINT_TYPE_ROCKET_JUMP   3
#define POINT_TYPE_WAIT_FOR_PLAYER   4
#define POINT_TYPE_WAIT_POINT_VISIBLE   5
#define POINT_TYPE_LOOK_FOR_ITEMS   6
#define POINT_TYPE_BLASTER_JUMP   7
#define POINT_TYPE_SHOOT_BLASTER   20
#define POINT_TYPE_SHOOT_GRENADE   21
#define POINT_TYPE_SHOOT_ROCKET   22
#define POINT_TYPE_SHOOT_SHREDDER   23

Typedefs

typedef Track Track
typedef TrackCB TrackCB

Functions

geBoolean Track_OnTrack (TrackData *td)
void Track_ClearTrack (TrackData *td)
TrackTrack_GetTrack (TrackData *td)
int32 Track_GetDir (TrackData *td)
geBoolean Track_PastStartPoint (TrackData *td)
TrackPtTrack_NextPoint (TrackData *td)
TrackPtTrack_PrevPoint (TrackData *td)
TrackPtTrack_GetPoint (TrackData *td)
float Track_Length (Track *t)
TrackPtTrack_GetEndPoint (TrackData *td)
TrackPtTrack_GetFirstPoint (TrackData *td)
geBoolean Track_IsOneWay (Track *t)
TrackTrack_FindTrack (GenVSI *VSI, geVec3d *StartPos, geVec3d *TgtPos, int32 player_dir, int32 *track_type, TrackData *td)
TrackTrack_FindFarTrack (GenVSI *VSI, geVec3d *StartPos)
geBoolean Track_FindMultiTrack (GenVSI *VSI, geVec3d *StartPos, geVec3d *EndPos, int32 dir, TrackCB *, Stack *nodestack)
geBoolean Track_NextMultiTrack (GenVSI *VSI, geVec3d *StartPos, int32 TrackNdx, TrackData *td)
void Track_LinkTracks (geWorld *World)
TrackTrack_GetNextTrack (Track *t)

Variables

int32 TrackCount
Track TrackList []


Define Documentation

#define MAX_TRACK_POINTS   30
 

Definition at line 12 of file track.h.

Referenced by PathPt_Startup().

#define MAX_TRACK_VIS   20
 

Definition at line 13 of file track.h.

Referenced by Track_LinkExists(), and Track_LinkSet().

#define MAX_TRACKS   100
 

Definition at line 11 of file track.h.

Referenced by PathPt_Reset(), PathPt_Startup(), StackInit(), Track_FakeTrack(), and Track_FindMultiTrack().

#define POINT_TYPE_BLASTER_JUMP   7
 

Definition at line 107 of file track.h.

Referenced by Bot_TrackAction().

#define POINT_TYPE_JUMP   1
 

Definition at line 101 of file track.h.

Referenced by Bot_TrackAction().

#define POINT_TYPE_LOOK_FOR_ITEMS   6
 

Definition at line 106 of file track.h.

Referenced by Bot_TrackAction(), Bot_ValidateMultiTrackPoints(), and Bot_ValidateTrackPoints().

#define POINT_TYPE_ROCKET_JUMP   3
 

Definition at line 103 of file track.h.

Referenced by Bot_TrackAction(), Bot_ValidateMultiTrackPoints(), and Bot_ValidateTrackPoints().

#define POINT_TYPE_SHOOT_BLASTER   20
 

Definition at line 109 of file track.h.

Referenced by Bot_TrackAction(), and Bot_ValidateTrackPoints().

#define POINT_TYPE_SHOOT_GRENADE   21
 

Definition at line 110 of file track.h.

Referenced by Bot_TrackAction(), and Bot_ValidateTrackPoints().

#define POINT_TYPE_SHOOT_ROCKET   22
 

Definition at line 111 of file track.h.

Referenced by Bot_TrackAction(), and Bot_ValidateTrackPoints().

#define POINT_TYPE_SHOOT_SHREDDER   23
 

Definition at line 112 of file track.h.

Referenced by Bot_TrackAction(), and Bot_ValidateTrackPoints().

#define POINT_TYPE_WAIT_FOR_PLAYER   4
 

Definition at line 104 of file track.h.

Referenced by Bot_TrackAction(), and Bot_ValidateMultiTrackPoints().

#define POINT_TYPE_WAIT_POINT_DIST   2
 

Definition at line 102 of file track.h.

Referenced by Bot_TrackAction().

#define POINT_TYPE_WAIT_POINT_VISIBLE   5
 

Definition at line 105 of file track.h.

Referenced by Bot_MoveToPoint(), Bot_TrackAction(), Bot_ValidateTrackPoints(), and PathPt_Startup().

#define TRACK_FLAG_LOOP   BIT(0)
 

Definition at line 95 of file track.h.

Referenced by Track_NextPoint(), and Track_PrevPoint().

#define TRACK_TYPE_DOWN   2
 

Definition at line 81 of file track.h.

Referenced by Bot_FindTrackToGoal(), and Track_IsOneWay().

#define TRACK_TYPE_ELEVATOR_DOWN   4
 

Definition at line 83 of file track.h.

Referenced by Bot_FindTrackToGoal(), and Track_IsOneWay().

#define TRACK_TYPE_ELEVATOR_UP   3
 

Definition at line 82 of file track.h.

Referenced by Bot_FindTrackToGoal(), and Track_IsOneWay().

#define TRACK_TYPE_EXIT   8
 

Definition at line 87 of file track.h.

Referenced by Bot_FindTrackToGoal().

#define TRACK_TYPE_HIDE   7
 

Definition at line 86 of file track.h.

#define TRACK_TYPE_MOVING_PLAT   5
 

Definition at line 84 of file track.h.

#define TRACK_TYPE_SCAN   6
 

Definition at line 85 of file track.h.

Referenced by Track_IsOneWay().

#define TRACK_TYPE_SCAN_HEALTH   9
 

Definition at line 88 of file track.h.

#define TRACK_TYPE_SCAN_LOOP   11
 

Definition at line 90 of file track.h.

#define TRACK_TYPE_SCAN_WEAPON_AMMO   12
 

Definition at line 91 of file track.h.

#define TRACK_TYPE_TRAVERSE   10
 

Definition at line 89 of file track.h.

Referenced by Bot_FindTrackToGoal(), and Track_FindTrack().

#define TRACK_TYPE_TRAVERSE_DOOR   13
 

Definition at line 92 of file track.h.

Referenced by Bot_FindTrackToGoal(), Bot_WaitForEntityVisible(), and PathPt_Startup().

#define TRACK_TYPE_TRAVERSE_ONEWAY   14
 

Definition at line 93 of file track.h.

Referenced by Bot_FindTrackToGoal(), and Track_IsOneWay().

#define TRACK_TYPE_UP   1
 

Definition at line 80 of file track.h.

Referenced by Bot_FindTrackToGoal(), and Track_IsOneWay().


Typedef Documentation

typedef struct Track Track
 

Definition at line 15 of file track.h.

Referenced by GetCDPosition(), and ReadServerMessages().

typedef struct TrackCB TrackCB
 


Function Documentation

void Track_ClearTrack TrackData td  ) 
 

Definition at line 68 of file Track.c.

References TrackData::PointNdx, and TrackData::TrackNdx.

Referenced by Bot_ClearTrack(), Bot_FindTrack(), Bot_FindTrackToGoal(), Bot_FinishTrack(), and Track_FindTrack().

00069 {
00070     td->TrackNdx = -1;
00071     td->PointNdx = -1;
00072 }

Track* Track_FindFarTrack GenVSI VSI,
geVec3d StartPos
 

Definition at line 927 of file Track.c.

References Bot_CanSeePointToPoint(), GE_FALSE, GE_TRUE, geBoolean, GenVSI_GetWorld(), geVec3d_DistanceBetween(), int32, NULL, TrackPt::Pos, t, Track_IsOneWay(), TrackCount, and TrackList.

Referenced by Track_FindMultiTrack().

00928     {
00929                 float far_dist = 0.0f;
00930                 
00931                 int32 end_point[2] = {0,0};
00932                 
00933                 Track *t, *far_track;
00934                 //TrackPt *tp;
00935                 
00936                 TrackPt *stp;
00937                 float bot2start_dist;
00938                 int32 dir = 1;
00939                 
00940                 geBoolean OneWay = GE_FALSE;
00941                 geBoolean found = GE_FALSE;
00942                 
00943                 int32 StartTrack = 0;
00944                 
00945                 geWorld                 *World;
00946                 
00947                 World = GenVSI_GetWorld(VSI);
00948                 assert(World);
00949                 
00950                 // look at all tracks finding the closest endpoint
00951                 for (t = &TrackList[StartTrack]; t < &TrackList[TrackCount]; t++)
00952         {
00953                         stp = t->PointList;
00954                         //end_point[1] = t->PointCount - 1;
00955                         
00956                         OneWay = Track_IsOneWay(t);
00957                         
00958                         bot2start_dist = geVec3d_DistanceBetween(StartPos, stp->Pos);
00959                         
00960                         if (bot2start_dist < far_dist)
00961                                 continue;
00962                         
00963                         if (Bot_CanSeePointToPoint(World, StartPos, stp->Pos))
00964                 continue;
00965                         
00966                         found = GE_TRUE;
00967                         far_dist = bot2start_dist;
00968                         far_track = t;
00969                 }
00970                 
00971                 if (found)
00972             {
00973                         return (far_track);
00974             }
00975                 
00976                 return (NULL);
00977     }

geBoolean Track_FindMultiTrack GenVSI VSI,
geVec3d StartPos,
geVec3d EndPos,
int32  dir,
TrackCB ,
Stack nodestack
 

Definition at line 1154 of file Track.c.

References bitarr, TrackCB::CB, TrackCB::Data, GE_FALSE, GE_TRUE, geBoolean, GenVSI_GetWorld(), int32, MAX_TRACKS, searchnode, searchparent, SET_BITARR, StackPush(), StackReset(), t, TEST_BITARR, Track_FakeTrack(), Track_FindCloseTrack(), Track_FindFarTrack(), TRACK_SEARCH_Y_RANGE, TrackCount, TrackList, and Track::Vis.

Referenced by Bot_InitFindMultiTrack(), and Bot_InitFindMultiTrackAway().

01155         {
01156         int32 endnode, startnode;
01157         int32 s_plc, s_end, i, j, k, nodenum;
01158         Track *t, *n;
01159         geWorld *World;
01160         geBoolean found = GE_FALSE;
01161         
01162         if (!TrackCount)
01163                 return GE_FALSE;
01164         
01165         World = GenVSI_GetWorld(VSI);
01166         assert(World);
01167         
01168         //start at the end for ease of traversing
01169         if (!Track_FakeTrack(World, StartPos))
01170                 return GE_FALSE;
01171 
01172         t = &TrackList[MAX_TRACKS];
01173         assert(t);
01174         startnode = t - TrackList;
01175 
01176         // early out
01177         if (!t->Vis[0])
01178                 return GE_FALSE;
01179 
01180     if (dir == -1)
01181             t = Track_FindFarTrack(VSI, EndPos);
01182     else
01183     if (dir == 1)
01184             t = Track_FindCloseTrack(VSI, EndPos, TRACK_SEARCH_Y_RANGE*1.5f);
01185 
01186         if (!t)
01187                 return GE_FALSE;
01188 
01189         endnode = t - TrackList;
01190         
01191         //clear bitsearch array
01192         memset(bitarr, 0, sizeof(bitarr));
01193         
01194         // Create a node
01195         searchnode[0] = startnode;
01196         searchparent[0] = -1;
01197         
01198         // startnode to searched
01199         SET_BITARR(bitarr,startnode);
01200         
01201         // search place and search end
01202         for(s_plc = 0, s_end = 1; s_plc < s_end; s_plc++)
01203         {
01204                 //loop through all nodes "visible" from this node
01205                 n = &TrackList[searchnode[s_plc]];
01206                 
01207                 for (i = 0; n->Vis[i]; i++)
01208                 {
01209                         nodenum = n->Vis[i] - &TrackList[0];
01210                         
01211                         // look at ALL nextsectors !!!!!! s_plc is parent
01212                         if (nodenum < 0) 
01213                                 continue;
01214                         
01215                         // only look at sector if its not been looked at before
01216                         if (!TEST_BITARR(bitarr,nodenum))
01217                         {
01218                                 // mark sector as searched
01219                                 SET_BITARR(bitarr,nodenum);
01220 
01221                                 if (!cb->CB(VSI, cb->Data, &TrackList[nodenum]))
01222                                         continue;
01223 
01224                                 // save off this sector at the END!!!!!
01225                                 searchnode[s_end] = nodenum;
01226                                 // save off the parent sector at the END!!!!!
01227                                 searchparent[s_end] = s_plc;
01228                                 // increment s_end (search end)
01229                                 s_end++;
01230                                 
01231                                 if (nodenum == endnode)
01232                                 {
01233                                         // FOUND -A- PATH!
01234                                         found = GE_TRUE;
01235 
01236                     // clear stack
01237                     StackReset(nodestack);
01238 
01239                     for(k = s_end-1, j=0; k >= 0; k = searchparent[k])
01240                                         {
01241                                                 if (searchnode[k] >= MAX_TRACKS)
01242                                                         continue;
01243 
01244                         StackPush(nodestack, searchnode[k]);
01245                         }
01246 
01247                                         goto finish;
01248                                 }
01249                         }
01250                 }
01251         }
01252 
01253 finish:
01254 
01255         // clean links to fake track
01256         for (t = &TrackList[0]; t < &TrackList[TrackCount]; t++)
01257     {
01258                 for (i = 0; t->Vis[i]; i++)
01259                         {
01260                         if (t->Vis[i] >= &TrackList[MAX_TRACKS])
01261                                 t->Vis[i] = 0;
01262                         }
01263         }
01264 
01265         return (found);
01266 
01267         }

Track* Track_FindTrack GenVSI VSI,
geVec3d StartPos,
geVec3d TgtPos,
int32  player_dir,
int32 track_type,
TrackData td
 

Definition at line 706 of file Track.c.

References AWAY_FROM_GOAL, Bot_CanSeePointToPoint(), DistWeightedY(), GE_FALSE, GE_TRUE, geBoolean, GenVSI_GetWorld(), geVec3d_DistanceBetween(), int32, NULL, TrackData::PointNdx, TrackPt::Pos, t, TEST, TOWARD_GOAL, Track_ClearTrack(), Track_IsOneWay(), Track_Length(), TRACK_SEARCH_Y_RANGE, TRACK_TYPE_TRAVERSE, TrackCount, TrackData::TrackDir, TrackList, TrackData::TrackNdx, type, and geVec3d::Y.

Referenced by Bot_FindTrack(), and Bot_FindTrackToGoal().

00707     {
00708     float near_dist = 999999.0f, ydiff;
00709 
00710     int32 end_point[2] = {0,0};
00711     int32 near_dir;
00712 
00713     Track *t, *near_track;
00714     TrackPt *tp, *near_tp;
00715 
00716         TrackPt *stp,*etp;
00717         float start2tgt_dist, dist0, dist1, bot2start_dist, bot2end_dist, end2tgt_dist, bot2tgt_dist, total_dist2end;
00718         int32 dir = 1;
00719         int32 *type;
00720 
00721         geBoolean OneWay = GE_FALSE;
00722         geBoolean found = GE_FALSE;
00723         static StartTrack = 0;
00724 
00725         geWorld                 *World;
00726 
00727         World = GenVSI_GetWorld(VSI);
00728         assert(World);
00729 
00730         if (td->TrackNdx <= -1)
00731         {
00732                 StartTrack = 0;
00733         }
00734         else
00735         {
00736                 StartTrack = td->TrackNdx+1;
00737         }
00738         
00739         Track_ClearTrack(td);
00740 
00741     // look at all tracks finding the closest endpoint
00742     for (t = &TrackList[StartTrack]; t < &TrackList[TrackCount]; t++)
00743         {
00744         tp = t->PointList;
00745 
00746         // Skip if is not the track type we are looking for
00747                 if (track_type)
00748                 {
00749                         type = track_type;
00750         
00751                         while (*type != -1)
00752                         {
00753                                 if (t->Type == *type)
00754                                         break;
00755                                 type++;
00756                         }
00757                         
00758                         if (*type <= -1)
00759                                 continue;
00760                 }
00761 
00762                 end_point[1] = t->PointCount - 1;
00763 
00764         #if 0
00765         // Skip if already someone on this track
00766         if (TEST(t->flags, TF_TRACK_OCCUPIED))
00767             continue;
00768         #endif
00769 
00770                 OneWay = Track_IsOneWay(t);
00771 
00772         ydiff = TRACK_SEARCH_Y_RANGE;
00773 
00774                 dist0 = geVec3d_DistanceBetween(StartPos, t->PointList[end_point[0]].Pos);
00775                 dist1 = geVec3d_DistanceBetween(StartPos, t->PointList[end_point[1]].Pos);
00776 
00777                 if (t->Type == TRACK_TYPE_TRAVERSE)
00778                 {
00779                         // find the closest point to the dest on the track
00780                         TrackPt *tp;
00781                         float save_start_dist = 999999.0f, 
00782                                   save_end_dist = 999999.0f, dist;
00783 
00784                         // don't bother if Start and Tgt are already close
00785                         //if (geVec3d_DistanceBetween(TgtPos, StartPos) < 900)
00786                         //      continue;
00787 
00788                         // find closest points to Start and Tgt Positions
00789                         for (tp = t->PointList; tp < &t->PointList[t->PointCount]; tp++)
00790                         {
00791                                 dist = geVec3d_DistanceBetween(tp->Pos, StartPos);
00792 
00793                                 if (dist < save_start_dist)
00794                                 {
00795                                         stp = tp;
00796                                         save_start_dist = dist;
00797                                 }
00798 
00799                                 dist = geVec3d_DistanceBetween(tp->Pos, TgtPos);
00800 
00801                                 if (dist < save_end_dist)
00802                                 {
00803                                         etp = tp;
00804                                         save_end_dist = dist;
00805                                 }
00806                         }
00807 
00808                         if (stp == etp)
00809                                 continue;
00810 
00811                         // compare pointer locations to see if tgt is past start point
00812                         if (etp > stp)
00813                                 dir = 1; // towards end
00814                         else
00815                                 dir = -1; // towards start
00816                 }
00817                 else
00818                 if (dist0 <= dist1)
00819                 {
00820                         stp = &t->PointList[end_point[0]];
00821                         etp = &t->PointList[end_point[1]];
00822                         dir = 1;
00823 
00824                 }
00825                 else
00826                 {
00827                         if (OneWay)
00828                                 continue;
00829 
00830                         stp = &t->PointList[end_point[1]];
00831                         etp = &t->PointList[end_point[0]];
00832                         dir = -1;
00833                 }
00834 
00835         if (player_dir == TOWARD_GOAL)
00836                         {
00837                         // early out! - tgtpos is exactly the endpoint
00838                         if (memcmp(TgtPos, etp->Pos, sizeof(*TgtPos)) == 0)
00839                                 {
00840                                 near_track = t;
00841                                 near_tp = stp;
00842                                 near_dir = dir;
00843                                 found = GE_TRUE;
00844                                 break;
00845                                 }
00846                         }
00847 
00848         bot2start_dist = geVec3d_DistanceBetween(StartPos, stp->Pos);
00849                 bot2end_dist = geVec3d_DistanceBetween(StartPos, etp->Pos);
00850 
00851         if (bot2start_dist > 1500.0f)
00852                         continue;
00853 
00854         if (bot2start_dist > near_dist)
00855                         continue;
00856 
00857         if (fabs(StartPos->Y - stp->Pos->Y) > ydiff)
00858             continue;
00859 
00860                 // approx total dist to travel - not really used yet but good to have
00861                 total_dist2end = bot2start_dist + Track_Length(t);
00862 
00863         start2tgt_dist = geVec3d_DistanceBetween(stp->Pos, TgtPos);
00864                 end2tgt_dist = geVec3d_DistanceBetween(etp->Pos, TgtPos);
00865 
00866         if (player_dir == TOWARD_GOAL)
00867                 {
00868                         // if the end point is farther than the start point - skip it
00869                         if (end2tgt_dist > start2tgt_dist)
00870                                 continue;
00871 
00872             end2tgt_dist = DistWeightedY(etp->Pos, TgtPos, 2.0f);
00873                     bot2tgt_dist = DistWeightedY(StartPos, TgtPos, 2.0f);
00874 
00875                         // if it does not get you closer - skip it
00876                         if (end2tgt_dist > bot2tgt_dist)
00877                                 continue;
00878                 }
00879                 else
00880                 if (player_dir == AWAY_FROM_GOAL)
00881                 {
00882                         // if the end point is closer than the start point - skip it
00883                         if (end2tgt_dist < start2tgt_dist)
00884                                 continue;
00885 
00886             end2tgt_dist = DistWeightedY(etp->Pos, TgtPos, 2.0f);
00887                     bot2tgt_dist = DistWeightedY(StartPos, TgtPos, 2.0f);
00888 
00889                         // if it does not get you further then skip it
00890                         if (end2tgt_dist < bot2tgt_dist)
00891                                 continue;
00892                 }
00893 
00894         if (!Bot_CanSeePointToPoint(World, StartPos, stp->Pos))
00895                         continue;
00896                 
00897                 // end up on approx the same Y level]
00898                 // not really working for some reason
00899         //if (fabs(TgtPos->Y - etp->Pos->Y) > ydiff*2)
00900         //    continue;
00901 
00902                 found = GE_TRUE;
00903         near_dist = bot2start_dist;
00904         near_track = t;
00905         near_tp = stp;
00906                 near_dir = dir;
00907         }
00908 
00909     if (found)
00910         {
00911         // if can see the point, return the track number
00912         td->TrackNdx = near_track - &TrackList[0];
00913         td->PointNdx = near_tp - &TrackList[td->TrackNdx].PointList[0];
00914         td->TrackDir = near_dir;
00915         return (near_track);
00916         }
00917     else
00918         {
00919         Track_ClearTrack(td);
00920         return (NULL);
00921         }
00922     }

int32 Track_GetDir TrackData td  ) 
 

Definition at line 85 of file Track.c.

References int32, and TrackData::TrackDir.

Referenced by Bot_TrackAction().

00086 {
00087         return td->TrackDir;
00088 }

TrackPt* Track_GetEndPoint TrackData td  ) 
 

Definition at line 223 of file Track.c.

References t, Track_OnTrack(), TrackData::TrackDir, TrackList, and TrackData::TrackNdx.

00224 {
00225         Track *t = &TrackList[td->TrackNdx];
00226 
00227         assert(td);
00228     assert(Track_OnTrack(td));
00229 
00230         if (td->TrackDir == 1)
00231                 return(&t->PointList[t->PointCount-1]);
00232         else
00233                 return(&t->PointList[0]);
00234 }

TrackPt* Track_GetFirstPoint TrackData td  ) 
 

Definition at line 239 of file Track.c.

References t, Track_OnTrack(), TrackData::TrackDir, TrackList, and TrackData::TrackNdx.

Referenced by Bot_ModeThinkLedge().

00240 {
00241         Track *t = &TrackList[td->TrackNdx];
00242 
00243         assert(td);
00244     assert(Track_OnTrack(td));
00245 
00246         if (td->TrackDir == -1)
00247                 return(&t->PointList[t->PointCount-1]);
00248         else
00249                 return(&t->PointList[0]);
00250 }

Track* Track_GetNextTrack Track t  ) 
 

Definition at line 48 of file Track.c.

References int32, NULL, t, TrackCount, and TrackList.

Referenced by Bot_FindRandomTrack().

00049 {
00050         int32 ndx;
00051 
00052         if (!t)
00053                 return(&TrackList[0]);
00054 
00055         ndx = t - &TrackList[0];
00056         assert(ndx >= 0 && ndx < TrackCount);
00057         ndx++;
00058 
00059         if (ndx >= TrackCount)
00060                 return NULL;
00061 
00062         return (&TrackList[ndx]);
00063 }

TrackPt* Track_GetPoint TrackData td  ) 
 

Definition at line 190 of file Track.c.

References Track::PointCount, Track::PointList, TrackData::PointNdx, Track_OnTrack(), TrackList, and TrackData::TrackNdx.

Referenced by Bot_ActionGetHealth(), Bot_ActionGetWeapon(), Bot_FinishTrack(), Bot_InitFindMultiTrack(), Bot_InitFindMultiTrackAway(), Bot_InitHide(), Bot_InitTrackAwayGoal(), Bot_InitTrackToGoal(), Bot_ModeThinkLedge(), Bot_ModeThinkOnTrack(), Bot_ModeThinkWanderGoal(), Bot_MoveToPoint(), Bot_ShootPoint(), Bot_WaitForEntityDist(), and Bot_WaitForEntityVisible().

00191     {
00192         assert(td);
00193 
00194     assert(Track_OnTrack(td));
00195 
00196     if (td->PointNdx >= TrackList[td->TrackNdx].PointCount)
00197         td = td;
00198 
00199     assert(td->PointNdx < TrackList[td->TrackNdx].PointCount);
00200 
00201         return &TrackList[td->TrackNdx].PointList[td->PointNdx];
00202     }

Track* Track_GetTrack TrackData td  ) 
 

Definition at line 77 of file Track.c.

References TrackList, and TrackData::TrackNdx.

Referenced by Bot_WaitForEntityVisible().

00078 {
00079         return &TrackList[td->TrackNdx];
00080 }

geBoolean Track_IsOneWay Track t  ) 
 

Definition at line 315 of file Track.c.

References GE_FALSE, GE_TRUE, geBoolean, t, TRACK_TYPE_DOWN, TRACK_TYPE_ELEVATOR_DOWN, TRACK_TYPE_ELEVATOR_UP, TRACK_TYPE_SCAN, TRACK_TYPE_TRAVERSE_ONEWAY, and TRACK_TYPE_UP.

Referenced by Track_FindCloseTrack(), Track_FindFarTrack(), Track_FindTrack(), Track_LinkTrack(), and Track_NextMultiTrack().

00316 {
00317     switch (t->Type)
00318         {
00319     // for ladders only look at first track point
00320         case TRACK_TYPE_ELEVATOR_UP:
00321         case TRACK_TYPE_ELEVATOR_DOWN:
00322     case TRACK_TYPE_UP:
00323     case TRACK_TYPE_DOWN:
00324     case TRACK_TYPE_SCAN:
00325     case TRACK_TYPE_TRAVERSE_ONEWAY:
00326             {
00327                         return GE_TRUE;
00328             }
00329                 }
00330 
00331         return GE_FALSE;
00332 }

float Track_Length Track t  ) 
 

Definition at line 207 of file Track.c.

References geVec3d_DistanceBetween(), TrackPt::Pos, and t.

Referenced by Track_FindTrack().

00208 {
00209         TrackPt *tp;
00210         float dist=0.0f;
00211 
00212     for (tp = t->PointList; tp < &t->PointList[t->PointCount-1]; tp++)
00213         {
00214                 dist += geVec3d_DistanceBetween(tp->Pos, (tp+1)->Pos);
00215         }
00216 
00217         return dist;
00218 }

void Track_LinkTracks geWorld World  ) 
 

Definition at line 653 of file Track.c.

References t, Track_LinkTrack(), TrackCount, and TrackList.

Referenced by PathPt_Startup().

00654     {
00655     Track *t, *t2;
00656         assert(World);
00657 
00658     // look at all tracks finding the closest endpoint
00659     for (t = &TrackList[0]; t < &TrackList[TrackCount]; t++)
00660         {
00661                 for (t2 = &TrackList[0]; t2 < &TrackList[TrackCount]; t2++)
00662                         {
00663             Track_LinkTrack(World, t, t2);
00664                         }
00665                 }
00666     }

geBoolean Track_NextMultiTrack GenVSI VSI,
geVec3d StartPos,
int32  TrackNdx,
TrackData td
 

Definition at line 1273 of file Track.c.

References Bot_CanSeePointToPoint(), GE_TRUE, geBoolean, GenVSI_GetWorld(), geVec3d_DistanceBetween(), int32, TrackData::PointNdx, TrackPt::Pos, t, Track_IsOneWay(), TrackData::TrackDir, TrackList, and TrackData::TrackNdx.

Referenced by Bot_FinishTrack(), Bot_InitFindMultiTrack(), and Bot_InitFindMultiTrackAway().

01274     {
01275         Track *t;
01276         TrackPt *tp, *ep;
01277         geWorld *World;
01278 
01279         geBoolean OneWay;
01280 
01281         int32 tpoint,dir;
01282         float dist2end,dist2start;
01283 
01284         assert(TrackNdx > -1);
01285 
01286         // look at all tracks finding the closest endpoint
01287         t = &TrackList[TrackNdx];
01288         tp = t->PointList;
01289         ep = &t->PointList[t->PointCount - 1];
01290         
01291         OneWay = Track_IsOneWay(t);
01292 
01293         if (OneWay)
01294                 {
01295                 td->TrackNdx = t - &TrackList[0];
01296                 td->PointNdx = 0;
01297                 td->TrackDir = 1;
01298                 return GE_TRUE;
01299                 }
01300 
01301         dist2start = geVec3d_DistanceBetween(StartPos, tp->Pos);
01302         dist2end = geVec3d_DistanceBetween(StartPos, ep->Pos);
01303 
01304         World = GenVSI_GetWorld(VSI);
01305 
01306         if (dist2start < dist2end)
01307         {
01308                 // try and see the closest point
01309                 if (Bot_CanSeePointToPoint(World, StartPos, tp->Pos))
01310                         {
01311                         dir = 1;
01312                         tpoint = 0;
01313                         }
01314                 else
01315                         {
01316                         dir = -1;
01317                         tpoint = t->PointCount - 1;
01318                         }
01319         }
01320         else
01321         {
01322                 // try and see the closest point
01323                 if (Bot_CanSeePointToPoint(World, StartPos, ep->Pos))
01324                         {
01325                         dir = -1;
01326                         tpoint = t->PointCount - 1;
01327                         }
01328                 else
01329                         {
01330                         dir = 1;
01331                         tpoint = 0;
01332                         }
01333         }
01334 
01335         td->TrackNdx = t - &TrackList[0];
01336         td->PointNdx = tpoint;
01337         td->TrackDir = dir;
01338 
01339         return GE_TRUE;
01340 }

TrackPt* Track_NextPoint TrackData td  ) 
 

Definition at line 114 of file Track.c.

References NULL, TrackData::PointNdx, TEST, TRACK_FLAG_LOOP, TrackData::TrackDir, TrackList, and TrackData::TrackNdx.

Referenced by Bot_MoveToPoint().

00115 {
00116         assert(td->TrackNdx > -1);
00117 
00118     td->PointNdx += td->TrackDir;
00119 
00120     if (td->PointNdx >= TrackList[td->TrackNdx].PointCount)
00121         {
00122         if (TEST(TrackList[td->TrackNdx].Flags, TRACK_FLAG_LOOP))
00123             {
00124             td->PointNdx = 0;
00125             return(&TrackList[td->TrackNdx].PointList[td->PointNdx]);
00126             }
00127 
00128 //              td->PointNdx >= TrackList[td->TrackNdx].PointCount-1;
00129         return(NULL);
00130         }
00131 
00132     if (td->PointNdx < 0)
00133         {
00134         if (TEST(TrackList[td->TrackNdx].Flags, TRACK_FLAG_LOOP))
00135             {
00136             td->PointNdx = TrackList[td->TrackNdx].PointCount - 1;
00137             return(&TrackList[td->TrackNdx].PointList[td->PointNdx]);
00138             }
00139 
00140                 td->PointNdx = 0;
00141         return(NULL);
00142         }
00143 
00144     assert(td->PointNdx < TrackList[td->TrackNdx].PointCount);
00145 
00146     return(&TrackList[td->TrackNdx].PointList[td->PointNdx]);
00147 }

geBoolean Track_OnTrack TrackData td  ) 
 

Definition at line 40 of file Track.c.

References geBoolean, and TrackData::TrackNdx.

Referenced by Bot_Control(), Bot_InitGenericMove(), Bot_ModeThinkLedge(), Bot_ModeThinkOnTrack(), Bot_ModeThinkWanderGoal(), Bot_MoveToPoint(), Bot_ShootPoint(), Bot_SuicideTest(), Bot_WaitForEntityDist(), Bot_WaitForEntityVisible(), Track_GetEndPoint(), Track_GetFirstPoint(), and Track_GetPoint().

00041 {
00042     return (td->TrackNdx >= 0);
00043 }

geBoolean Track_PastStartPoint TrackData td  ) 
 

Definition at line 93 of file Track.c.

References GE_FALSE, geBoolean, TrackData::PointNdx, TrackData::TrackDir, TrackList, and TrackData::TrackNdx.

00094 {
00095         assert(td->TrackNdx > -1);
00096 
00097         if (td->TrackDir == 1)
00098         {
00099                 return (td->PointNdx > 0);
00100         }
00101         else
00102         if (td->TrackDir == -1)
00103         {
00104                 return (td->PointNdx < TrackList[td->PointNdx].PointCount);
00105         }
00106 
00107         assert(1==0);
00108         return GE_FALSE;
00109 }

TrackPt* Track_PrevPoint TrackData td  ) 
 

Definition at line 153 of file Track.c.

References NULL, TrackData::PointNdx, TEST, TRACK_FLAG_LOOP, TrackData::TrackDir, TrackList, and TrackData::TrackNdx.

00154     {
00155         assert(td->TrackNdx > -1);
00156 
00157     td->PointNdx -= td->TrackDir;
00158 
00159     if (td->PointNdx >= TrackList[td->TrackNdx].PointCount)
00160         {
00161         if (TEST(TrackList[td->TrackNdx].Flags, TRACK_FLAG_LOOP))
00162             {
00163             td->PointNdx = 0;
00164             return(&TrackList[td->TrackNdx].PointList[td->PointNdx]);
00165             }
00166 
00167         return(NULL);
00168         }
00169 
00170     if (td->PointNdx < 0)
00171         {
00172         if (TEST(TrackList[td->TrackNdx].Flags, TRACK_FLAG_LOOP))
00173             {
00174             td->PointNdx = TrackList[td->TrackNdx].PointCount - 1;
00175             return(&TrackList[td->TrackNdx].PointList[td->PointNdx]);
00176             }
00177 
00178         return(NULL);
00179         }
00180 
00181     assert(td->PointNdx < TrackList[td->TrackNdx].PointCount);
00182 
00183     return(&TrackList[td->TrackNdx].PointList[td->PointNdx]);
00184     }


Variable Documentation

int32 TrackCount
 

Definition at line 54 of file track.h.

Referenced by PathPoint_Frame2(), PathPoint_Frame3(), PathPt_Reset(), PathPt_Startup(), Track_FakeTrack(), Track_FindCloseTrack(), Track_FindFarTrack(), Track_FindMultiTrack(), Track_FindTrack(), Track_GetNextTrack(), and Track_LinkTracks().

Track TrackList[]
 

Definition at line 55 of file track.h.

Referenced by PathPoint_Frame2(), PathPoint_Frame3(), PathPt_Reset(), PathPt_Startup(), Track_FakeTrack(), Track_FindCloseTrack(), Track_FindFarTrack(), Track_FindMultiTrack(), Track_FindTrack(), Track_GetEndPoint(), Track_GetFirstPoint(), Track_GetNextTrack(), Track_GetPoint(), Track_GetTrack(), Track_LinkTracks(), Track_NextMultiTrack(), Track_NextPoint(), Track_PastStartPoint(), and Track_PrevPoint().


Generated on Tue Sep 30 12:38:19 2003 for GTestAndEngine by doxygen 1.3.2