123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- /*
- ===========================================================================
- Doom 3 GPL Source Code
- Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
- This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
- Doom 3 Source Code is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- Doom 3 Source Code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
- In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
- If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
- ===========================================================================
- */
- #include "../../idlib/precompiled.h"
- #pragma hdrstop
- #include "AAS_local.h"
- /*
- ============
- idAAS::Alloc
- ============
- */
- idAAS *idAAS::Alloc( void ) {
- return new idAASLocal;
- }
- /*
- ============
- idAAS::idAAS
- ============
- */
- idAAS::~idAAS( void ) {
- }
- /*
- ============
- idAASLocal::idAASLocal
- ============
- */
- idAASLocal::idAASLocal( void ) {
- file = NULL;
- }
- /*
- ============
- idAASLocal::~idAASLocal
- ============
- */
- idAASLocal::~idAASLocal( void ) {
- Shutdown();
- }
- /*
- ============
- idAASLocal::Init
- ============
- */
- bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
- if ( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
- common->Printf( "Keeping %s\n", file->GetName() );
- RemoveAllObstacles();
- }
- else {
- Shutdown();
- file = AASFileManager->LoadAAS( mapName, mapFileCRC );
- if ( !file ) {
- common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
- return false;
- }
- SetupRouting();
- }
- return true;
- }
- /*
- ============
- idAASLocal::Shutdown
- ============
- */
- void idAASLocal::Shutdown( void ) {
- if ( file ) {
- ShutdownRouting();
- RemoveAllObstacles();
- AASFileManager->FreeAAS( file );
- file = NULL;
- }
- }
- /*
- ============
- idAASLocal::Stats
- ============
- */
- void idAASLocal::Stats( void ) const {
- if ( !file ) {
- return;
- }
- common->Printf( "[%s]\n", file->GetName() );
- file->PrintInfo();
- RoutingStats();
- }
- /*
- ============
- idAASLocal::GetSettings
- ============
- */
- const idAASSettings *idAASLocal::GetSettings( void ) const {
- if ( !file ) {
- return NULL;
- }
- return &file->GetSettings();
- }
- /*
- ============
- idAASLocal::PointAreaNum
- ============
- */
- int idAASLocal::PointAreaNum( const idVec3 &origin ) const {
- if ( !file ) {
- return 0;
- }
- return file->PointAreaNum( origin );
- }
- /*
- ============
- idAASLocal::PointReachableAreaNum
- ============
- */
- int idAASLocal::PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const {
- if ( !file ) {
- return 0;
- }
- return file->PointReachableAreaNum( origin, searchBounds, areaFlags, TFL_INVALID );
- }
- /*
- ============
- idAASLocal::BoundsReachableAreaNum
- ============
- */
- int idAASLocal::BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const {
- if ( !file ) {
- return 0;
- }
-
- return file->BoundsReachableAreaNum( bounds, areaFlags, TFL_INVALID );
- }
- /*
- ============
- idAASLocal::PushPointIntoAreaNum
- ============
- */
- void idAASLocal::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
- if ( !file ) {
- return;
- }
- file->PushPointIntoAreaNum( areaNum, origin );
- }
- /*
- ============
- idAASLocal::AreaCenter
- ============
- */
- idVec3 idAASLocal::AreaCenter( int areaNum ) const {
- if ( !file ) {
- return vec3_origin;
- }
- return file->GetArea( areaNum ).center;
- }
- /*
- ============
- idAASLocal::AreaFlags
- ============
- */
- int idAASLocal::AreaFlags( int areaNum ) const {
- if ( !file ) {
- return 0;
- }
- return file->GetArea( areaNum ).flags;
- }
- /*
- ============
- idAASLocal::AreaTravelFlags
- ============
- */
- int idAASLocal::AreaTravelFlags( int areaNum ) const {
- if ( !file ) {
- return 0;
- }
- return file->GetArea( areaNum ).travelFlags;
- }
- /*
- ============
- idAASLocal::Trace
- ============
- */
- bool idAASLocal::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const {
- if ( !file ) {
- trace.fraction = 0.0f;
- trace.lastAreaNum = 0;
- trace.numAreas = 0;
- return true;
- }
- return file->Trace( trace, start, end );
- }
- /*
- ============
- idAASLocal::GetPlane
- ============
- */
- const idPlane &idAASLocal::GetPlane( int planeNum ) const {
- if ( !file ) {
- static idPlane dummy;
- return dummy;
- }
- return file->GetPlane( planeNum );
- }
- /*
- ============
- idAASLocal::GetEdgeVertexNumbers
- ============
- */
- void idAASLocal::GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const {
- if ( !file ) {
- verts[0] = verts[1] = 0;
- return;
- }
- const int *v = file->GetEdge( abs(edgeNum) ).vertexNum;
- verts[0] = v[INTSIGNBITSET(edgeNum)];
- verts[1] = v[INTSIGNBITNOTSET(edgeNum)];
- }
- /*
- ============
- idAASLocal::GetEdge
- ============
- */
- void idAASLocal::GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const {
- if ( !file ) {
- start.Zero();
- end.Zero();
- return;
- }
- const int *v = file->GetEdge( abs(edgeNum) ).vertexNum;
- start = file->GetVertex( v[INTSIGNBITSET(edgeNum)] );
- end = file->GetVertex( v[INTSIGNBITNOTSET(edgeNum)] );
- }
|