mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-17 19:23:51 +02:00
Added recast navmesh.
This commit is contained in:
@@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "../Game_local.h"
|
||||
#include "AAS_local.h"
|
||||
|
||||
/*
|
||||
@@ -72,6 +73,28 @@ idAASLocal::Init
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
|
||||
const idStr navName = idRecastNavMesh::NavFileNameForAASName( mapName );
|
||||
if ( recastNavMesh.IsLoaded() && mapName.Icmp( name ) == 0 ) {
|
||||
common->Printf( "Keeping %s\n", navName.c_str() );
|
||||
recastNavMesh.RemoveAllObstacles();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( recastNavMesh.Load( mapName, navName, mapFileCRC ) ) {
|
||||
if ( file ) {
|
||||
for ( int i = 0; i < obstacleList.Num(); i++ ) {
|
||||
delete obstacleList[i];
|
||||
}
|
||||
obstacleList.Clear();
|
||||
ShutdownRouting();
|
||||
AASFileManager->FreeAAS( file );
|
||||
file = NULL;
|
||||
}
|
||||
name = mapName;
|
||||
common->Printf( "Loaded Recast navmesh: %s\n", navName.c_str() );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
|
||||
common->Printf( "Keeping %s\n", file->GetName() );
|
||||
RemoveAllObstacles();
|
||||
@@ -95,6 +118,7 @@ idAASLocal::Shutdown
|
||||
============
|
||||
*/
|
||||
void idAASLocal::Shutdown( void ) {
|
||||
recastNavMesh.Shutdown();
|
||||
if ( file ) {
|
||||
ShutdownRouting();
|
||||
RemoveAllObstacles();
|
||||
@@ -109,6 +133,10 @@ idAASLocal::Stats
|
||||
============
|
||||
*/
|
||||
void idAASLocal::Stats( void ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.Stats();
|
||||
return;
|
||||
}
|
||||
if ( !file ) {
|
||||
return;
|
||||
}
|
||||
@@ -123,6 +151,9 @@ idAASLocal::GetSettings
|
||||
============
|
||||
*/
|
||||
const idAASSettings *idAASLocal::GetSettings( void ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.GetSettings();
|
||||
}
|
||||
if ( !file ) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -135,6 +166,9 @@ idAASLocal::PointAreaNum
|
||||
============
|
||||
*/
|
||||
int idAASLocal::PointAreaNum( const idVec3 &origin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.PointAreaNum( origin );
|
||||
}
|
||||
if ( !file ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -147,6 +181,9 @@ idAASLocal::PointReachableAreaNum
|
||||
============
|
||||
*/
|
||||
int idAASLocal::PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.PointReachableAreaNum( origin, searchBounds, areaFlags );
|
||||
}
|
||||
if ( !file ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -160,6 +197,9 @@ idAASLocal::BoundsReachableAreaNum
|
||||
============
|
||||
*/
|
||||
int idAASLocal::BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.BoundsReachableAreaNum( bounds, areaFlags );
|
||||
}
|
||||
if ( !file ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -173,6 +213,10 @@ idAASLocal::PushPointIntoAreaNum
|
||||
============
|
||||
*/
|
||||
void idAASLocal::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
recastNavMesh.PushPointIntoAreaNum( areaNum, origin );
|
||||
return;
|
||||
}
|
||||
if ( !file ) {
|
||||
return;
|
||||
}
|
||||
@@ -185,6 +229,9 @@ idAASLocal::AreaCenter
|
||||
============
|
||||
*/
|
||||
idVec3 idAASLocal::AreaCenter( int areaNum ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.AreaCenter( areaNum );
|
||||
}
|
||||
if ( !file ) {
|
||||
return vec3_origin;
|
||||
}
|
||||
@@ -197,6 +244,9 @@ idAASLocal::AreaFlags
|
||||
============
|
||||
*/
|
||||
int idAASLocal::AreaFlags( int areaNum ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.AreaFlags( areaNum );
|
||||
}
|
||||
if ( !file ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -209,6 +259,9 @@ idAASLocal::AreaTravelFlags
|
||||
============
|
||||
*/
|
||||
int idAASLocal::AreaTravelFlags( int areaNum ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.AreaTravelFlags( areaNum );
|
||||
}
|
||||
if ( !file ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -221,6 +274,9 @@ idAASLocal::Trace
|
||||
============
|
||||
*/
|
||||
bool idAASLocal::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const {
|
||||
if ( recastNavMesh.IsLoaded() ) {
|
||||
return recastNavMesh.Trace( trace, start, end );
|
||||
}
|
||||
if ( !file ) {
|
||||
trace.fraction = 0.0f;
|
||||
trace.lastAreaNum = 0;
|
||||
@@ -285,4 +341,4 @@ int idAASLocal::AdjustPositionAndGetArea(idVec3& origin)
|
||||
int area = PointReachableAreaNum(origin, DefaultSearchBounds(), AREA_REACHABLE_WALK);
|
||||
PushPointIntoAreaNum(area, origin);
|
||||
return area;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user