Go to the source code of this file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 11 of file g_nav.h. Referenced by NAV_AvoidCollision(), and NAVNEW_AvoidCollision(). |
|
|
Definition at line 20 of file g_nav.h. Referenced by waypoint_getRadius(). |
|
|
Definition at line 9 of file g_nav.h. Referenced by NAV_StoreWaypoint(). |
|
|
|
|
|
Definition at line 15 of file g_nav.h. Referenced by NPC_Blocked(), and NPC_SetBlocked(). |
|
|
|
|
|
Definition at line 17 of file g_nav.h. Referenced by NAV_CheckAhead(), NAV_ResolveEntityCollision(), NAV_TestBestNode(), and NAVNEW_ResolveEntityCollision(). |
|
|
Definition at line 14 of file g_nav.h. Referenced by NAV_TestForBlocked(). |
|
|
|
|
|
Definition at line 12 of file g_nav.h. Referenced by NAV_HitNavGoal(), and SP_waypoint_navgoal(). |
|
|
Definition at line 34 of file g_nav.h. Referenced by NAV_ShowDebugInfo(). |
|
|
Definition at line 36 of file g_nav.h. Referenced by NAV_FindClosestWaypointForEnt(), NAV_FindClosestWaypointForPoint(), NAV_FindClosestWaypointForPoint2(), NAV_FindPlayerWaypoint(), NAV_GetNearestNode(), NAVNEW_MoveToGoal(), NPC_SearchForWeapons(), and Svcmd_Nav_f(). |
|
|
|
|
|
|
|
|
Definition at line 45 of file g_nav.h. Referenced by NAV_MoveToGoal(), NAV_ShowDebugInfo(), NAVNEW_MoveToGoal(), NPC_FindCombatPoint(), and NPC_SearchForWeapons(). |
|
|
Definition at line 19 of file g_nav.h. Referenced by NAV_MoveBlocker(). |
|
|
Definition at line 18 of file g_nav.h. Referenced by NAV_MoveBlocker(). |
|
|
|
Definition at line 21 of file g_nav.h. Referenced by waypoint_getRadius(). |
|
||||||||||||
|
Definition at line 1734 of file g_nav.c. References Com_Printf(), fatalErrorPointer, fatalErrors, fatalErrorString, memset(), NAV_GetStoredWaypoint(), qfalse, trap_Nav_CheckBlockedEdges(), trap_Nav_HardConnect(), and trap_Nav_SetPathsCalculated(). Referenced by NAV_CheckCalcPaths().
01735 {
01736 int target = -1;
01737 int i;
01738
01739 if ( !tempWaypointList )
01740 {
01741 return;
01742 }
01743 #ifndef FINAL_BUILD
01744 fatalErrors = 0;
01745 memset( fatalErrorString, 0, sizeof( fatalErrorString ) );
01746 fatalErrorPointer = &fatalErrorString[0];
01747 #endif
01748 #if _HARD_CONNECT
01749
01750 //Find all connections and hard connect them
01751 for ( i = 0; i < numStoredWaypoints; i++ )
01752 {
01753 //Find the first connection
01754 target = NAV_GetStoredWaypoint( tempWaypointList[i].target );
01755
01756 if ( target != -1 )
01757 {
01758 #ifndef FINAL_BUILD
01759 // if ( !NAV_WaypointsTooFar( ent, target ) )
01760 #endif
01761 {
01762 trap_Nav_HardConnect( tempWaypointList[i].nodeID, tempWaypointList[target].nodeID );
01763 }
01764 }
01765
01766 //Find a possible second connection
01767 target = NAV_GetStoredWaypoint( tempWaypointList[i].target2 );
01768
01769 if ( target != -1 )
01770 {
01771 #ifndef FINAL_BUILD
01772 // if ( !NAV_WaypointsTooFar( ent, target ) )
01773 #endif
01774 {
01775 trap_Nav_HardConnect( tempWaypointList[i].nodeID, tempWaypointList[target].nodeID );
01776 }
01777 }
01778
01779 //Find a possible third connection
01780 target = NAV_GetStoredWaypoint( tempWaypointList[i].target3 );
01781
01782 if ( target != -1 )
01783 {
01784 #ifndef FINAL_BUILD
01785 // if ( !NAV_WaypointsTooFar( ent, target ) )
01786 #endif
01787 {
01788 trap_Nav_HardConnect( tempWaypointList[i].nodeID, tempWaypointList[target].nodeID );
01789 }
01790 }
01791
01792 //Find a possible fourth connection
01793 target = NAV_GetStoredWaypoint( tempWaypointList[i].target4 );
01794
01795 if ( target != -1 )
01796 {
01797 #ifndef FINAL_BUILD
01798 // if ( !NAV_WaypointsTooFar( ent, target ) )
01799 #endif
01800 {
01801 trap_Nav_HardConnect( tempWaypointList[i].nodeID, tempWaypointList[target].nodeID );
01802 }
01803 }
01804 }
01805
01806 #endif
01807
01808 //Remove all waypoints now that they're done
01809 //gi.Free(tempWaypointList);
01810 /*
01811 trap_TrueFree((void **)&tempWaypointList);
01812 tempWaypointList=0;
01813 */
01814
01815 //Now check all blocked edges, mark failed ones
01816 trap_Nav_CheckBlockedEdges();
01817
01818 trap_Nav_SetPathsCalculated(qfalse);
01819 //navigator.pathsCalculated = qfalse;
01820
01821 //Calculate the paths based on the supplied waypoints
01822 //trap_Nav_CalculatePaths();
01823
01824 //Save the resulting information
01825 /*
01826 if ( trap_Nav_Save( filename, checksum ) == qfalse )
01827 {
01828 Com_Printf("Unable to save navigations data for map \"%s\" (checksum:%d)\n", filename, checksum );
01829 }
01830 */
01831 #ifndef FINAL_BUILD
01832 if ( fatalErrors )
01833 {
01834 //Com_Error( ERR_DROP, "%s%d FATAL NAV ERRORS\n", fatalErrorString, fatalErrors );
01835 Com_Printf( "%s%d FATAL NAV ERRORS\n", fatalErrorString, fatalErrors );
01836 }
01837 #endif
01838 }
|
|
||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
|
Definition at line 1911 of file g_nav.c. References g_entities, NF_CLEAR_PATH, trap_Nav_GetNearestNode(), gentity_s::waypoint, and WAYPOINT_NONE. Referenced by G_RunFrame().
01912 {
01913 g_entities[clNum].waypoint = trap_Nav_GetNearestNode( &g_entities[clNum], g_entities[clNum].lastWaypoint, NF_CLEAR_PATH, WAYPOINT_NONE );
01914 }
|
|
||||||||||||
|
Definition at line 1083 of file g_nav.c.
01084 {
01085 return trap_Nav_GetNearestNode( self, lastNode, NF_CLEAR_PATH, WAYPOINT_NONE );
01086 }
|
|
|
Definition at line 1857 of file g_nav.c. References level_locals_t::combatPoints, G_DrawCombatPoint(), G_DrawNode(), g_entities, level, NAV_TestBestNode(), NAVDEBUG_curGoal, NAVDEBUG_showCombatPoints, NAVDEBUG_showEdges, NAVDEBUG_showNavGoals, NAVDEBUG_showNodes, NAVDEBUG_showTestPath, NF_ANY, NODE_GOAL, NODE_NONE, NODE_START, level_locals_t::numCombatPoints, combatPoint_t::origin, qfalse, RTF_NAVGOAL, TAG_ShowTags(), trap_Nav_GetBestNode(), trap_Nav_GetNearestNode(), trap_Nav_GetNodePosition(), trap_Nav_ShowEdges(), trap_Nav_ShowNodes(), trap_Nav_ShowPath(), vec3_t, and WAYPOINT_NONE.
01858 {
01859 int i;
01860
01861 if ( NAVDEBUG_showNodes )
01862 {
01863 trap_Nav_ShowNodes();
01864 }
01865
01866 if ( NAVDEBUG_showEdges )
01867 {
01868 trap_Nav_ShowEdges();
01869 }
01870
01871 if ( NAVDEBUG_showTestPath )
01872 {
01873 //Get the nearest node to the player
01874 int nearestNode = trap_Nav_GetNearestNode( &g_entities[0], g_entities[0].waypoint, NF_ANY, WAYPOINT_NONE );
01875 int testNode = trap_Nav_GetBestNode( nearestNode, NAVDEBUG_curGoal, NODE_NONE );
01876 vec3_t dest, start;
01877
01878 nearestNode = NAV_TestBestNode( &g_entities[0], nearestNode, testNode, qfalse );
01879
01880 //Show the connection
01881
01882 //Get the positions
01883 trap_Nav_GetNodePosition( NAVDEBUG_curGoal, dest );
01884 trap_Nav_GetNodePosition( nearestNode, start );
01885
01886 G_DrawNode( start, NODE_START );
01887 G_DrawNode( dest, NODE_GOAL );
01888 trap_Nav_ShowPath( nearestNode, NAVDEBUG_curGoal );
01889 }
01890
01891 if ( NAVDEBUG_showCombatPoints )
01892 {
01893 for ( i = 0; i < level.numCombatPoints; i++ )
01894 {
01895 G_DrawCombatPoint( level.combatPoints[i].origin, 0 );
01896 }
01897 }
01898
01899 if ( NAVDEBUG_showNavGoals )
01900 {
01901 TAG_ShowTags( RTF_NAVGOAL );
01902 }
01903 }
|
|
|
Definition at line 1846 of file g_nav.c. References trap_Nav_Free().
01847 {
01848 trap_Nav_Free();
01849 }
|
|
||||||||||||||||||||
|
Definition at line 971 of file g_nav.c. References trace_t::allsolid, gentity_s::classname, gentity_s::clipmask, entityShared_t::contents, trace_t::contents, CONTENTS_BODY, CONTENTS_BOTCLIP, CONTENTS_MONSTERCLIP, entityShared_t::currentOrigin, trace_t::endpos, trace_t::entityNum, ENTITYNUM_WORLD, fabs(), trace_t::fraction, G_EntIsBreakable(), G_EntIsDoor(), G_EntIsRemovableUsable(), G_EntIsUnlockedDoor(), g_entities, gentity_t, entityShared_t::maxs, MIN_DOOR_BLOCK_DIST_SQR, entityShared_t::mins, NPC, entityState_s::number, qfalse, gentity_s::r, gentity_s::s, entityState_s::solid, SOLID_BMODEL, trace_t::startsolid, STEPSIZE, gentity_s::targetname, trap_Nav_AddFailedEdge(), trap_Nav_GetNodePosition(), trap_Trace(), VALIDSTRING, vec3_t, VectorSet, entityState_s::weapon, and WP_SABER. Referenced by NAV_MoveToGoal(), NAV_ShowDebugInfo(), and NAVNEW_MoveToGoal().
00972 {//check only against architectrure
00973 vec3_t end;
00974 trace_t trace;
00975 vec3_t mins;
00976 int clipmask = (NPC->clipmask&~CONTENTS_BODY)|CONTENTS_BOTCLIP;
00977
00978 //get the position for the test choice
00979 trap_Nav_GetNodePosition( endID, end );
00980
00981 //Offset the step height
00982 VectorSet( mins, self->r.mins[0], self->r.mins[1], self->r.mins[2] + STEPSIZE );
00983
00984 trap_Trace( &trace, self->r.currentOrigin, mins, self->r.maxs, end, self->s.number, clipmask );
00985
00986 if ( trace.startsolid&&(trace.contents&CONTENTS_BOTCLIP) )
00987 {//started inside do not enter, so ignore them
00988 clipmask &= ~CONTENTS_BOTCLIP;
00989 trap_Trace( &trace, self->r.currentOrigin, mins, self->r.maxs, end, self->s.number, clipmask );
00990 }
00991 //Do a simple check
00992 if ( ( trace.allsolid == qfalse ) && ( trace.startsolid == qfalse ) && ( trace.fraction == 1.0f ) )
00993 {//it's clear
00994 return endID;
00995 }
00996
00997 //See if we're too far above
00998 if ( self->s.weapon != WP_SABER && fabs( self->r.currentOrigin[2] - end[2] ) > 48 )
00999 {
01000 }
01001 else
01002 {
01003 //This is a work around
01004 float radius = ( self->r.maxs[0] > self->r.maxs[1] ) ? self->r.maxs[0] : self->r.maxs[1];
01005 float dist = Distance( self->r.currentOrigin, end );
01006 float tFrac = 1.0f - ( radius / dist );
01007
01008 if ( trace.fraction >= tFrac )
01009 {//it's clear
01010 return endID;
01011 }
01012 }
01013
01014 //Do a special check for doors
01015 if ( trace.entityNum < ENTITYNUM_WORLD )
01016 {
01017 gentity_t *blocker = &g_entities[trace.entityNum];
01018
01019 if VALIDSTRING( blocker->classname )
01020 {//special case: doors are architecture, but are dynamic, like entitites
01021 if ( G_EntIsUnlockedDoor( blocker->s.number ) )
01022 //if ( Q_stricmp( blocker->classname, "func_door" ) == 0 )
01023 {//it's unlocked, go for it
01024 //We're too close, try and avoid the door (most likely stuck on a lip)
01025 if ( DistanceSquared( self->r.currentOrigin, trace.endpos ) < MIN_DOOR_BLOCK_DIST_SQR )
01026 {
01027 return startID;
01028 }
01029 //we can keep heading to the door, it should open
01030 if ( self->s.weapon != WP_SABER && fabs( self->r.currentOrigin[2] - end[2] ) > 48 )
01031 {//too far above
01032 }
01033 else
01034 {
01035 return endID;
01036 }
01037 }
01038 else if ( G_EntIsDoor( blocker->s.number ) )
01039 {//a locked door!
01040 //path is blocked by a locked door, mark it as such if instructed to do so
01041 if ( failEdge )
01042 {
01043 trap_Nav_AddFailedEdge( self->s.number, startID, endID );
01044 }
01045 }
01046 else if ( G_EntIsBreakable( blocker->s.number ) )
01047 {//do same for breakable brushes/models/glass?
01048 //path is blocked by a breakable, mark it as such if instructed to do so
01049 if ( failEdge )
01050 {
01051 trap_Nav_AddFailedEdge( self->s.number, startID, endID );
01052 }
01053 }
01054 else if ( G_EntIsRemovableUsable( blocker->s.number ) )
01055 {//and removable usables
01056 //path is blocked by a removable usable, mark it as such if instructed to do so
01057 if ( failEdge )
01058 {
01059 trap_Nav_AddFailedEdge( self->s.number, startID, endID );
01060 }
01061 }
01062 else if ( blocker->targetname && blocker->s.solid == SOLID_BMODEL && ((blocker->r.contents&CONTENTS_MONSTERCLIP)|| (blocker->r.contents&CONTENTS_BOTCLIP)) )
01063 {//some other kind of do not enter entity brush that will probably be removed
01064 //path is blocked by a removable brushent, mark it as such if instructed to do so
01065 if ( failEdge )
01066 {
01067 trap_Nav_AddFailedEdge( self->s.number, startID, endID );
01068 }
01069 }
01070 }
01071 }
01072 //path is blocked
01073 //use the fallback choice
01074 return startID;
01075 }
|
|
||||||||||||
|
Definition at line 160 of file NPC_move.c. References AngleNormalize360(), CONTENTS_LADDER, gNPC_t::desiredYaw, navInfo_s::direction, navInfo_s::distance, navInfo_s::flags, frameNavInfo, gNPC_t::goalEntity, memset(), NAV_AvoidCollision(), NAV_MoveToGoal(), NIF_MACRO_NAV, NPC, NPC_ClearPathToGoal(), NPC_GetMoveInformation(), NPCInfo, navInfo_s::pathDirection, qboolean, qfalse, qtrue, vec3_t, vectoangles(), VectorCopy, gentity_s::watertype, WAYPOINT_NONE, and YAW. Referenced by ImperialProbe_Hunt(), Interrogator_Hunt(), NPC_MoveToGoal(), Remote_Hunt(), Seeker_Hunt(), and Sentry_Hunt().
00161 {
00162 vec3_t angles;
00163
00164 //Clear the struct
00165 memset( &frameNavInfo, 0, sizeof( frameNavInfo ) );
00166
00167 //Get our movement, if any
00168 if ( NPC_GetMoveInformation( frameNavInfo.direction, &frameNavInfo.distance ) == qfalse )
00169 return qfalse;
00170
00171 //Setup the return value
00172 *distance = frameNavInfo.distance;
00173
00174 //For starters
00175 VectorCopy( frameNavInfo.direction, frameNavInfo.pathDirection );
00176
00177 //If on a ladder, move appropriately
00178 if ( NPC->watertype & CONTENTS_LADDER )
00179 {
00180 NPC_LadderMove( frameNavInfo.direction );
00181 return qtrue;
00182 }
00183
00184 //Attempt a straight move to goal
00185 if ( NPC_ClearPathToGoal( frameNavInfo.direction, NPCInfo->goalEntity ) == qfalse )
00186 {
00187 //See if we're just stuck
00188 if ( NAV_MoveToGoal( NPC, &frameNavInfo ) == WAYPOINT_NONE )
00189 {
00190 //Can't reach goal, just face
00191 vectoangles( frameNavInfo.direction, angles );
00192 NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] );
00193 VectorCopy( frameNavInfo.direction, out );
00194 *distance = frameNavInfo.distance;
00195 return qfalse;
00196 }
00197
00198 frameNavInfo.flags |= NIF_MACRO_NAV;
00199 }
00200
00201 //Avoid any collisions on the way
00202 if ( NAV_AvoidCollision( NPC, NPCInfo->goalEntity, &frameNavInfo ) == qfalse )
00203 {
00204 //FIXME: Emit a warning, this is a worst case scenario
00205 //FIXME: if we have a clear path to our goal (exluding bodies), but then this
00206 // check (against bodies only) fails, shouldn't we fall back
00207 // to macro navigation? Like so:
00208 if ( !(frameNavInfo.flags&NIF_MACRO_NAV) )
00209 {//we had a clear path to goal and didn't try macro nav, but can't avoid collision so try macro nav here
00210 //See if we're just stuck
00211 if ( NAV_MoveToGoal( NPC, &frameNavInfo ) == WAYPOINT_NONE )
00212 {
00213 //Can't reach goal, just face
00214 vectoangles( frameNavInfo.direction, angles );
00215 NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] );
00216 VectorCopy( frameNavInfo.direction, out );
00217 *distance = frameNavInfo.distance;
00218 return qfalse;
00219 }
00220
00221 frameNavInfo.flags |= NIF_MACRO_NAV;
00222 }
00223 }
00224
00225 //Setup the return values
00226 VectorCopy( frameNavInfo.direction, out );
00227 *distance = frameNavInfo.distance;
00228
00229 return qtrue;
00230 }
|
|
|
|
|
|
Definition at line 50 of file g_nav.h. Referenced by G_InitGame(), SP_waypoint(), and SP_waypoint_small(). |
|
|
Definition at line 61 of file g_nav.h. Referenced by NAV_ShowDebugInfo(), and Svcmd_Nav_f(). |
|
|
Definition at line 59 of file g_nav.h. Referenced by NAV_AvoidCollision(), NAV_Bypass(), NAV_ClearPathToPoint(), NAV_StackedCanyon(), NAV_Steer(), NAVNEW_AvoidCollision(), NAVNEW_Bypass(), and Svcmd_Nav_f(). |
|
|
Definition at line 57 of file g_nav.h. Referenced by NAV_ShowDebugInfo(), and Svcmd_Nav_f(). |
|
|
Definition at line 54 of file g_nav.h. Referenced by NAV_ShowDebugInfo(), and Svcmd_Nav_f(). |
|
|
Definition at line 56 of file g_nav.h. Referenced by NAV_MoveToGoal(), NAVNEW_MoveToGoal(), and Svcmd_Nav_f(). |
|
|
Definition at line 58 of file g_nav.h. Referenced by NAV_ShowDebugInfo(), and Svcmd_Nav_f(). |
|
|
Definition at line 52 of file g_nav.h. Referenced by NAV_ShowDebugInfo(), and Svcmd_Nav_f(). |
|
|
Definition at line 53 of file g_nav.h. Referenced by Svcmd_Nav_f(). |
|
|
Definition at line 55 of file g_nav.h. Referenced by NAV_ShowDebugInfo(), and Svcmd_Nav_f(). |