mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-17 11:00:38 +02:00
Removed legacy AAS from Doom, cleaned up naming.
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
// Copyright (C) 2007 Id Software, Inc.
|
||||
//
|
||||
|
||||
#ifndef __AASCALLBACK_FINDAREAOUTOFRANGE_H__
|
||||
#define __AASCALLBACK_FINDAREAOUTOFRANGE_H__
|
||||
|
||||
#include "AASCallback_AvoidLocation.h"
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
idAASCallback_FindAreaOutOfRange
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
class idAASCallback_FindAreaOutOfRange : public idAASCallback_AvoidLocation
|
||||
{
|
||||
public:
|
||||
idAASCallback_FindAreaOutOfRange( const idVec3& targetPos, float maxDist );
|
||||
|
||||
virtual bool AreaIsGoal( const idAAS* aas, int areaNum );
|
||||
|
||||
private:
|
||||
idVec3 targetPos;
|
||||
float maxDistSqr;
|
||||
};
|
||||
|
||||
#endif /* !__AASCALLBACK_FINDAREAOUTOFRANGE_H__ */
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright (C) 2007 Id Software, Inc.
|
||||
//
|
||||
|
||||
#ifndef __AASCALLBACK_FINDCOVERAREA_H__
|
||||
#define __AASCALLBACK_FINDCOVERAREA_H__
|
||||
|
||||
#include "AASCallback_AvoidLocation.h"
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
idAASCallback_FindCoverArea
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
class idAASCallback_FindCoverArea : public idAASCallback_AvoidLocation
|
||||
{
|
||||
public:
|
||||
idAASCallback_FindCoverArea( const idVec3& hideFromPos );
|
||||
~idAASCallback_FindCoverArea();
|
||||
|
||||
virtual bool AreaIsGoal( const idAAS* aas, int areaNum );
|
||||
|
||||
private:
|
||||
static const int MAX_PVS_AREAS = 4;
|
||||
|
||||
pvsHandle_t hidePVS;
|
||||
int PVSAreas[ MAX_PVS_AREAS ];
|
||||
};
|
||||
|
||||
#endif /* !__AASCALLBACK_FINDCOVERAREA_H__ */
|
||||
+19
-19
@@ -30,10 +30,10 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#pragma hdrstop
|
||||
|
||||
#include "../Game_local.h"
|
||||
#include "AASCallback_AvoidLocation.h"
|
||||
#include "AASCallback_FindAreaOutOfRange.h"
|
||||
#include "AASCallback_FindAttackPosition.h"
|
||||
#include "AASCallback_FindCoverArea.h"
|
||||
#include "NAVCallback_AvoidLocation.h"
|
||||
#include "NAVCallback_FindAreaOutOfRange.h"
|
||||
#include "NAVCallback_FindAttackPosition.h"
|
||||
#include "NAVCallback_FindCoverArea.h"
|
||||
|
||||
static const char* moveCommandString[NUM_MOVE_COMMANDS] = {
|
||||
"MOVE_NONE",
|
||||
@@ -533,11 +533,11 @@ void idAI::Restore(idRestoreGame* savefile) {
|
||||
|
||||
savefile->ReadBool(restorePhysics);
|
||||
|
||||
// Set the AAS if the character has the correct gravity vector
|
||||
// Set the NAV if the character has the correct gravity vector
|
||||
idVec3 gravity = spawnArgs.GetVector("gravityDir", "0 0 -1");
|
||||
gravity *= g_gravity.GetFloat();
|
||||
if (gravity == gameLocal.GetGravity()) {
|
||||
SetAAS();
|
||||
SetNAV();
|
||||
}
|
||||
|
||||
SetCombatModel();
|
||||
@@ -743,7 +743,7 @@ void idAI::Spawn(void) {
|
||||
|
||||
move.blockTime = 0;
|
||||
|
||||
SetAAS();
|
||||
SetNAV();
|
||||
|
||||
projectile = NULL;
|
||||
projectileDef = NULL;
|
||||
@@ -1030,7 +1030,7 @@ void idAI::Think(void) {
|
||||
}
|
||||
/* this still draws in retail builds.. not sure why.. don't care at this point.
|
||||
if ( !aas && developer.GetBool() && !fl.hidden && !num_cinematics ) {
|
||||
gameRenderWorld->DrawText( "No AAS", physicsObj.GetAbsBounds().GetCenter(), 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3(), 1, gameLocal.msec );
|
||||
gameRenderWorld->DrawText( "No NAV", physicsObj.GetAbsBounds().GetCenter(), 0.1f, colorWhite, gameLocal.GetLocalPlayer()->viewAngles.ToMat3(), 1, gameLocal.msec );
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1180,14 +1180,14 @@ bool ValidForBounds(const idAASSettings* settings, const idBounds& bounds) {
|
||||
|
||||
/*
|
||||
=====================
|
||||
idAI::SetAAS
|
||||
idAI::SetNAV
|
||||
=====================
|
||||
*/
|
||||
void idAI::SetAAS(void) {
|
||||
void idAI::SetNAV(void) {
|
||||
idStr use_aas;
|
||||
|
||||
spawnArgs.GetString("use_aas", NULL, use_aas);
|
||||
aas = gameLocal.GetAAS(use_aas);
|
||||
aas = gameLocal.GetNAV(use_aas);
|
||||
if (aas) {
|
||||
const idAASSettings* settings = aas->GetSettings();
|
||||
if (settings) {
|
||||
@@ -1202,7 +1202,7 @@ void idAI::SetAAS(void) {
|
||||
aas = NULL;
|
||||
}
|
||||
}
|
||||
gameLocal.Printf("WARNING: %s has no AAS file\n", name.c_str());
|
||||
gameLocal.Printf("WARNING: %s has no NAV file\n", name.c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1317,7 +1317,7 @@ bool idAI::PathToGoal(aasPath_t& path, int areaNum, const idVec3& origin, int go
|
||||
=====================
|
||||
idAI::TravelDistance
|
||||
|
||||
Returns the approximate travel distance from one position to the goal, or if no AAS, the straight line distance.
|
||||
Returns the approximate travel distance from one position to the goal, or if no NAV, the straight line distance.
|
||||
|
||||
This is feakin' slow, so it's not good to do it too many times per frame. It also is slower the further you
|
||||
are from the goal, so try to break the goals up into shorter distances.
|
||||
@@ -1695,7 +1695,7 @@ bool idAI::MoveOutOfRange(idEntity* ent, float range) {
|
||||
pos = ent->GetPhysics()->GetOrigin();
|
||||
}
|
||||
|
||||
idAASCallback_FindAreaOutOfRange findGoal(pos, range);
|
||||
idNAVCallback_FindAreaOutOfRange findGoal(pos, range);
|
||||
if (!aas->FindNearestGoal(goal, areaNum, org, pos, travelFlags, &obstacle, 1, findGoal)) {
|
||||
StopMove(MOVE_STATUS_DEST_UNREACHABLE);
|
||||
AI_DEST_UNREACHABLE = true;
|
||||
@@ -1753,7 +1753,7 @@ bool idAI::MoveToAttackPosition(idEntity* ent, int attack_anim) {
|
||||
pos = ent->GetPhysics()->GetOrigin();
|
||||
}
|
||||
|
||||
idAASFindAttackPosition findGoal(this, physicsObj.GetGravityAxis(), ent, pos, missileLaunchOffset[attack_anim]);
|
||||
idNAVFindAttackPosition findGoal(this, physicsObj.GetGravityAxis(), ent, pos, missileLaunchOffset[attack_anim]);
|
||||
if (!aas->FindNearestGoal(goal, areaNum, org, pos, travelFlags, &obstacle, 1, findGoal)) {
|
||||
StopMove(MOVE_STATUS_DEST_UNREACHABLE);
|
||||
AI_DEST_UNREACHABLE = true;
|
||||
@@ -1846,7 +1846,7 @@ bool idAI::MoveToCover(idEntity* entity, const idVec3& hideFromPos) {
|
||||
// consider the entity the monster tries to hide from as an obstacle
|
||||
obstacle.absBounds = entity->GetPhysics()->GetAbsBounds();
|
||||
|
||||
idAASCallback_FindCoverArea findCover(hideFromPos);
|
||||
idNAVCallback_FindCoverArea findCover(hideFromPos);
|
||||
if (!aas->FindNearestGoal(hideGoal, areaNum, org, hideFromPos, travelFlags, &obstacle, 1, findCover)) {
|
||||
StopMove(MOVE_STATUS_DEST_UNREACHABLE);
|
||||
AI_DEST_UNREACHABLE = true;
|
||||
@@ -3647,7 +3647,7 @@ void idAI::SetEnemyPosition(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
// when we don't have an AAS, we can't tell if an enemy is reachable or not,
|
||||
// when we don't have a NAV, we can't tell if an enemy is reachable or not,
|
||||
// so just assume that he is.
|
||||
if (!aas) {
|
||||
lastVisibleReachableEnemyPos = lastVisibleEnemyPos;
|
||||
@@ -3739,7 +3739,7 @@ void idAI::UpdateEnemyPosition(void) {
|
||||
}
|
||||
|
||||
if (onGround) {
|
||||
// when we don't have an AAS, we can't tell if an enemy is reachable or not,
|
||||
// when we don't have a NAV, we can't tell if an enemy is reachable or not,
|
||||
// so just assume that he is.
|
||||
if (!aas) {
|
||||
enemyAreaNum = 0;
|
||||
@@ -3808,7 +3808,7 @@ void idAI::SetEnemy(idActor* newEnemy) {
|
||||
return;
|
||||
}
|
||||
// let the monster know where the enemy is
|
||||
newEnemy->GetAASLocation(aas, lastReachableEnemyPos, enemyAreaNum);
|
||||
newEnemy->GetNAVLocation(aas, lastReachableEnemyPos, enemyAreaNum);
|
||||
SetEnemyPosition();
|
||||
SetChatSound();
|
||||
|
||||
|
||||
@@ -221,11 +221,11 @@ public:
|
||||
static void List_f(const idCmdArgs& args);
|
||||
|
||||
// Finds a path around dynamic obstacles.
|
||||
static bool FindPathAroundObstacles(const idPhysics* physics, const idAAS* aas, const idEntity* ignore, const idVec3& startPos, const idVec3& seekPos, obstaclePath_t& path);
|
||||
static bool FindPathAroundObstacles(const idPhysics* physics, const idNAV* aas, const idEntity* ignore, const idVec3& startPos, const idVec3& seekPos, obstaclePath_t& path);
|
||||
// Frees any nodes used for the dynamic obstacle avoidance.
|
||||
static void FreeObstacleAvoidanceNodes(void);
|
||||
// Predicts movement, returns true if a stop event was triggered.
|
||||
static bool PredictPath(const idEntity* ent, const idAAS* aas, const idVec3& start, const idVec3& velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t& path);
|
||||
static bool PredictPath(const idEntity* ent, const idNAV* aas, const idVec3& start, const idVec3& velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t& path);
|
||||
// Return true if the trajectory of the clip model is collision free.
|
||||
static bool TestTrajectory(const idVec3& start, const idVec3& end, float zVel, float gravity, float time, float max_height, const idClipModel* clip, int clipmask, const idEntity* ignore, const idEntity* targetEntity, int drawtime);
|
||||
// Finds the best collision free trajectory for a clip model.
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
|
||||
protected:
|
||||
// navigation
|
||||
idAAS* aas;
|
||||
idNAV* aas;
|
||||
int travelFlags;
|
||||
|
||||
idMoveState move;
|
||||
@@ -377,7 +377,7 @@ protected:
|
||||
//
|
||||
// ai/ai.cpp
|
||||
//
|
||||
void SetAAS(void);
|
||||
void SetNAV(void);
|
||||
virtual void DormantBegin(void); // called when entity becomes dormant
|
||||
virtual void DormantEnd(void); // called when entity wakes from being dormant
|
||||
void Think(void);
|
||||
@@ -586,7 +586,7 @@ protected:
|
||||
void LocateEnemy(void);
|
||||
void KickObstacles(idEntity* kickEnt, float force);
|
||||
idEntity* GetObstacle(void);
|
||||
idVec3 PushPointIntoAAS(const idVec3& pos);
|
||||
idVec3 PushPointIntoNAV(const idVec3& pos);
|
||||
float GetTurnRate(void);
|
||||
void SetTurnRate(float rate);
|
||||
void AnimTurn(float angles);
|
||||
@@ -718,7 +718,7 @@ protected:
|
||||
void Event_LocateEnemy(void);
|
||||
void Event_KickObstacles(idEntity* kickEnt, float force);
|
||||
void Event_GetObstacle(void);
|
||||
void Event_PushPointIntoAAS(const idVec3& pos);
|
||||
void Event_PushPointIntoNAV(const idVec3& pos);
|
||||
void Event_GetTurnRate(void);
|
||||
void Event_SetTurnRate(float rate);
|
||||
void Event_AnimTurn(float angles);
|
||||
|
||||
@@ -149,7 +149,7 @@ const idEventDef AI_WakeOnFlashlight("wakeOnFlashlight", "d");
|
||||
const idEventDef AI_LocateEnemy("locateEnemy");
|
||||
const idEventDef AI_KickObstacles("kickObstacles", "Ef");
|
||||
const idEventDef AI_GetObstacle("getObstacle", NULL, 'e');
|
||||
const idEventDef AI_PushPointIntoAAS("pushPointIntoAAS", "v", 'v');
|
||||
const idEventDef AI_PushPointIntoNAV("pushPointIntoAAS", "v", 'v');
|
||||
const idEventDef AI_GetTurnRate("getTurnRate", NULL, 'f');
|
||||
const idEventDef AI_SetTurnRate("setTurnRate", "f");
|
||||
const idEventDef AI_AnimTurn("animTurn", "f");
|
||||
@@ -279,7 +279,7 @@ EVENT(AI_WakeOnFlashlight, idAI::Event_WakeOnFlashlight)
|
||||
EVENT(AI_LocateEnemy, idAI::Event_LocateEnemy)
|
||||
EVENT(AI_KickObstacles, idAI::Event_KickObstacles)
|
||||
EVENT(AI_GetObstacle, idAI::Event_GetObstacle)
|
||||
EVENT(AI_PushPointIntoAAS, idAI::Event_PushPointIntoAAS)
|
||||
EVENT(AI_PushPointIntoNAV, idAI::Event_PushPointIntoNAV)
|
||||
EVENT(AI_GetTurnRate, idAI::Event_GetTurnRate)
|
||||
EVENT(AI_SetTurnRate, idAI::Event_SetTurnRate)
|
||||
EVENT(AI_AnimTurn, idAI::Event_AnimTurn)
|
||||
@@ -2209,7 +2209,7 @@ void idAI::LocateEnemy(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
enemyEnt->GetAASLocation(aas, lastReachableEnemyPos, areaNum);
|
||||
enemyEnt->GetNAVLocation(aas, lastReachableEnemyPos, areaNum);
|
||||
SetEnemyPosition();
|
||||
UpdateEnemyPosition();
|
||||
}
|
||||
@@ -2251,10 +2251,10 @@ idEntity* idAI::GetObstacle(void) {
|
||||
|
||||
/*
|
||||
=====================
|
||||
idAI::PushPointIntoAAS
|
||||
idAI::PushPointIntoNAV
|
||||
=====================
|
||||
*/
|
||||
idVec3 idAI::PushPointIntoAAS(const idVec3& pos) {
|
||||
idVec3 idAI::PushPointIntoNAV(const idVec3& pos) {
|
||||
int areaNum;
|
||||
idVec3 newPos;
|
||||
|
||||
@@ -2425,7 +2425,7 @@ int idAI::CanReachEnemy(void) {
|
||||
if (enemyEnt->OnLadder()) {
|
||||
return false;
|
||||
}
|
||||
enemyEnt->GetAASLocation(aas, pos, toAreaNum);
|
||||
enemyEnt->GetNAVLocation(aas, pos, toAreaNum);
|
||||
}
|
||||
else {
|
||||
pos = enemyEnt->GetPhysics()->GetOrigin();
|
||||
@@ -3614,11 +3614,11 @@ void idAI::Event_GetObstacle(void) {
|
||||
|
||||
/*
|
||||
=====================
|
||||
idAI::Event_PushPointIntoAAS
|
||||
idAI::Event_PushPointIntoNAV
|
||||
=====================
|
||||
*/
|
||||
void idAI::Event_PushPointIntoAAS(const idVec3& pos) {
|
||||
idThread::ReturnVector(PushPointIntoAAS(pos));
|
||||
void idAI::Event_PushPointIntoNAV(const idVec3& pos) {
|
||||
idThread::ReturnVector(PushPointIntoNAV(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -38,7 +38,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||
|
||||
- assumes the AI lives inside a bounding box aligned with the gravity direction
|
||||
- obstacles in proximity of the AI are gathered
|
||||
- if obstacles are found the AAS walls are also considered as obstacles
|
||||
- if obstacles are found the NAV walls are also considered as obstacles
|
||||
- every obstacle is represented by an oriented bounding box (OBB)
|
||||
- an OBB is projected onto a 2D plane orthogonal to AI's gravity direction
|
||||
- the 2D windings of the projections are expanded for the AI bbox
|
||||
@@ -52,7 +52,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||
const float MAX_OBSTACLE_RADIUS = 256.0f;
|
||||
const float PUSH_OUTSIDE_OBSTACLES = 0.5f;
|
||||
const float CLIP_BOUNDS_EPSILON = 10.0f;
|
||||
const int MAX_AAS_WALL_EDGES = 256;
|
||||
const int MAX_NAV_WALL_EDGES = 256;
|
||||
const int MAX_OBSTACLES = 256;
|
||||
const int MAX_PATH_NODES = 256;
|
||||
const int MAX_OBSTACLE_PATH = 64;
|
||||
@@ -306,9 +306,9 @@ bool GetFirstBlockingObstacle( const obstacle_t *obstacles, int numObstacles, in
|
||||
GetObstacles
|
||||
============
|
||||
*/
|
||||
int GetObstacles( const idPhysics *physics, const idAAS *aas, const idEntity *ignore, int areaNum, const idVec3 &startPos, const idVec3 &seekPos, obstacle_t *obstacles, int maxObstacles, idBounds &clipBounds ) {
|
||||
int GetObstacles( const idPhysics *physics, const idNAV *aas, const idEntity *ignore, int areaNum, const idVec3 &startPos, const idVec3 &seekPos, obstacle_t *obstacles, int maxObstacles, idBounds &clipBounds ) {
|
||||
int i, j, numListedClipModels, numObstacles, numVerts, clipMask, blockingObstacle, blockingEdgeNum;
|
||||
int wallEdges[MAX_AAS_WALL_EDGES], numWallEdges, verts[2], lastVerts[2], nextVerts[2];
|
||||
int wallEdges[MAX_NAV_WALL_EDGES], numWallEdges, verts[2], lastVerts[2], nextVerts[2];
|
||||
float stepHeight, headHeight, blockingScale, min, max;
|
||||
idVec3 seekDelta, silVerts[32], start, end, nextStart, nextEnd;
|
||||
idVec2 expBounds[2], edgeDir, edgeNormal, nextEdgeDir, nextEdgeNormal, lastEdgeNormal;
|
||||
@@ -402,23 +402,23 @@ int GetObstacles( const idPhysics *physics, const idAAS *aas, const idEntity *ig
|
||||
obstacle.entity = obEnt;
|
||||
}
|
||||
|
||||
// if there are no dynamic obstacles the path should be through valid AAS space
|
||||
// if there are no dynamic obstacles the path should be through valid NAV space
|
||||
if ( numObstacles == 0 ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if the current path doesn't intersect any dynamic obstacles the path should be through valid AAS space
|
||||
// if the current path doesn't intersect any dynamic obstacles the path should be through valid NAV space
|
||||
if ( PointInsideObstacle( obstacles, numObstacles, startPos.ToVec2() ) == -1 ) {
|
||||
if ( !GetFirstBlockingObstacle( obstacles, numObstacles, -1, startPos.ToVec2(), seekDelta.ToVec2(), blockingScale, blockingObstacle, blockingEdgeNum ) ) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// create obstacles for AAS walls
|
||||
// create obstacles for NAV walls
|
||||
if ( aas ) {
|
||||
float halfBoundsSize = ( expBounds[ 1 ].x - expBounds[ 0 ].x ) * 0.5f;
|
||||
|
||||
numWallEdges = aas->GetWallEdges( areaNum, clipBounds, TFL_WALK, wallEdges, MAX_AAS_WALL_EDGES );
|
||||
numWallEdges = aas->GetWallEdges( areaNum, clipBounds, TFL_WALK, wallEdges, MAX_NAV_WALL_EDGES );
|
||||
aas->SortWallEdges( wallEdges, numWallEdges );
|
||||
|
||||
lastVerts[0] = lastVerts[1] = 0;
|
||||
@@ -921,7 +921,7 @@ idAI::FindPathAroundObstacles
|
||||
Finds a path around dynamic obstacles using a path tree with clockwise and counter clockwise edge walks.
|
||||
============
|
||||
*/
|
||||
bool idAI::FindPathAroundObstacles( const idPhysics *physics, const idAAS *aas, const idEntity *ignore, const idVec3 &startPos, const idVec3 &seekPos, obstaclePath_t &path ) {
|
||||
bool idAI::FindPathAroundObstacles( const idPhysics *physics, const idNAV *aas, const idEntity *ignore, const idVec3 &startPos, const idVec3 &seekPos, obstaclePath_t &path ) {
|
||||
int numObstacles, areaNum, insideObstacle;
|
||||
obstacle_t obstacles[MAX_OBSTACLES];
|
||||
idBounds clipBounds;
|
||||
@@ -944,7 +944,7 @@ bool idAI::FindPathAroundObstacles( const idPhysics *physics, const idAAS *aas,
|
||||
bounds[0] = -bounds[1];
|
||||
bounds[1].z = 32.0f;
|
||||
|
||||
// get the AAS area number and a valid point inside that area
|
||||
// get the NAV area number and a valid point inside that area
|
||||
areaNum = aas->PointReachableAreaNum( path.startPosOutsideObstacles, bounds, (AREA_REACHABLE_WALK|AREA_REACHABLE_FLY) );
|
||||
aas->PushPointIntoAreaNum( areaNum, path.startPosOutsideObstacles );
|
||||
|
||||
@@ -1005,7 +1005,7 @@ void idAI::FreeObstacleAvoidanceNodes( void ) {
|
||||
|
||||
Path Prediction
|
||||
|
||||
Uses the AAS to quickly and accurately predict a path for a certain
|
||||
Uses the NAV to quickly and accurately predict a path for a certain
|
||||
period of time based on an initial position and velocity.
|
||||
|
||||
===============================================================================
|
||||
@@ -1028,7 +1028,7 @@ PathTrace
|
||||
Returns true if a stop event was triggered.
|
||||
============
|
||||
*/
|
||||
bool PathTrace( const idEntity *ent, const idAAS *aas, const idVec3 &start, const idVec3 &end, int stopEvent, struct pathTrace_s &trace, predictedPath_t &path ) {
|
||||
bool PathTrace( const idEntity *ent, const idNAV *aas, const idVec3 &start, const idVec3 &end, int stopEvent, struct pathTrace_s &trace, predictedPath_t &path ) {
|
||||
trace_t clipTrace;
|
||||
aasTrace_t aasTrace;
|
||||
|
||||
@@ -1039,7 +1039,7 @@ bool PathTrace( const idEntity *ent, const idAAS *aas, const idVec3 &start, cons
|
||||
gameLocal.clip.Translation( clipTrace, start, end, ent->GetPhysics()->GetClipModel(),
|
||||
ent->GetPhysics()->GetClipModel()->GetAxis(), MASK_MONSTERSOLID, ent );
|
||||
|
||||
// NOTE: could do (expensive) ledge detection here for when there is no AAS file
|
||||
// NOTE: could do (expensive) ledge detection here for when there is no NAV file
|
||||
|
||||
trace.fraction = clipTrace.fraction;
|
||||
trace.endPos = clipTrace.endpos;
|
||||
@@ -1113,10 +1113,10 @@ bool PathTrace( const idEntity *ent, const idAAS *aas, const idVec3 &start, cons
|
||||
============
|
||||
idAI::PredictPath
|
||||
|
||||
Can also be used when there is no AAS file available however ledges are not detected.
|
||||
Can also be used when there is no NAV file available however ledges are not detected.
|
||||
============
|
||||
*/
|
||||
bool idAI::PredictPath( const idEntity *ent, const idAAS *aas, const idVec3 &start, const idVec3 &velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t &path ) {
|
||||
bool idAI::PredictPath( const idEntity *ent, const idNAV *aas, const idVec3 &start, const idVec3 &velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t &path ) {
|
||||
int i, j, step, numFrames, curFrameTime;
|
||||
idVec3 delta, curStart, curEnd, curVelocity, lastEnd, stepUp, tmpStart;
|
||||
idVec3 gravity, gravityDir, invGravityDir;
|
||||
|
||||
@@ -30,50 +30,50 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#pragma hdrstop
|
||||
|
||||
#include "../Game_local.h"
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
|
||||
/*
|
||||
============
|
||||
idAAS::Alloc
|
||||
idNAV::Alloc
|
||||
============
|
||||
*/
|
||||
idAAS *idAAS::Alloc( void ) {
|
||||
return new idAASLocal;
|
||||
idNAV *idNAV::Alloc( void ) {
|
||||
return new idNAVLocal;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAAS::idAAS
|
||||
idNAV::~idNAV
|
||||
============
|
||||
*/
|
||||
idAAS::~idAAS( void ) {
|
||||
idNAV::~idNAV( void ) {
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::idAASLocal
|
||||
idNAVLocal::idNAVLocal
|
||||
============
|
||||
*/
|
||||
idAASLocal::idAASLocal( void ) {
|
||||
idNAVLocal::idNAVLocal( void ) {
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::~idAASLocal
|
||||
idNAVLocal::~idNAVLocal
|
||||
============
|
||||
*/
|
||||
idAASLocal::~idAASLocal( void ) {
|
||||
idNAVLocal::~idNAVLocal( void ) {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::Init
|
||||
idNAVLocal::Init
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
|
||||
const idStr navName = idRecastNavMesh::NavFileNameForAASName( mapName );
|
||||
bool idNAVLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
|
||||
const idStr navName = idRecastNavMesh::NavFileNameForMapName( mapName );
|
||||
if ( recastNavMesh.IsLoaded() && mapName.Icmp( name ) == 0 ) {
|
||||
common->Printf( "Keeping %s\n", navName.c_str() );
|
||||
recastNavMesh.RemoveAllObstacles();
|
||||
@@ -104,7 +104,7 @@ bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
|
||||
|
||||
file = AASFileManager->LoadAAS( mapName, mapFileCRC );
|
||||
if ( !file ) {
|
||||
common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
|
||||
common->DWarning( "Couldn't load NAV file: '%s'", mapName.c_str() );
|
||||
return false;
|
||||
}
|
||||
SetupRouting();
|
||||
@@ -114,10 +114,10 @@ bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::Shutdown
|
||||
idNAVLocal::Shutdown
|
||||
============
|
||||
*/
|
||||
void idAASLocal::Shutdown( void ) {
|
||||
void idNAVLocal::Shutdown( void ) {
|
||||
recastNavMesh.Shutdown();
|
||||
if ( file ) {
|
||||
ShutdownRouting();
|
||||
@@ -129,10 +129,10 @@ void idAASLocal::Shutdown( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::Stats
|
||||
idNAVLocal::Stats
|
||||
============
|
||||
*/
|
||||
void idAASLocal::Stats( void ) const {
|
||||
void idNAVLocal::Stats( void ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.Stats();
|
||||
return;
|
||||
@@ -147,10 +147,10 @@ void idAASLocal::Stats( void ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetSettings
|
||||
idNAVLocal::GetSettings
|
||||
============
|
||||
*/
|
||||
const idAASSettings *idAASLocal::GetSettings( void ) const {
|
||||
const idAASSettings *idNAVLocal::GetSettings( void ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.GetSettings();
|
||||
}
|
||||
@@ -162,10 +162,10 @@ const idAASSettings *idAASLocal::GetSettings( void ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::PointAreaNum
|
||||
idNAVLocal::PointAreaNum
|
||||
============
|
||||
*/
|
||||
int idAASLocal::PointAreaNum( const idVec3 &origin ) const {
|
||||
int idNAVLocal::PointAreaNum( const idVec3 &origin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.PointAreaNum( origin );
|
||||
}
|
||||
@@ -177,10 +177,10 @@ int idAASLocal::PointAreaNum( const idVec3 &origin ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::PointReachableAreaNum
|
||||
idNAVLocal::PointReachableAreaNum
|
||||
============
|
||||
*/
|
||||
int idAASLocal::PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const {
|
||||
int idNAVLocal::PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.PointReachableAreaNum( origin, searchBounds, areaFlags );
|
||||
}
|
||||
@@ -193,10 +193,10 @@ int idAASLocal::PointReachableAreaNum( const idVec3 &origin, const idBounds &sea
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::BoundsReachableAreaNum
|
||||
idNAVLocal::BoundsReachableAreaNum
|
||||
============
|
||||
*/
|
||||
int idAASLocal::BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const {
|
||||
int idNAVLocal::BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.BoundsReachableAreaNum( bounds, areaFlags );
|
||||
}
|
||||
@@ -209,10 +209,10 @@ int idAASLocal::BoundsReachableAreaNum( const idBounds &bounds, const int areaFl
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::PushPointIntoAreaNum
|
||||
idNAVLocal::PushPointIntoAreaNum
|
||||
============
|
||||
*/
|
||||
void idAASLocal::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
|
||||
void idNAVLocal::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.PushPointIntoAreaNum( areaNum, origin );
|
||||
return;
|
||||
@@ -225,10 +225,10 @@ void idAASLocal::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::AreaCenter
|
||||
idNAVLocal::AreaCenter
|
||||
============
|
||||
*/
|
||||
idVec3 idAASLocal::AreaCenter( int areaNum ) const {
|
||||
idVec3 idNAVLocal::AreaCenter( int areaNum ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.AreaCenter( areaNum );
|
||||
}
|
||||
@@ -240,10 +240,10 @@ idVec3 idAASLocal::AreaCenter( int areaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::AreaFlags
|
||||
idNAVLocal::AreaFlags
|
||||
============
|
||||
*/
|
||||
int idAASLocal::AreaFlags( int areaNum ) const {
|
||||
int idNAVLocal::AreaFlags( int areaNum ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.AreaFlags( areaNum );
|
||||
}
|
||||
@@ -255,10 +255,10 @@ int idAASLocal::AreaFlags( int areaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::AreaTravelFlags
|
||||
idNAVLocal::AreaTravelFlags
|
||||
============
|
||||
*/
|
||||
int idAASLocal::AreaTravelFlags( int areaNum ) const {
|
||||
int idNAVLocal::AreaTravelFlags( int areaNum ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.AreaTravelFlags( areaNum );
|
||||
}
|
||||
@@ -270,10 +270,10 @@ int idAASLocal::AreaTravelFlags( int areaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::Trace
|
||||
idNAVLocal::Trace
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const {
|
||||
bool idNAVLocal::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.Trace( trace, start, end );
|
||||
}
|
||||
@@ -288,10 +288,10 @@ bool idAASLocal::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &en
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetPlane
|
||||
idNAVLocal::GetPlane
|
||||
============
|
||||
*/
|
||||
const idPlane &idAASLocal::GetPlane( int planeNum ) const {
|
||||
const idPlane &idNAVLocal::GetPlane( int planeNum ) const {
|
||||
if ( !file ) {
|
||||
static idPlane dummy;
|
||||
return dummy;
|
||||
@@ -301,10 +301,10 @@ const idPlane &idAASLocal::GetPlane( int planeNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetEdgeVertexNumbers
|
||||
idNAVLocal::GetEdgeVertexNumbers
|
||||
============
|
||||
*/
|
||||
void idAASLocal::GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const {
|
||||
void idNAVLocal::GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const {
|
||||
if ( !file ) {
|
||||
verts[0] = verts[1] = 0;
|
||||
return;
|
||||
@@ -316,10 +316,10 @@ void idAASLocal::GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetEdge
|
||||
idNAVLocal::GetEdge
|
||||
============
|
||||
*/
|
||||
void idAASLocal::GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const {
|
||||
void idNAVLocal::GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const {
|
||||
if ( !file ) {
|
||||
start.Zero();
|
||||
end.Zero();
|
||||
@@ -333,10 +333,10 @@ void idAASLocal::GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::AdjustPositionAndGetArea
|
||||
idNAVLocal::AdjustPositionAndGetArea
|
||||
============
|
||||
*/
|
||||
int idAASLocal::AdjustPositionAndGetArea(idVec3& origin)
|
||||
int idNAVLocal::AdjustPositionAndGetArea(idVec3& origin)
|
||||
{
|
||||
int area = PointReachableAreaNum(origin, DefaultSearchBounds(), AREA_REACHABLE_WALK);
|
||||
PushPointIntoAreaNum(area, origin);
|
||||
@@ -26,8 +26,8 @@ If you have questions concerning this license or the applicable additional terms
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __AAS_H__
|
||||
#define __AAS_H__
|
||||
#ifndef __NAV_H__
|
||||
#define __NAV_H__
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
@@ -64,25 +64,25 @@ typedef struct aasObstacle_s {
|
||||
idBounds expAbsBounds; // expanded absolute bounds of obstacle
|
||||
} aasObstacle_t;
|
||||
|
||||
class idAASCallback {
|
||||
class idNAVCallback {
|
||||
public:
|
||||
virtual ~idAASCallback() {};
|
||||
virtual bool AreaIsGoal( const class idAAS *aas, int areaNum ) = 0;
|
||||
virtual ~idNAVCallback() {};
|
||||
virtual bool AreaIsGoal( const class idNAV *aas, int areaNum ) = 0;
|
||||
};
|
||||
|
||||
typedef int aasHandle_t;
|
||||
|
||||
class idAAS {
|
||||
class idNAV {
|
||||
public:
|
||||
static idAAS * Alloc( void );
|
||||
virtual ~idAAS( void ) = 0;
|
||||
static idNAV * Alloc( void );
|
||||
virtual ~idNAV( void ) = 0;
|
||||
// Initialize for the given map.
|
||||
virtual bool Init( const idStr &mapName, unsigned int mapFileCRC ) = 0;
|
||||
// Print AAS stats.
|
||||
// Print NAV stats.
|
||||
virtual void Stats( void ) const = 0;
|
||||
// Test from the given origin.
|
||||
virtual void Test( const idVec3 &origin ) = 0;
|
||||
// Get the AAS settings.
|
||||
// Get the NAV settings.
|
||||
virtual const idAASSettings *GetSettings( void ) const = 0;
|
||||
// Returns the number of the area the origin is in.
|
||||
virtual int PointAreaNum( const idVec3 &origin ) const = 0;
|
||||
@@ -135,12 +135,12 @@ public:
|
||||
// Show the fly path from the origin towards the area.
|
||||
virtual void ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const = 0;
|
||||
// Find the nearest goal which satisfies the callback.
|
||||
virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const = 0;
|
||||
virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idNAVCallback &callback ) const = 0;
|
||||
|
||||
virtual int AdjustPositionAndGetArea(idVec3& origin) = 0;
|
||||
virtual void ShowArea(const idVec3& origin) const = 0;
|
||||
virtual idAASFile* GetAASFile(void) = 0;
|
||||
virtual idAASFile* GetNAVFile(void) = 0;
|
||||
virtual const idBounds& DefaultSearchBounds(void) const = 0;
|
||||
};
|
||||
|
||||
#endif /* !__AAS_H__ */
|
||||
#endif /* !__NAV_H__ */
|
||||
+14
-14
@@ -4,16 +4,16 @@
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
#include "../Game_local.h" // for print and error
|
||||
#include "AASCallback_AvoidLocation.h"
|
||||
#include "NAVCallback_AvoidLocation.h"
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_AvoidLocation::idAASCallback_AvoidLocation
|
||||
idNAVCallback_AvoidLocation::idNAVCallback_AvoidLocation
|
||||
============
|
||||
*/
|
||||
idAASCallback_AvoidLocation::idAASCallback_AvoidLocation()
|
||||
idNAVCallback_AvoidLocation::idNAVCallback_AvoidLocation()
|
||||
{
|
||||
avoidLocation.Zero();
|
||||
avoidDist = 0.0f;
|
||||
@@ -23,19 +23,19 @@ idAASCallback_AvoidLocation::idAASCallback_AvoidLocation()
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_AvoidLocation::~idAASCallback_AvoidLocation
|
||||
idNAVCallback_AvoidLocation::~idNAVCallback_AvoidLocation
|
||||
============
|
||||
*/
|
||||
idAASCallback_AvoidLocation::~idAASCallback_AvoidLocation()
|
||||
idNAVCallback_AvoidLocation::~idNAVCallback_AvoidLocation()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_AvoidLocation::SetAvoidLocation
|
||||
idNAVCallback_AvoidLocation::SetAvoidLocation
|
||||
============
|
||||
*/
|
||||
void idAASCallback_AvoidLocation::SetAvoidLocation( const idVec3& start, const idVec3& avoidLocation )
|
||||
void idNAVCallback_AvoidLocation::SetAvoidLocation( const idVec3& start, const idVec3& avoidLocation )
|
||||
{
|
||||
this->avoidLocation = avoidLocation;
|
||||
this->avoidDist = ( avoidLocation - start ).Length();
|
||||
@@ -43,10 +43,10 @@ void idAASCallback_AvoidLocation::SetAvoidLocation( const idVec3& start, const i
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_AvoidLocation::SetObstacles
|
||||
idNAVCallback_AvoidLocation::SetObstacles
|
||||
============
|
||||
*/
|
||||
void idAASCallback_AvoidLocation::SetObstacles( const idAAS* aas, const idAASObstacle* obstacles, int numObstacles )
|
||||
void idNAVCallback_AvoidLocation::SetObstacles( const idNAV* aas, const idNAVObstacle* obstacles, int numObstacles )
|
||||
{
|
||||
this->obstacles = obstacles;
|
||||
this->numObstacles = numObstacles;
|
||||
@@ -60,10 +60,10 @@ void idAASCallback_AvoidLocation::SetObstacles( const idAAS* aas, const idAASObs
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_AvoidLocation::PathValid
|
||||
idNAVCallback_AvoidLocation::PathValid
|
||||
============
|
||||
*/
|
||||
bool idAASCallback_AvoidLocation::PathValid( const idAAS* aas, const idVec3& start, const idVec3& end )
|
||||
bool idNAVCallback_AvoidLocation::PathValid( const idNAV* aas, const idVec3& start, const idVec3& end )
|
||||
{
|
||||
// path may not go through any obstacles
|
||||
for( int i = 0; i < numObstacles; i++ )
|
||||
@@ -79,10 +79,10 @@ bool idAASCallback_AvoidLocation::PathValid( const idAAS* aas, const idVec3& sta
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_AvoidLocation::AdditionalTravelTimeForPath
|
||||
idNAVCallback_AvoidLocation::AdditionalTravelTimeForPath
|
||||
============
|
||||
*/
|
||||
int idAASCallback_AvoidLocation::AdditionalTravelTimeForPath( const idAAS* aas, const idVec3& start, const idVec3& end )
|
||||
int idNAVCallback_AvoidLocation::AdditionalTravelTimeForPath( const idNAV* aas, const idVec3& start, const idVec3& end )
|
||||
{
|
||||
if( avoidDist <= 0.0f )
|
||||
{
|
||||
+13
-13
@@ -1,41 +1,41 @@
|
||||
// Copyright (C) 2007 Id Software, Inc.
|
||||
//
|
||||
|
||||
#ifndef __AASCALLBACK_AVOIDLOCATION_H__
|
||||
#define __AASCALLBACK_AVOIDLOCATION_H__
|
||||
#ifndef __NAVCALLBACK_AVOIDLOCATION_H__
|
||||
#define __NAVCALLBACK_AVOIDLOCATION_H__
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
idAASCallback_AvoidLocation
|
||||
idNAVCallback_AvoidLocation
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
struct idAASObstacle
|
||||
struct idNAVObstacle
|
||||
{
|
||||
idBounds absBounds; // absolute bounds of obstacle
|
||||
mutable idBounds expAbsBounds; // expanded absolute bounds of obstacle
|
||||
};
|
||||
|
||||
class idAASCallback_AvoidLocation : public idAASCallback
|
||||
class idNAVCallback_AvoidLocation : public idNAVCallback
|
||||
{
|
||||
public:
|
||||
idAASCallback_AvoidLocation();
|
||||
~idAASCallback_AvoidLocation();
|
||||
idNAVCallback_AvoidLocation();
|
||||
~idNAVCallback_AvoidLocation();
|
||||
|
||||
void SetAvoidLocation( const idVec3& start, const idVec3& avoidLocation );
|
||||
void SetObstacles( const idAAS* aas, const idAASObstacle* obstacles, int numObstacles );
|
||||
void SetObstacles( const idNAV* aas, const idNAVObstacle* obstacles, int numObstacles );
|
||||
|
||||
virtual bool PathValid( const idAAS* aas, const idVec3& start, const idVec3& end );
|
||||
virtual int AdditionalTravelTimeForPath( const idAAS* aas, const idVec3& start, const idVec3& end );
|
||||
virtual bool AreaIsGoal( const idAAS* aas, int areaNum ) = 0;
|
||||
virtual bool PathValid( const idNAV* aas, const idVec3& start, const idVec3& end );
|
||||
virtual int AdditionalTravelTimeForPath( const idNAV* aas, const idVec3& start, const idVec3& end );
|
||||
virtual bool AreaIsGoal( const idNAV* aas, int areaNum ) = 0;
|
||||
|
||||
private:
|
||||
idVec3 avoidLocation;
|
||||
float avoidDist;
|
||||
const idAASObstacle* obstacles;
|
||||
const idNAVObstacle* obstacles;
|
||||
int numObstacles;
|
||||
};
|
||||
|
||||
#endif /* !__AASCALLBACK_AVOIDLOCATION_H__ */
|
||||
#endif /* !__NAVCALLBACK_AVOIDLOCATION_H__ */
|
||||
+6
-6
@@ -4,17 +4,17 @@
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
#include "../Game_local.h" // for print and error
|
||||
|
||||
#include "AASCallback_FindAreaOutOfRange.h"
|
||||
#include "NAVCallback_FindAreaOutOfRange.h"
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_FindAreaOutOfRange::idAASCallback_FindAreaOutOfRange
|
||||
idNAVCallback_FindAreaOutOfRange::idNAVCallback_FindAreaOutOfRange
|
||||
============
|
||||
*/
|
||||
idAASCallback_FindAreaOutOfRange::idAASCallback_FindAreaOutOfRange( const idVec3& targetPos, float maxDist )
|
||||
idNAVCallback_FindAreaOutOfRange::idNAVCallback_FindAreaOutOfRange( const idVec3& targetPos, float maxDist )
|
||||
{
|
||||
this->targetPos = targetPos;
|
||||
this->maxDistSqr = maxDist * maxDist;
|
||||
@@ -22,10 +22,10 @@ idAASCallback_FindAreaOutOfRange::idAASCallback_FindAreaOutOfRange( const idVec3
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_FindAreaOutOfRange::AreaIsGoal
|
||||
idNAVCallback_FindAreaOutOfRange::AreaIsGoal
|
||||
============
|
||||
*/
|
||||
bool idAASCallback_FindAreaOutOfRange::AreaIsGoal( const idAAS* aas, int areaNum )
|
||||
bool idNAVCallback_FindAreaOutOfRange::AreaIsGoal( const idNAV* aas, int areaNum )
|
||||
{
|
||||
const idVec3& areaCenter = aas->AreaCenter( areaNum );
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2007 Id Software, Inc.
|
||||
//
|
||||
|
||||
#ifndef __NAVCALLBACK_FINDAREAOUTOFRANGE_H__
|
||||
#define __NAVCALLBACK_FINDAREAOUTOFRANGE_H__
|
||||
|
||||
#include "NAVCallback_AvoidLocation.h"
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
idNAVCallback_FindAreaOutOfRange
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
class idNAVCallback_FindAreaOutOfRange : public idNAVCallback_AvoidLocation
|
||||
{
|
||||
public:
|
||||
idNAVCallback_FindAreaOutOfRange( const idVec3& targetPos, float maxDist );
|
||||
|
||||
virtual bool AreaIsGoal( const idNAV* aas, int areaNum );
|
||||
|
||||
private:
|
||||
idVec3 targetPos;
|
||||
float maxDistSqr;
|
||||
};
|
||||
|
||||
#endif /* !__NAVCALLBACK_FINDAREAOUTOFRANGE_H__ */
|
||||
+8
-8
@@ -1,16 +1,16 @@
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
#include "../Game_local.h"
|
||||
#include "AASCallback_FindAttackPosition.h"
|
||||
#include "NAVCallback_FindAttackPosition.h"
|
||||
|
||||
/*
|
||||
============
|
||||
idAASFindAttackPosition::idAASFindAttackPosition
|
||||
idNAVFindAttackPosition::idNAVFindAttackPosition
|
||||
============
|
||||
*/
|
||||
idAASFindAttackPosition::idAASFindAttackPosition(const idAI* self, const idMat3& gravityAxis, idEntity* target, const idVec3& targetPos, const idVec3& fireOffset) {
|
||||
idNAVFindAttackPosition::idNAVFindAttackPosition(const idAI* self, const idMat3& gravityAxis, idEntity* target, const idVec3& targetPos, const idVec3& fireOffset) {
|
||||
int numPVSAreas;
|
||||
|
||||
this->target = target;
|
||||
@@ -30,19 +30,19 @@ idAASFindAttackPosition::idAASFindAttackPosition(const idAI* self, const idMat3&
|
||||
|
||||
/*
|
||||
============
|
||||
idAASFindAttackPosition::~idAASFindAttackPosition
|
||||
idNAVFindAttackPosition::~idNAVFindAttackPosition
|
||||
============
|
||||
*/
|
||||
idAASFindAttackPosition::~idAASFindAttackPosition() {
|
||||
idNAVFindAttackPosition::~idNAVFindAttackPosition() {
|
||||
gameLocal.pvs.FreeCurrentPVS(targetPVS);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASFindAttackPosition::TestArea
|
||||
idNAVFindAttackPosition::TestArea
|
||||
============
|
||||
*/
|
||||
bool idAASFindAttackPosition::AreaIsGoal(const idAAS* aas, int areaNum) {
|
||||
bool idNAVFindAttackPosition::AreaIsGoal(const idNAV* aas, int areaNum) {
|
||||
idVec3 dir;
|
||||
idVec3 local_dir;
|
||||
idVec3 fromPos;
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
class idAASFindAttackPosition : public idAASCallback {
|
||||
class idNAVFindAttackPosition : public idNAVCallback {
|
||||
public:
|
||||
idAASFindAttackPosition(const idAI* self, const idMat3& gravityAxis, idEntity* target, const idVec3& targetPos, const idVec3& fireOffset);
|
||||
~idAASFindAttackPosition();
|
||||
idNAVFindAttackPosition(const idAI* self, const idMat3& gravityAxis, idEntity* target, const idVec3& targetPos, const idVec3& fireOffset);
|
||||
~idNAVFindAttackPosition();
|
||||
|
||||
virtual bool AreaIsGoal(const idAAS* aas, int areaNum);
|
||||
virtual bool AreaIsGoal(const idNAV* aas, int areaNum);
|
||||
|
||||
private:
|
||||
const idAI* self;
|
||||
+8
-8
@@ -4,17 +4,17 @@
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
#include "../Game_local.h" // for print and error
|
||||
|
||||
#include "AASCallback_FindCoverArea.h"
|
||||
#include "NAVCallback_FindCoverArea.h"
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_FindCoverArea::idAASCallback_FindCoverArea
|
||||
idNAVCallback_FindCoverArea::idNAVCallback_FindCoverArea
|
||||
============
|
||||
*/
|
||||
idAASCallback_FindCoverArea::idAASCallback_FindCoverArea( const idVec3& hideFromPos )
|
||||
idNAVCallback_FindCoverArea::idNAVCallback_FindCoverArea( const idVec3& hideFromPos )
|
||||
{
|
||||
int numPVSAreas;
|
||||
idBounds bounds( hideFromPos - idVec3( 16, 16, 0 ), hideFromPos + idVec3( 16, 16, 64 ) );
|
||||
@@ -26,20 +26,20 @@ idAASCallback_FindCoverArea::idAASCallback_FindCoverArea( const idVec3& hideFrom
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_FindCoverArea::~idAASCallback_FindCoverArea
|
||||
idNAVCallback_FindCoverArea::~idNAVCallback_FindCoverArea
|
||||
============
|
||||
*/
|
||||
idAASCallback_FindCoverArea::~idAASCallback_FindCoverArea()
|
||||
idNAVCallback_FindCoverArea::~idNAVCallback_FindCoverArea()
|
||||
{
|
||||
gameLocal.pvs.FreeCurrentPVS( hidePVS );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASCallback_FindCoverArea::AreaIsGoal
|
||||
idNAVCallback_FindCoverArea::AreaIsGoal
|
||||
============
|
||||
*/
|
||||
bool idAASCallback_FindCoverArea::AreaIsGoal( const idAAS* aas, int areaNum )
|
||||
bool idNAVCallback_FindCoverArea::AreaIsGoal( const idNAV* aas, int areaNum )
|
||||
{
|
||||
idVec3 areaCenter;
|
||||
int numPVSAreas;
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2007 Id Software, Inc.
|
||||
//
|
||||
|
||||
#ifndef __NAVCALLBACK_FINDCOVERAREA_H__
|
||||
#define __NAVCALLBACK_FINDCOVERAREA_H__
|
||||
|
||||
#include "NAVCallback_AvoidLocation.h"
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
idNAVCallback_FindCoverArea
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
class idNAVCallback_FindCoverArea : public idNAVCallback_AvoidLocation
|
||||
{
|
||||
public:
|
||||
idNAVCallback_FindCoverArea( const idVec3& hideFromPos );
|
||||
~idNAVCallback_FindCoverArea();
|
||||
|
||||
virtual bool AreaIsGoal( const idNAV* aas, int areaNum );
|
||||
|
||||
private:
|
||||
static const int MAX_PVS_AREAS = 4;
|
||||
|
||||
pvsHandle_t hidePVS;
|
||||
int PVSAreas[ MAX_PVS_AREAS ];
|
||||
};
|
||||
|
||||
#endif /* !__NAVCALLBACK_FINDCOVERAREA_H__ */
|
||||
@@ -29,16 +29,16 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
#include "../Game_local.h" // for cvars and debug drawing
|
||||
#include "AASCallback_FindCoverArea.h"
|
||||
#include "NAVCallback_FindCoverArea.h"
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DrawCone
|
||||
idNAVLocal::DrawCone
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DrawCone( const idVec3 &origin, const idVec3 &dir, float radius, const idVec4 &color ) const {
|
||||
void idNAVLocal::DrawCone( const idVec3 &origin, const idVec3 &dir, float radius, const idVec4 &color ) const {
|
||||
int i;
|
||||
idMat3 axis;
|
||||
idVec3 center, top, p, lastp;
|
||||
@@ -61,10 +61,10 @@ void idAASLocal::DrawCone( const idVec3 &origin, const idVec3 &dir, float radius
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DrawReachability
|
||||
idNAVLocal::DrawReachability
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DrawReachability( const idReachability *reach ) const {
|
||||
void idNAVLocal::DrawReachability( const idReachability *reach ) const {
|
||||
gameRenderWorld->DebugArrow( colorCyan, reach->start, reach->end, 2 );
|
||||
|
||||
if ( gameLocal.GetLocalPlayer() ) {
|
||||
@@ -84,10 +84,10 @@ void idAASLocal::DrawReachability( const idReachability *reach ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DrawEdge
|
||||
idNAVLocal::DrawEdge
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DrawEdge( int edgeNum, bool arrow ) const {
|
||||
void idNAVLocal::DrawEdge( int edgeNum, bool arrow ) const {
|
||||
const aasEdge_t *edge;
|
||||
idVec4 *color;
|
||||
|
||||
@@ -110,10 +110,10 @@ void idAASLocal::DrawEdge( int edgeNum, bool arrow ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DrawFace
|
||||
idNAVLocal::DrawFace
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DrawFace( int faceNum, bool side ) const {
|
||||
void idNAVLocal::DrawFace( int faceNum, bool side ) const {
|
||||
int i, j, numEdges, firstEdge;
|
||||
const aasFace_t *face;
|
||||
idVec3 mid, end;
|
||||
@@ -144,10 +144,10 @@ void idAASLocal::DrawFace( int faceNum, bool side ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DrawArea
|
||||
idNAVLocal::DrawArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DrawArea( int areaNum ) const {
|
||||
void idNAVLocal::DrawArea( int areaNum ) const {
|
||||
int i, numFaces, firstFace;
|
||||
const aasArea_t *area;
|
||||
idReachability *reach;
|
||||
@@ -171,10 +171,10 @@ void idAASLocal::DrawArea( int areaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DefaultSearchBounds
|
||||
idNAVLocal::DefaultSearchBounds
|
||||
============
|
||||
*/
|
||||
const idBounds &idAASLocal::DefaultSearchBounds( void ) const {
|
||||
const idBounds &idNAVLocal::DefaultSearchBounds( void ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.GetSettings()->boundingBoxes[0];
|
||||
}
|
||||
@@ -183,10 +183,10 @@ const idBounds &idAASLocal::DefaultSearchBounds( void ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShowArea
|
||||
idNAVLocal::ShowArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShowArea( const idVec3 &origin ) const {
|
||||
void idNAVLocal::ShowArea( const idVec3 &origin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.ShowArea( origin );
|
||||
return;
|
||||
@@ -200,11 +200,11 @@ void idAASLocal::ShowArea( const idVec3 &origin ) const {
|
||||
org = origin;
|
||||
PushPointIntoAreaNum( areaNum, org );
|
||||
|
||||
if ( aas_goalArea.GetInteger() ) {
|
||||
if ( nav_goalArea.GetInteger() ) {
|
||||
int travelTime;
|
||||
idReachability *reach;
|
||||
|
||||
RouteToGoalArea( areaNum, org, aas_goalArea.GetInteger(), TFL_WALK|TFL_AIR, travelTime, &reach );
|
||||
RouteToGoalArea( areaNum, org, nav_goalArea.GetInteger(), TFL_WALK|TFL_AIR, travelTime, &reach );
|
||||
gameLocal.Printf( "\rtt = %4d", travelTime );
|
||||
if ( reach ) {
|
||||
gameLocal.Printf( " to area %4d", reach->toAreaNum );
|
||||
@@ -245,10 +245,10 @@ void idAASLocal::ShowArea( const idVec3 &origin ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShowWalkPath
|
||||
idNAVLocal::ShowWalkPath
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const {
|
||||
void idNAVLocal::ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.ShowPath( origin, goalAreaNum, goalOrigin );
|
||||
return;
|
||||
@@ -295,10 +295,10 @@ void idAASLocal::ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVe
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShowFlyPath
|
||||
idNAVLocal::ShowFlyPath
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const {
|
||||
void idNAVLocal::ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.ShowPath( origin, goalAreaNum, goalOrigin );
|
||||
return;
|
||||
@@ -345,10 +345,10 @@ void idAASLocal::ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShowWallEdges
|
||||
idNAVLocal::ShowWallEdges
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShowWallEdges( const idVec3 &origin ) const {
|
||||
void idNAVLocal::ShowWallEdges( const idVec3 &origin ) const {
|
||||
int i, areaNum, numEdges, edges[1024];
|
||||
idVec3 start, end;
|
||||
idPlayer *player;
|
||||
@@ -369,10 +369,10 @@ void idAASLocal::ShowWallEdges( const idVec3 &origin ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShowHideArea
|
||||
idNAVLocal::ShowHideArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShowHideArea( const idVec3 &origin, int targetAreaNum ) const {
|
||||
void idNAVLocal::ShowHideArea( const idVec3 &origin, int targetAreaNum ) const {
|
||||
int areaNum, numObstacles;
|
||||
idVec3 target;
|
||||
aasGoal_t goal;
|
||||
@@ -387,7 +387,7 @@ void idAASLocal::ShowHideArea( const idVec3 &origin, int targetAreaNum ) const {
|
||||
|
||||
DrawCone( target, idVec3(0,0,1), 16.0f, colorYellow );
|
||||
|
||||
idAASCallback_FindCoverArea findCover( target );
|
||||
idNAVCallback_FindCoverArea findCover( target );
|
||||
if ( FindNearestGoal( goal, areaNum, origin, target, TFL_WALK|TFL_AIR, obstacles, numObstacles, findCover ) ) {
|
||||
DrawArea( goal.areaNum );
|
||||
ShowWalkPath( origin, goal.areaNum, goal.origin );
|
||||
@@ -397,10 +397,10 @@ void idAASLocal::ShowHideArea( const idVec3 &origin, int targetAreaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::PullPlayer
|
||||
idNAVLocal::PullPlayer
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::PullPlayer( const idVec3 &origin, int toAreaNum ) const {
|
||||
bool idNAVLocal::PullPlayer( const idVec3 &origin, int toAreaNum ) const {
|
||||
int areaNum;
|
||||
idVec3 areaCenter, dir, vel;
|
||||
idAngles delta;
|
||||
@@ -448,33 +448,33 @@ bool idAASLocal::PullPlayer( const idVec3 &origin, int toAreaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::RandomPullPlayer
|
||||
idNAVLocal::RandomPullPlayer
|
||||
============
|
||||
*/
|
||||
void idAASLocal::RandomPullPlayer( const idVec3 &origin ) const {
|
||||
void idNAVLocal::RandomPullPlayer( const idVec3 &origin ) const {
|
||||
int rnd, i, n;
|
||||
|
||||
if ( !PullPlayer( origin, aas_pullPlayer.GetInteger() ) ) {
|
||||
if ( !PullPlayer( origin, nav_pullPlayer.GetInteger() ) ) {
|
||||
|
||||
rnd = gameLocal.random.RandomFloat() * file->GetNumAreas();
|
||||
|
||||
for ( i = 0; i < file->GetNumAreas(); i++ ) {
|
||||
n = (rnd + i) % file->GetNumAreas();
|
||||
if ( file->GetArea( n ).flags & (AREA_REACHABLE_WALK|AREA_REACHABLE_FLY) ) {
|
||||
aas_pullPlayer.SetInteger( n );
|
||||
nav_pullPlayer.SetInteger( n );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ShowWalkPath( origin, aas_pullPlayer.GetInteger(), AreaCenter( aas_pullPlayer.GetInteger() ) );
|
||||
ShowWalkPath( origin, nav_pullPlayer.GetInteger(), AreaCenter( nav_pullPlayer.GetInteger() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShowPushIntoArea
|
||||
idNAVLocal::ShowPushIntoArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShowPushIntoArea( const idVec3 &origin ) const {
|
||||
void idNAVLocal::ShowPushIntoArea( const idVec3 &origin ) const {
|
||||
int areaNum;
|
||||
idVec3 target;
|
||||
|
||||
@@ -486,23 +486,23 @@ void idAASLocal::ShowPushIntoArea( const idVec3 &origin ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::Test
|
||||
idNAVLocal::Test
|
||||
============
|
||||
*/
|
||||
void idAASLocal::Test( const idVec3 &origin ) {
|
||||
void idNAVLocal::Test( const idVec3 &origin ) {
|
||||
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
if ( aas_showRecastNavMesh.GetInteger() > 0 ) {
|
||||
recastNavMesh.DebugDraw( aas_showRecastNavMesh.GetInteger() );
|
||||
if ( nav_showRecastNavMesh.GetInteger() > 0 ) {
|
||||
recastNavMesh.DebugDraw( nav_showRecastNavMesh.GetInteger() );
|
||||
}
|
||||
if ( aas_showAreas.GetBool() ) {
|
||||
if ( nav_showAreas.GetBool() ) {
|
||||
ShowArea( origin );
|
||||
}
|
||||
if ( aas_showPath.GetInteger() > 0 ) {
|
||||
ShowWalkPath( origin, aas_showPath.GetInteger(), AreaCenter( aas_showPath.GetInteger() ) );
|
||||
if ( nav_showPath.GetInteger() > 0 ) {
|
||||
ShowWalkPath( origin, nav_showPath.GetInteger(), AreaCenter( nav_showPath.GetInteger() ) );
|
||||
}
|
||||
if ( aas_showFlyPath.GetInteger() > 0 ) {
|
||||
ShowFlyPath( origin, aas_showFlyPath.GetInteger(), AreaCenter( aas_showFlyPath.GetInteger() ) );
|
||||
if ( nav_showFlyPath.GetInteger() > 0 ) {
|
||||
ShowFlyPath( origin, nav_showFlyPath.GetInteger(), AreaCenter( nav_showFlyPath.GetInteger() ) );
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -511,29 +511,29 @@ void idAASLocal::Test( const idVec3 &origin ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( aas_randomPullPlayer.GetBool() ) {
|
||||
if ( nav_randomPullPlayer.GetBool() ) {
|
||||
RandomPullPlayer( origin );
|
||||
}
|
||||
if ( ( aas_pullPlayer.GetInteger() > 0 ) && ( aas_pullPlayer.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowWalkPath( origin, aas_pullPlayer.GetInteger(), AreaCenter( aas_pullPlayer.GetInteger() ) );
|
||||
PullPlayer( origin, aas_pullPlayer.GetInteger() );
|
||||
if ( ( nav_pullPlayer.GetInteger() > 0 ) && ( nav_pullPlayer.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowWalkPath( origin, nav_pullPlayer.GetInteger(), AreaCenter( nav_pullPlayer.GetInteger() ) );
|
||||
PullPlayer( origin, nav_pullPlayer.GetInteger() );
|
||||
}
|
||||
if ( ( aas_showPath.GetInteger() > 0 ) && ( aas_showPath.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowWalkPath( origin, aas_showPath.GetInteger(), AreaCenter( aas_showPath.GetInteger() ) );
|
||||
if ( ( nav_showPath.GetInteger() > 0 ) && ( nav_showPath.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowWalkPath( origin, nav_showPath.GetInteger(), AreaCenter( nav_showPath.GetInteger() ) );
|
||||
}
|
||||
if ( ( aas_showFlyPath.GetInteger() > 0 ) && ( aas_showFlyPath.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowFlyPath( origin, aas_showFlyPath.GetInteger(), AreaCenter( aas_showFlyPath.GetInteger() ) );
|
||||
if ( ( nav_showFlyPath.GetInteger() > 0 ) && ( nav_showFlyPath.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowFlyPath( origin, nav_showFlyPath.GetInteger(), AreaCenter( nav_showFlyPath.GetInteger() ) );
|
||||
}
|
||||
if ( ( aas_showHideArea.GetInteger() > 0 ) && ( aas_showHideArea.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowHideArea( origin, aas_showHideArea.GetInteger() );
|
||||
if ( ( nav_showHideArea.GetInteger() > 0 ) && ( nav_showHideArea.GetInteger() < file->GetNumAreas() ) ) {
|
||||
ShowHideArea( origin, nav_showHideArea.GetInteger() );
|
||||
}
|
||||
if ( aas_showAreas.GetBool() ) {
|
||||
if ( nav_showAreas.GetBool() ) {
|
||||
ShowArea( origin );
|
||||
}
|
||||
if ( aas_showWallEdges.GetBool() ) {
|
||||
if ( nav_showWallEdges.GetBool() ) {
|
||||
ShowWallEdges( origin );
|
||||
}
|
||||
if ( aas_showPushIntoArea.GetBool() ) {
|
||||
if ( nav_showPushIntoArea.GetBool() ) {
|
||||
ShowPushIntoArea( origin );
|
||||
}
|
||||
}
|
||||
@@ -26,16 +26,16 @@ If you have questions concerning this license or the applicable additional terms
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __AAS_LOCAL_H__
|
||||
#define __AAS_LOCAL_H__
|
||||
#ifndef __NAV_LOCAL_H__
|
||||
#define __NAV_LOCAL_H__
|
||||
|
||||
#include "AAS.h"
|
||||
#include "NAV.h"
|
||||
#include "../Pvs.h"
|
||||
#include "RecastNavMesh.h"
|
||||
|
||||
|
||||
class idRoutingCache {
|
||||
friend class idAASLocal;
|
||||
friend class idNAVLocal;
|
||||
|
||||
public:
|
||||
idRoutingCache( int size );
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
|
||||
|
||||
class idRoutingUpdate {
|
||||
friend class idAASLocal;
|
||||
friend class idNAVLocal;
|
||||
|
||||
private:
|
||||
int cluster; // cluster number of this update
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
|
||||
|
||||
class idRoutingObstacle {
|
||||
friend class idAASLocal;
|
||||
friend class idNAVLocal;
|
||||
idRoutingObstacle( void ) { }
|
||||
|
||||
private:
|
||||
@@ -84,10 +84,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class idAASLocal : public idAAS {
|
||||
class idNAVLocal : public idNAV {
|
||||
public:
|
||||
idAASLocal( void );
|
||||
virtual ~idAASLocal( void );
|
||||
idNAVLocal( void );
|
||||
virtual ~idNAVLocal( void );
|
||||
virtual bool Init( const idStr &mapName, unsigned int mapFileCRC );
|
||||
virtual void Shutdown( void );
|
||||
virtual void Stats( void ) const;
|
||||
@@ -118,10 +118,10 @@ public:
|
||||
virtual bool FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const;
|
||||
virtual void ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const;
|
||||
virtual void ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const;
|
||||
virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const;
|
||||
virtual bool FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idNAVCallback &callback ) const;
|
||||
virtual int AdjustPositionAndGetArea(idVec3& origin);
|
||||
virtual void ShowArea(const idVec3& origin) const;
|
||||
virtual idAASFile* GetAASFile(void) { return file; }
|
||||
virtual idAASFile* GetNAVFile(void) { return file; }
|
||||
virtual const idBounds& DefaultSearchBounds(void) const;
|
||||
private:
|
||||
idAASFile * file;
|
||||
@@ -189,4 +189,4 @@ private: // debug
|
||||
void ShowPushIntoArea( const idVec3 &origin ) const;
|
||||
};
|
||||
|
||||
#endif /* !__AAS_LOCAL_H__ */
|
||||
#endif /* !__NAV_LOCAL_H__ */
|
||||
@@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
|
||||
#define SUBSAMPLE_WALK_PATH 1
|
||||
#define SUBSAMPLE_FLY_PATH 0
|
||||
@@ -45,13 +45,13 @@ const float flyPathSampleDistance = 8.0f;
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::EdgeSplitPoint
|
||||
idNAVLocal::EdgeSplitPoint
|
||||
|
||||
calculates split point of the edge with the plane
|
||||
returns true if the split point is between the edge vertices
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::EdgeSplitPoint( idVec3 &split, int edgeNum, const idPlane &plane ) const {
|
||||
bool idNAVLocal::EdgeSplitPoint( idVec3 &split, int edgeNum, const idPlane &plane ) const {
|
||||
const aasEdge_t *edge;
|
||||
idVec3 v1, v2;
|
||||
float d1, d2;
|
||||
@@ -72,13 +72,13 @@ bool idAASLocal::EdgeSplitPoint( idVec3 &split, int edgeNum, const idPlane &plan
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::FloorEdgeSplitPoint
|
||||
idNAVLocal::FloorEdgeSplitPoint
|
||||
|
||||
calculates either the closest or furthest point on the floor of the area which also lies on the pathPlane
|
||||
the point has to be on the front side of the frontPlane to be valid
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::FloorEdgeSplitPoint( idVec3 &bestSplit, int areaNum, const idPlane &pathPlane, const idPlane &frontPlane, bool closest ) const {
|
||||
bool idNAVLocal::FloorEdgeSplitPoint( idVec3 &bestSplit, int areaNum, const idPlane &pathPlane, const idPlane &frontPlane, bool closest ) const {
|
||||
int i, j, faceNum, edgeNum;
|
||||
const aasArea_t *area;
|
||||
const aasFace_t *face;
|
||||
@@ -131,12 +131,12 @@ bool idAASLocal::FloorEdgeSplitPoint( idVec3 &bestSplit, int areaNum, const idPl
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::WalkPathValid
|
||||
idNAVLocal::WalkPathValid
|
||||
|
||||
returns true if one can walk in a straight line between origin and goalOrigin
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::WalkPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const {
|
||||
bool idNAVLocal::WalkPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const {
|
||||
int curAreaNum, lastAreaNum, lastAreas[4], lastAreaIndex;
|
||||
idPlane pathPlane, frontPlane, farPlane;
|
||||
idReachability *reach;
|
||||
@@ -250,10 +250,10 @@ bool idAASLocal::WalkPathValid( int areaNum, const idVec3 &origin, int goalAreaN
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SubSampleWalkPath
|
||||
idNAVLocal::SubSampleWalkPath
|
||||
============
|
||||
*/
|
||||
idVec3 idAASLocal::SubSampleWalkPath( int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum ) const {
|
||||
idVec3 idNAVLocal::SubSampleWalkPath( int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum ) const {
|
||||
int i, numSamples, curAreaNum;
|
||||
idVec3 dir, point, nextPoint, endPos;
|
||||
|
||||
@@ -266,7 +266,7 @@ idVec3 idAASLocal::SubSampleWalkPath( int areaNum, const idVec3 &origin, const i
|
||||
if ( (point - nextPoint).LengthSqr() > Square( maxWalkPathDistance ) ) {
|
||||
return point;
|
||||
}
|
||||
if ( !idAASLocal::WalkPathValid( areaNum, origin, 0, nextPoint, travelFlags, endPos, curAreaNum ) ) {
|
||||
if ( !idNAVLocal::WalkPathValid( areaNum, origin, 0, nextPoint, travelFlags, endPos, curAreaNum ) ) {
|
||||
return point;
|
||||
}
|
||||
point = nextPoint;
|
||||
@@ -277,12 +277,12 @@ idVec3 idAASLocal::SubSampleWalkPath( int areaNum, const idVec3 &origin, const i
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::WalkPathToGoal
|
||||
idNAVLocal::WalkPathToGoal
|
||||
|
||||
FIXME: don't stop optimizing on first failure ?
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const {
|
||||
bool idNAVLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const {
|
||||
int i, travelTime, curAreaNum, lastAreas[4], lastAreaIndex, endAreaNum;
|
||||
idReachability *reach;
|
||||
idVec3 endPos;
|
||||
@@ -309,7 +309,7 @@ bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &ori
|
||||
|
||||
for ( i = 0; i < maxWalkPathIterations; i++ ) {
|
||||
|
||||
if ( !idAASLocal::RouteToGoalArea( curAreaNum, path.moveGoal, goalAreaNum, travelFlags, travelTime, &reach ) ) {
|
||||
if ( !idNAVLocal::RouteToGoalArea( curAreaNum, path.moveGoal, goalAreaNum, travelFlags, travelTime, &reach ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &ori
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !idAASLocal::WalkPathValid( areaNum, origin, 0, reach->start, travelFlags, endPos, endAreaNum ) ) {
|
||||
if ( !idNAVLocal::WalkPathValid( areaNum, origin, 0, reach->start, travelFlags, endPos, endAreaNum ) ) {
|
||||
#if SUBSAMPLE_WALK_PATH
|
||||
path.moveGoal = SubSampleWalkPath( areaNum, origin, path.moveGoal, reach->start, travelFlags, path.moveAreaNum );
|
||||
#endif
|
||||
@@ -342,7 +342,7 @@ bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &ori
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !idAASLocal::WalkPathValid( areaNum, origin, 0, reach->end, travelFlags, endPos, endAreaNum ) ) {
|
||||
if ( !idNAVLocal::WalkPathValid( areaNum, origin, 0, reach->end, travelFlags, endPos, endAreaNum ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &ori
|
||||
path.moveAreaNum = reach->toAreaNum;
|
||||
|
||||
if ( reach->toAreaNum == goalAreaNum ) {
|
||||
if ( !idAASLocal::WalkPathValid( areaNum, origin, 0, goalOrigin, travelFlags, endPos, endAreaNum ) ) {
|
||||
if ( !idNAVLocal::WalkPathValid( areaNum, origin, 0, goalOrigin, travelFlags, endPos, endAreaNum ) ) {
|
||||
#if SUBSAMPLE_WALK_PATH
|
||||
path.moveGoal = SubSampleWalkPath( areaNum, origin, path.moveGoal, goalOrigin, travelFlags, path.moveAreaNum );
|
||||
#endif
|
||||
@@ -368,7 +368,7 @@ bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &ori
|
||||
|
||||
if ( curAreaNum == lastAreas[0] || curAreaNum == lastAreas[1] ||
|
||||
curAreaNum == lastAreas[2] || curAreaNum == lastAreas[3] ) {
|
||||
common->Warning( "idAASLocal::WalkPathToGoal: local routing minimum going from area %d to area %d", areaNum, goalAreaNum );
|
||||
common->Warning( "idNAVLocal::WalkPathToGoal: local routing minimum going from area %d to area %d", areaNum, goalAreaNum );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -402,12 +402,12 @@ bool idAASLocal::WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &ori
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::FlyPathValid
|
||||
idNAVLocal::FlyPathValid
|
||||
|
||||
returns true if one can fly in a straight line between origin and goalOrigin
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const {
|
||||
bool idNAVLocal::FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const {
|
||||
aasTrace_t trace;
|
||||
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
@@ -434,10 +434,10 @@ bool idAASLocal::FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNu
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SubSampleFlyPath
|
||||
idNAVLocal::SubSampleFlyPath
|
||||
============
|
||||
*/
|
||||
idVec3 idAASLocal::SubSampleFlyPath( int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum ) const {
|
||||
idVec3 idNAVLocal::SubSampleFlyPath( int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum ) const {
|
||||
int i, numSamples, curAreaNum;
|
||||
idVec3 dir, point, nextPoint, endPos;
|
||||
|
||||
@@ -450,7 +450,7 @@ idVec3 idAASLocal::SubSampleFlyPath( int areaNum, const idVec3 &origin, const id
|
||||
if ( (point - nextPoint).LengthSqr() > Square( maxFlyPathDistance ) ) {
|
||||
return point;
|
||||
}
|
||||
if ( !idAASLocal::FlyPathValid( areaNum, origin, 0, nextPoint, travelFlags, endPos, curAreaNum ) ) {
|
||||
if ( !idNAVLocal::FlyPathValid( areaNum, origin, 0, nextPoint, travelFlags, endPos, curAreaNum ) ) {
|
||||
return point;
|
||||
}
|
||||
point = nextPoint;
|
||||
@@ -461,12 +461,12 @@ idVec3 idAASLocal::SubSampleFlyPath( int areaNum, const idVec3 &origin, const id
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::FlyPathToGoal
|
||||
idNAVLocal::FlyPathToGoal
|
||||
|
||||
FIXME: don't stop optimizing on first failure ?
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const {
|
||||
bool idNAVLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const {
|
||||
int i, travelTime, curAreaNum, lastAreas[4], lastAreaIndex, endAreaNum;
|
||||
idReachability *reach;
|
||||
idVec3 endPos;
|
||||
@@ -493,7 +493,7 @@ bool idAASLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &orig
|
||||
|
||||
for ( i = 0; i < maxFlyPathIterations; i++ ) {
|
||||
|
||||
if ( !idAASLocal::RouteToGoalArea( curAreaNum, path.moveGoal, goalAreaNum, travelFlags, travelTime, &reach ) ) {
|
||||
if ( !idNAVLocal::RouteToGoalArea( curAreaNum, path.moveGoal, goalAreaNum, travelFlags, travelTime, &reach ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -510,7 +510,7 @@ bool idAASLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &orig
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !idAASLocal::FlyPathValid( areaNum, origin, 0, reach->start, travelFlags, endPos, endAreaNum ) ) {
|
||||
if ( !idNAVLocal::FlyPathValid( areaNum, origin, 0, reach->start, travelFlags, endPos, endAreaNum ) ) {
|
||||
#if SUBSAMPLE_FLY_PATH
|
||||
path.moveGoal = SubSampleFlyPath( areaNum, origin, path.moveGoal, reach->start, travelFlags, path.moveAreaNum );
|
||||
#endif
|
||||
@@ -521,7 +521,7 @@ bool idAASLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &orig
|
||||
path.moveGoal = reach->start;
|
||||
path.moveAreaNum = curAreaNum;
|
||||
|
||||
if ( !idAASLocal::FlyPathValid( areaNum, origin, 0, reach->end, travelFlags, endPos, endAreaNum ) ) {
|
||||
if ( !idNAVLocal::FlyPathValid( areaNum, origin, 0, reach->end, travelFlags, endPos, endAreaNum ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ bool idAASLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &orig
|
||||
path.moveAreaNum = reach->toAreaNum;
|
||||
|
||||
if ( reach->toAreaNum == goalAreaNum ) {
|
||||
if ( !idAASLocal::FlyPathValid( areaNum, origin, 0, goalOrigin, travelFlags, endPos, endAreaNum ) ) {
|
||||
if ( !idNAVLocal::FlyPathValid( areaNum, origin, 0, goalOrigin, travelFlags, endPos, endAreaNum ) ) {
|
||||
#if SUBSAMPLE_FLY_PATH
|
||||
path.moveGoal = SubSampleFlyPath( areaNum, origin, path.moveGoal, goalOrigin, travelFlags, path.moveAreaNum );
|
||||
#endif
|
||||
@@ -547,7 +547,7 @@ bool idAASLocal::FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &orig
|
||||
|
||||
if ( curAreaNum == lastAreas[0] || curAreaNum == lastAreas[1] ||
|
||||
curAreaNum == lastAreas[2] || curAreaNum == lastAreas[3] ) {
|
||||
common->Warning( "idAASLocal::FlyPathToGoal: local routing minimum going from area %d to area %d", areaNum, goalAreaNum );
|
||||
common->Warning( "idNAVLocal::FlyPathToGoal: local routing minimum going from area %d to area %d", areaNum, goalAreaNum );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -567,10 +567,10 @@ typedef struct wallEdge_s {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SortWallEdges
|
||||
idNAVLocal::SortWallEdges
|
||||
============
|
||||
*/
|
||||
void idAASLocal::SortWallEdges( int *edges, int numEdges ) const {
|
||||
void idNAVLocal::SortWallEdges( int *edges, int numEdges ) const {
|
||||
int i, j, k, numSequences;
|
||||
wallEdge_t **sequenceFirst, **sequenceLast, *wallEdges, *wallEdge;
|
||||
|
||||
@@ -619,10 +619,10 @@ void idAASLocal::SortWallEdges( int *edges, int numEdges ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetWallEdges
|
||||
idNAVLocal::GetWallEdges
|
||||
============
|
||||
*/
|
||||
int idAASLocal::GetWallEdges( int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges ) const {
|
||||
int idNAVLocal::GetWallEdges( int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges ) const {
|
||||
int i, j, k, l, face1Num, face2Num, edge1Num, edge2Num, numEdges, absEdge1Num;
|
||||
int *areaQueue, curArea, queueStart, queueEnd;
|
||||
byte *areasVisited;
|
||||
@@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "AAS_local.h"
|
||||
#include "NAV_local.h"
|
||||
#include "../Game_local.h" // for print and error
|
||||
|
||||
#define CACHETYPE_AREA 1
|
||||
@@ -80,10 +80,10 @@ int idRoutingCache::Size( void ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::AreaTravelTime
|
||||
idNAVLocal::AreaTravelTime
|
||||
============
|
||||
*/
|
||||
unsigned short idAASLocal::AreaTravelTime( int areaNum, const idVec3 &start, const idVec3 &end ) const {
|
||||
unsigned short idNAVLocal::AreaTravelTime( int areaNum, const idVec3 &start, const idVec3 &end ) const {
|
||||
float dist;
|
||||
|
||||
dist = ( end - start ).Length();
|
||||
@@ -103,10 +103,10 @@ unsigned short idAASLocal::AreaTravelTime( int areaNum, const idVec3 &start, con
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::CalculateAreaTravelTimes
|
||||
idNAVLocal::CalculateAreaTravelTimes
|
||||
============
|
||||
*/
|
||||
void idAASLocal::CalculateAreaTravelTimes(void) {
|
||||
void idNAVLocal::CalculateAreaTravelTimes(void) {
|
||||
int n, i, j, numReach, numRevReach, t, maxt;
|
||||
byte *bytePtr;
|
||||
idReachability *reach, *rev_reach;
|
||||
@@ -172,10 +172,10 @@ void idAASLocal::CalculateAreaTravelTimes(void) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DeleteAreaTravelTimes
|
||||
idNAVLocal::DeleteAreaTravelTimes
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DeleteAreaTravelTimes( void ) {
|
||||
void idNAVLocal::DeleteAreaTravelTimes( void ) {
|
||||
Mem_Free( areaTravelTimes );
|
||||
areaTravelTimes = NULL;
|
||||
numAreaTravelTimes = 0;
|
||||
@@ -183,10 +183,10 @@ void idAASLocal::DeleteAreaTravelTimes( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SetupRoutingCache
|
||||
idNAVLocal::SetupRoutingCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::SetupRoutingCache( void ) {
|
||||
void idNAVLocal::SetupRoutingCache( void ) {
|
||||
int i;
|
||||
byte *bytePtr;
|
||||
|
||||
@@ -216,10 +216,10 @@ void idAASLocal::SetupRoutingCache( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DeleteClusterCache
|
||||
idNAVLocal::DeleteClusterCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DeleteClusterCache( int clusterNum ) {
|
||||
void idNAVLocal::DeleteClusterCache( int clusterNum ) {
|
||||
int i;
|
||||
idRoutingCache *cache;
|
||||
|
||||
@@ -234,10 +234,10 @@ void idAASLocal::DeleteClusterCache( int clusterNum ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DeletePortalCache
|
||||
idNAVLocal::DeletePortalCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DeletePortalCache( void ) {
|
||||
void idNAVLocal::DeletePortalCache( void ) {
|
||||
int i;
|
||||
idRoutingCache *cache;
|
||||
|
||||
@@ -252,10 +252,10 @@ void idAASLocal::DeletePortalCache( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShutdownRoutingCache
|
||||
idNAVLocal::ShutdownRoutingCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShutdownRoutingCache( void ) {
|
||||
void idNAVLocal::ShutdownRoutingCache( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < file->GetNumClusters(); i++ ) {
|
||||
@@ -283,10 +283,10 @@ void idAASLocal::ShutdownRoutingCache( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SetupRouting
|
||||
idNAVLocal::SetupRouting
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::SetupRouting( void ) {
|
||||
bool idNAVLocal::SetupRouting( void ) {
|
||||
CalculateAreaTravelTimes();
|
||||
SetupRoutingCache();
|
||||
return true;
|
||||
@@ -294,20 +294,20 @@ bool idAASLocal::SetupRouting( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ShutdownRouting
|
||||
idNAVLocal::ShutdownRouting
|
||||
============
|
||||
*/
|
||||
void idAASLocal::ShutdownRouting( void ) {
|
||||
void idNAVLocal::ShutdownRouting( void ) {
|
||||
DeleteAreaTravelTimes();
|
||||
ShutdownRoutingCache();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::RoutingStats
|
||||
idNAVLocal::RoutingStats
|
||||
============
|
||||
*/
|
||||
void idAASLocal::RoutingStats( void ) const {
|
||||
void idNAVLocal::RoutingStats( void ) const {
|
||||
idRoutingCache *cache;
|
||||
int numAreaCache, numPortalCache;
|
||||
int totalAreaCacheMemory, totalPortalCacheMemory;
|
||||
@@ -334,10 +334,10 @@ void idAASLocal::RoutingStats( void ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::RemoveRoutingCacheUsingArea
|
||||
idNAVLocal::RemoveRoutingCacheUsingArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::RemoveRoutingCacheUsingArea( int areaNum ) {
|
||||
void idNAVLocal::RemoveRoutingCacheUsingArea( int areaNum ) {
|
||||
int clusterNum;
|
||||
|
||||
clusterNum = file->GetArea( areaNum ).cluster;
|
||||
@@ -355,10 +355,10 @@ void idAASLocal::RemoveRoutingCacheUsingArea( int areaNum ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DisableArea
|
||||
idNAVLocal::DisableArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DisableArea( int areaNum ) {
|
||||
void idNAVLocal::DisableArea( int areaNum ) {
|
||||
assert( areaNum > 0 && areaNum < file->GetNumAreas() );
|
||||
|
||||
if ( file->GetArea( areaNum ).travelFlags & TFL_INVALID ) {
|
||||
@@ -372,10 +372,10 @@ void idAASLocal::DisableArea( int areaNum ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::EnableArea
|
||||
idNAVLocal::EnableArea
|
||||
============
|
||||
*/
|
||||
void idAASLocal::EnableArea( int areaNum ) {
|
||||
void idNAVLocal::EnableArea( int areaNum ) {
|
||||
assert( areaNum > 0 && areaNum < file->GetNumAreas() );
|
||||
|
||||
if ( !( file->GetArea( areaNum ).travelFlags & TFL_INVALID ) ) {
|
||||
@@ -389,10 +389,10 @@ void idAASLocal::EnableArea( int areaNum ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SetAreaState_r
|
||||
idNAVLocal::SetAreaState_r
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::SetAreaState_r( int nodeNum, const idBounds &bounds, const int areaContents, bool disabled ) {
|
||||
bool idNAVLocal::SetAreaState_r( int nodeNum, const idBounds &bounds, const int areaContents, bool disabled ) {
|
||||
int res;
|
||||
const aasNode_t *node;
|
||||
bool foundClusterPortal = false;
|
||||
@@ -429,10 +429,10 @@ bool idAASLocal::SetAreaState_r( int nodeNum, const idBounds &bounds, const int
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SetAreaState
|
||||
idNAVLocal::SetAreaState
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::SetAreaState( const idBounds &bounds, const int areaContents, bool disabled ) {
|
||||
bool idNAVLocal::SetAreaState( const idBounds &bounds, const int areaContents, bool disabled ) {
|
||||
idBounds expBounds;
|
||||
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
@@ -452,10 +452,10 @@ bool idAASLocal::SetAreaState( const idBounds &bounds, const int areaContents, b
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetBoundsAreas_r
|
||||
idNAVLocal::GetBoundsAreas_r
|
||||
============
|
||||
*/
|
||||
void idAASLocal::GetBoundsAreas_r( int nodeNum, const idBounds &bounds, idList<int> &areas ) const {
|
||||
void idNAVLocal::GetBoundsAreas_r( int nodeNum, const idBounds &bounds, idList<int> &areas ) const {
|
||||
int res;
|
||||
const aasNode_t *node;
|
||||
|
||||
@@ -481,10 +481,10 @@ void idAASLocal::GetBoundsAreas_r( int nodeNum, const idBounds &bounds, idList<i
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::SetObstacleState
|
||||
idNAVLocal::SetObstacleState
|
||||
============
|
||||
*/
|
||||
void idAASLocal::SetObstacleState( const idRoutingObstacle *obstacle, bool enable ) {
|
||||
void idNAVLocal::SetObstacleState( const idRoutingObstacle *obstacle, bool enable ) {
|
||||
int i;
|
||||
const aasArea_t *area;
|
||||
idReachability *reach, *rev_reach;
|
||||
@@ -535,10 +535,10 @@ void idAASLocal::SetObstacleState( const idRoutingObstacle *obstacle, bool enabl
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::AddObstacle
|
||||
idNAVLocal::AddObstacle
|
||||
============
|
||||
*/
|
||||
aasHandle_t idAASLocal::AddObstacle( const idBounds &bounds ) {
|
||||
aasHandle_t idNAVLocal::AddObstacle( const idBounds &bounds ) {
|
||||
idRoutingObstacle *obstacle;
|
||||
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
@@ -561,10 +561,10 @@ aasHandle_t idAASLocal::AddObstacle( const idBounds &bounds ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::RemoveObstacle
|
||||
idNAVLocal::RemoveObstacle
|
||||
============
|
||||
*/
|
||||
void idAASLocal::RemoveObstacle( const aasHandle_t handle ) {
|
||||
void idNAVLocal::RemoveObstacle( const aasHandle_t handle ) {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.RemoveObstacle( handle );
|
||||
return;
|
||||
@@ -582,10 +582,10 @@ void idAASLocal::RemoveObstacle( const aasHandle_t handle ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::RemoveAllObstacles
|
||||
idNAVLocal::RemoveAllObstacles
|
||||
============
|
||||
*/
|
||||
void idAASLocal::RemoveAllObstacles( void ) {
|
||||
void idNAVLocal::RemoveAllObstacles( void ) {
|
||||
int i;
|
||||
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
@@ -606,12 +606,12 @@ void idAASLocal::RemoveAllObstacles( void ) {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::LinkCache
|
||||
idNAVLocal::LinkCache
|
||||
|
||||
link the cache in the cache list sorted from oldest to newest cache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::LinkCache( idRoutingCache *cache ) const {
|
||||
void idNAVLocal::LinkCache( idRoutingCache *cache ) const {
|
||||
|
||||
// if the cache is already linked
|
||||
if ( cache->time_next || cache->time_prev || cacheListStart == cache ) {
|
||||
@@ -634,10 +634,10 @@ void idAASLocal::LinkCache( idRoutingCache *cache ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::UnlinkCache
|
||||
idNAVLocal::UnlinkCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::UnlinkCache( idRoutingCache *cache ) const {
|
||||
void idNAVLocal::UnlinkCache( idRoutingCache *cache ) const {
|
||||
|
||||
totalCacheMemory -= cache->Size();
|
||||
|
||||
@@ -657,10 +657,10 @@ void idAASLocal::UnlinkCache( idRoutingCache *cache ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::DeleteOldestCache
|
||||
idNAVLocal::DeleteOldestCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::DeleteOldestCache( void ) const {
|
||||
void idNAVLocal::DeleteOldestCache( void ) const {
|
||||
idRoutingCache *cache;
|
||||
|
||||
assert( cacheListStart );
|
||||
@@ -688,10 +688,10 @@ void idAASLocal::DeleteOldestCache( void ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetAreaReachability
|
||||
idNAVLocal::GetAreaReachability
|
||||
============
|
||||
*/
|
||||
idReachability *idAASLocal::GetAreaReachability( int areaNum, int reachabilityNum ) const {
|
||||
idReachability *idNAVLocal::GetAreaReachability( int areaNum, int reachabilityNum ) const {
|
||||
idReachability *reach;
|
||||
|
||||
for ( reach = file->GetArea( areaNum ).reach; reach; reach = reach->next ) {
|
||||
@@ -704,10 +704,10 @@ idReachability *idAASLocal::GetAreaReachability( int areaNum, int reachabilityNu
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::ClusterAreaNum
|
||||
idNAVLocal::ClusterAreaNum
|
||||
============
|
||||
*/
|
||||
ID_INLINE int idAASLocal::ClusterAreaNum( int clusterNum, int areaNum ) const {
|
||||
ID_INLINE int idNAVLocal::ClusterAreaNum( int clusterNum, int areaNum ) const {
|
||||
int side, areaCluster;
|
||||
|
||||
areaCluster = file->GetArea( areaNum ).cluster;
|
||||
@@ -722,10 +722,10 @@ ID_INLINE int idAASLocal::ClusterAreaNum( int clusterNum, int areaNum ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::UpdateAreaRoutingCache
|
||||
idNAVLocal::UpdateAreaRoutingCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::UpdateAreaRoutingCache( idRoutingCache *areaCache ) const {
|
||||
void idNAVLocal::UpdateAreaRoutingCache( idRoutingCache *areaCache ) const {
|
||||
int i, nextAreaNum, cluster, badTravelFlags, clusterAreaNum, numReachableAreas;
|
||||
unsigned short t, startAreaTravelTimes[MAX_REACH_PER_AREA];
|
||||
idRoutingUpdate *updateListStart, *updateListEnd, *curUpdate, *nextUpdate;
|
||||
@@ -840,10 +840,10 @@ void idAASLocal::UpdateAreaRoutingCache( idRoutingCache *areaCache ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetAreaRoutingCache
|
||||
idNAVLocal::GetAreaRoutingCache
|
||||
============
|
||||
*/
|
||||
idRoutingCache *idAASLocal::GetAreaRoutingCache( int clusterNum, int areaNum, int travelFlags ) const {
|
||||
idRoutingCache *idNAVLocal::GetAreaRoutingCache( int clusterNum, int areaNum, int travelFlags ) const {
|
||||
int clusterAreaNum;
|
||||
idRoutingCache *cache, *clusterCache;
|
||||
|
||||
@@ -879,10 +879,10 @@ idRoutingCache *idAASLocal::GetAreaRoutingCache( int clusterNum, int areaNum, in
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::UpdatePortalRoutingCache
|
||||
idNAVLocal::UpdatePortalRoutingCache
|
||||
============
|
||||
*/
|
||||
void idAASLocal::UpdatePortalRoutingCache( idRoutingCache *portalCache ) const {
|
||||
void idNAVLocal::UpdatePortalRoutingCache( idRoutingCache *portalCache ) const {
|
||||
int i, portalNum, clusterAreaNum;
|
||||
unsigned short t;
|
||||
const aasPortal_t *portal;
|
||||
@@ -971,10 +971,10 @@ void idAASLocal::UpdatePortalRoutingCache( idRoutingCache *portalCache ) const {
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::GetPortalRoutingCache
|
||||
idNAVLocal::GetPortalRoutingCache
|
||||
============
|
||||
*/
|
||||
idRoutingCache *idAASLocal::GetPortalRoutingCache( int clusterNum, int areaNum, int travelFlags ) const {
|
||||
idRoutingCache *idNAVLocal::GetPortalRoutingCache( int clusterNum, int areaNum, int travelFlags ) const {
|
||||
idRoutingCache *cache;
|
||||
|
||||
// check if cache without undesired travel flags already exists
|
||||
@@ -1005,10 +1005,10 @@ idRoutingCache *idAASLocal::GetPortalRoutingCache( int clusterNum, int areaNum,
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::RouteToGoalArea
|
||||
idNAVLocal::RouteToGoalArea
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const {
|
||||
bool idNAVLocal::RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const {
|
||||
int clusterNum, goalClusterNum, portalNum, i, clusterAreaNum;
|
||||
unsigned short int t, bestTime;
|
||||
const aasPortal_t *portal;
|
||||
@@ -1165,10 +1165,10 @@ bool idAASLocal::RouteToGoalArea( int areaNum, const idVec3 origin, int goalArea
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::TravelTimeToGoalArea
|
||||
idNAVLocal::TravelTimeToGoalArea
|
||||
============
|
||||
*/
|
||||
int idAASLocal::TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const {
|
||||
int idNAVLocal::TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const {
|
||||
int travelTime;
|
||||
idReachability *reach;
|
||||
|
||||
@@ -1188,10 +1188,10 @@ int idAASLocal::TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goa
|
||||
|
||||
/*
|
||||
============
|
||||
idAASLocal::FindNearestGoal
|
||||
idNAVLocal::FindNearestGoal
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const {
|
||||
bool idNAVLocal::FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idNAVCallback &callback ) const {
|
||||
int i, j, k, badTravelFlags, nextAreaNum, bestAreaNum;
|
||||
unsigned short t, bestTravelTime;
|
||||
idRoutingUpdate *updateListStart, *updateListEnd, *curUpdate, *nextUpdate;
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
===========================================================================
|
||||
|
||||
IceTech GPL Source Code
|
||||
Copyright (C) 2026 Justin Marshall
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "../Game_local.h"
|
||||
#include "RecastNavMesh.h"
|
||||
|
||||
idRecastNavMesh::idRecastNavMesh( void ) {
|
||||
handle = RECAST_NAV_HANDLE_INVALID;
|
||||
memset( &syntheticReach, 0, sizeof( syntheticReach ) );
|
||||
if ( RecastNavigationManager ) {
|
||||
handle = RecastNavigationManager->Alloc();
|
||||
}
|
||||
}
|
||||
|
||||
idRecastNavMesh::~idRecastNavMesh( void ) {
|
||||
if ( RecastNavigationManager && handle != RECAST_NAV_HANDLE_INVALID ) {
|
||||
RecastNavigationManager->Free( handle );
|
||||
handle = RECAST_NAV_HANDLE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::HasManager( void ) const {
|
||||
return RecastNavigationManager && handle != RECAST_NAV_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
void idRecastNavMesh::Shutdown( void ) {
|
||||
if ( HasManager() ) {
|
||||
RecastNavigationManager->Free( handle );
|
||||
handle = RecastNavigationManager->Alloc();
|
||||
}
|
||||
name.Clear();
|
||||
memset( &syntheticReach, 0, sizeof( syntheticReach ) );
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::Load( const idStr &mapName, const idStr &fileName, unsigned int mapFileCRC ) {
|
||||
if ( !HasManager() ) {
|
||||
return false;
|
||||
}
|
||||
if ( !RecastNavigationManager->Load( handle, mapName, fileName, mapFileCRC ) ) {
|
||||
name.Clear();
|
||||
return false;
|
||||
}
|
||||
name = fileName;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::IsLoaded( void ) const {
|
||||
return HasManager() && RecastNavigationManager->IsLoaded( handle );
|
||||
}
|
||||
|
||||
int idRecastNavMesh::NumPolys( void ) const {
|
||||
return HasManager() ? RecastNavigationManager->NumPolys( handle ) : 0;
|
||||
}
|
||||
|
||||
const idAASSettings *idRecastNavMesh::GetSettings( void ) const {
|
||||
return HasManager() ? RecastNavigationManager->GetSettings( handle ) : NULL;
|
||||
}
|
||||
|
||||
idStr idRecastNavMesh::NavFileNameForMapName( const idStr &mapName ) {
|
||||
idStr navName = mapName;
|
||||
navName += ".navmesh";
|
||||
return navName;
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::BuildMapFile( const idStr &mapName, const idStr &aasType ) {
|
||||
return RecastNavigationManager && RecastNavigationManager->BuildMapFile( mapName.c_str(), aasType.c_str() );
|
||||
}
|
||||
|
||||
void idRecastNavMesh::Stats( void ) const {
|
||||
if ( HasManager() ) {
|
||||
RecastNavigationManager->Stats( handle );
|
||||
}
|
||||
}
|
||||
|
||||
void idRecastNavMesh::DebugDraw( int drawMode ) const {
|
||||
if ( HasManager() ) {
|
||||
RecastNavigationManager->DebugDraw( handle, gameRenderWorld, drawMode, gameLocal.msec );
|
||||
}
|
||||
}
|
||||
|
||||
int idRecastNavMesh::PointAreaNum( const idVec3 &origin ) const {
|
||||
return HasManager() ? RecastNavigationManager->PointAreaNum( handle, origin ) : 0;
|
||||
}
|
||||
|
||||
int idRecastNavMesh::PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const {
|
||||
return HasManager() ? RecastNavigationManager->PointReachableAreaNum( handle, origin, searchBounds, areaFlags ) : 0;
|
||||
}
|
||||
|
||||
int idRecastNavMesh::BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const {
|
||||
return HasManager() ? RecastNavigationManager->BoundsReachableAreaNum( handle, bounds, areaFlags ) : 0;
|
||||
}
|
||||
|
||||
void idRecastNavMesh::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
|
||||
if ( HasManager() ) {
|
||||
RecastNavigationManager->PushPointIntoAreaNum( handle, areaNum, origin );
|
||||
}
|
||||
}
|
||||
|
||||
idVec3 idRecastNavMesh::AreaCenter( int areaNum ) const {
|
||||
return HasManager() ? RecastNavigationManager->AreaCenter( handle, areaNum ) : vec3_origin;
|
||||
}
|
||||
|
||||
int idRecastNavMesh::AreaFlags( int areaNum ) const {
|
||||
return HasManager() ? RecastNavigationManager->AreaFlags( handle, areaNum ) : 0;
|
||||
}
|
||||
|
||||
int idRecastNavMesh::AreaTravelFlags( int areaNum ) const {
|
||||
return HasManager() ? RecastNavigationManager->AreaTravelFlags( handle, areaNum ) : TFL_INVALID;
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const {
|
||||
return HasManager() && RecastNavigationManager->Trace( handle, trace, start, end );
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::SetAreaState( const idBounds &bounds, const int areaContents, bool disabled ) {
|
||||
return HasManager() && RecastNavigationManager->SetAreaState( handle, bounds, areaContents, disabled );
|
||||
}
|
||||
|
||||
aasHandle_t idRecastNavMesh::AddObstacle( const idBounds &bounds ) {
|
||||
return HasManager() ? RecastNavigationManager->AddObstacle( handle, bounds ) : -1;
|
||||
}
|
||||
|
||||
void idRecastNavMesh::RemoveObstacle( const aasHandle_t obstacleHandle ) {
|
||||
if ( HasManager() ) {
|
||||
RecastNavigationManager->RemoveObstacle( handle, obstacleHandle );
|
||||
}
|
||||
}
|
||||
|
||||
void idRecastNavMesh::RemoveAllObstacles( void ) {
|
||||
if ( HasManager() ) {
|
||||
RecastNavigationManager->RemoveAllObstacles( handle );
|
||||
}
|
||||
}
|
||||
|
||||
int idRecastNavMesh::TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const {
|
||||
return HasManager() ? RecastNavigationManager->TravelTimeToGoalArea( handle, areaNum, origin, goalAreaNum, travelFlags ) : 0;
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const {
|
||||
recastPath_t route;
|
||||
if ( !HasManager() || !RecastNavigationManager->RouteToGoalArea( handle, areaNum, origin, goalAreaNum, travelFlags, route ) ) {
|
||||
travelTime = 0;
|
||||
*reach = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
travelTime = route.travelTime;
|
||||
memset( &syntheticReach, 0, sizeof( syntheticReach ) );
|
||||
syntheticReach.travelType = TFL_WALK;
|
||||
syntheticReach.fromAreaNum = areaNum;
|
||||
syntheticReach.toAreaNum = route.moveAreaNum;
|
||||
syntheticReach.start = route.moveGoal;
|
||||
syntheticReach.end = route.moveGoal;
|
||||
syntheticReach.travelTime = travelTime;
|
||||
*reach = &syntheticReach;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::PathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const {
|
||||
recastPath_t recastPath;
|
||||
if ( !HasManager() || !RecastNavigationManager->PathToGoal( handle, recastPath, areaNum, origin, goalAreaNum, goalOrigin, travelFlags ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
path.type = PATHTYPE_WALK;
|
||||
path.moveGoal = recastPath.moveGoal;
|
||||
path.moveAreaNum = recastPath.moveAreaNum;
|
||||
path.secondaryGoal = recastPath.secondaryGoal;
|
||||
path.reachability = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::PathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const {
|
||||
return HasManager() && RecastNavigationManager->PathValid( handle, areaNum, origin, goalAreaNum, goalOrigin, travelFlags, endPos, endAreaNum );
|
||||
}
|
||||
|
||||
bool idRecastNavMesh::FindNearestGoal( const idNAV *owner, aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *queryObstacles, int numObstacles, idNAVCallback &callback ) const {
|
||||
int areas[MAX_RECAST_PATH_AREAS];
|
||||
int numAreas = 0;
|
||||
const int targetArea = PointAreaNum( target );
|
||||
if ( targetArea <= 0 || !HasManager() || !RecastNavigationManager->PathAreaList( handle, areaNum, origin, targetArea, target, travelFlags, areas, numAreas, MAX_RECAST_PATH_AREAS ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = numAreas - 1; i >= 0; i-- ) {
|
||||
const int candidateArea = areas[i];
|
||||
if ( !callback.AreaIsGoal( owner, candidateArea ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const idVec3 candidateOrigin = AreaCenter( candidateArea );
|
||||
bool blocked = false;
|
||||
for ( int j = 0; j < numObstacles; j++ ) {
|
||||
if ( queryObstacles[j].expAbsBounds.ContainsPoint( candidateOrigin ) ) {
|
||||
blocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !blocked ) {
|
||||
goal.areaNum = candidateArea;
|
||||
goal.origin = candidateOrigin;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void idRecastNavMesh::ShowPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const {
|
||||
aasPath_t path;
|
||||
const int areaNum = PointAreaNum( origin );
|
||||
if ( PathToGoal( path, areaNum, origin, goalAreaNum, goalOrigin, TFL_WALK ) ) {
|
||||
gameRenderWorld->DebugLine( colorGreen, origin, path.moveGoal, gameLocal.msec );
|
||||
gameRenderWorld->DebugArrow( colorYellow, path.moveGoal, goalOrigin, 4.0f, gameLocal.msec );
|
||||
}
|
||||
}
|
||||
|
||||
void idRecastNavMesh::ShowArea( const idVec3 &origin ) const {
|
||||
const int areaNum = PointAreaNum( origin );
|
||||
if ( areaNum <= 0 ) {
|
||||
return;
|
||||
}
|
||||
const idVec3 center = AreaCenter( areaNum );
|
||||
gameRenderWorld->DebugBounds( colorCyan, idBounds( idVec3( -8.0f, -8.0f, -4.0f ), idVec3( 8.0f, 8.0f, 4.0f ) ), center, gameLocal.msec );
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
===========================================================================
|
||||
|
||||
IceTech GPL Source Code
|
||||
Copyright (C) 2026 Justin Marshall
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __RECAST_NAVMESH_H__
|
||||
#define __RECAST_NAVMESH_H__
|
||||
|
||||
#include "../../../engine/tools/compilers/recast/RecastNavigation.h"
|
||||
|
||||
class idRecastNavMesh {
|
||||
public:
|
||||
idRecastNavMesh( void );
|
||||
~idRecastNavMesh( void );
|
||||
|
||||
void Shutdown( void );
|
||||
bool Load( const idStr &mapName, const idStr &fileName, unsigned int mapFileCRC );
|
||||
|
||||
bool IsLoaded( void ) const;
|
||||
const idStr & GetName( void ) const { return name; }
|
||||
int NumPolys( void ) const;
|
||||
const idAASSettings * GetSettings( void ) const;
|
||||
void Stats( void ) const;
|
||||
void DebugDraw( int drawMode ) const;
|
||||
|
||||
int PointAreaNum( const idVec3 &origin ) const;
|
||||
int PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const;
|
||||
int BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const;
|
||||
void PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const;
|
||||
idVec3 AreaCenter( int areaNum ) const;
|
||||
int AreaFlags( int areaNum ) const;
|
||||
int AreaTravelFlags( int areaNum ) const;
|
||||
bool Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const;
|
||||
|
||||
bool SetAreaState( const idBounds &bounds, const int areaContents, bool disabled );
|
||||
aasHandle_t AddObstacle( const idBounds &bounds );
|
||||
void RemoveObstacle( const aasHandle_t handle );
|
||||
void RemoveAllObstacles( void );
|
||||
|
||||
int TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const;
|
||||
bool RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const;
|
||||
bool PathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const;
|
||||
bool PathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const;
|
||||
bool FindNearestGoal( const idNAV *owner, aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idNAVCallback &callback ) const;
|
||||
void ShowPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const;
|
||||
void ShowArea( const idVec3 &origin ) const;
|
||||
|
||||
static bool BuildMapFile( const idStr &mapName, const idStr &aasType );
|
||||
static idStr NavFileNameForMapName( const idStr &mapName );
|
||||
|
||||
private:
|
||||
bool HasManager( void ) const;
|
||||
|
||||
private:
|
||||
idStr name;
|
||||
recastNavHandle_t handle;
|
||||
mutable idReachability syntheticReach;
|
||||
};
|
||||
|
||||
#endif /* !__RECAST_NAVMESH_H__ */
|
||||
Reference in New Issue
Block a user