2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 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.
24 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.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
32 #include "AAS_local.h"
39 idAAS *idAAS::Alloc( void ) {
40 return new idAASLocal;
48 idAAS::~idAAS( void ) {
53 idAASLocal::idAASLocal
56 idAASLocal::idAASLocal( void ) {
62 idAASLocal::~idAASLocal
65 idAASLocal::~idAASLocal( void ) {
74 bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
75 if ( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
76 common->Printf( "Keeping %s\n", file->GetName() );
82 file = AASFileManager->LoadAAS( mapName, mapFileCRC );
84 common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
97 void idAASLocal::Shutdown( void ) {
100 RemoveAllObstacles();
101 AASFileManager->FreeAAS( file );
111 void idAASLocal::Stats( void ) const {
115 common->Printf( "[%s]\n", file->GetName() );
122 idAASLocal::GetSettings
125 const idAASSettings *idAASLocal::GetSettings( void ) const {
129 return &file->GetSettings();
134 idAASLocal::PointAreaNum
137 int idAASLocal::PointAreaNum( const idVec3 &origin ) const {
141 return file->PointAreaNum( origin );
146 idAASLocal::PointReachableAreaNum
149 int idAASLocal::PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags ) const {
154 return file->PointReachableAreaNum( origin, searchBounds, areaFlags, TFL_INVALID );
159 idAASLocal::BoundsReachableAreaNum
162 int idAASLocal::BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const {
167 return file->BoundsReachableAreaNum( bounds, areaFlags, TFL_INVALID );
172 idAASLocal::PushPointIntoAreaNum
175 void idAASLocal::PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const {
179 file->PushPointIntoAreaNum( areaNum, origin );
184 idAASLocal::AreaCenter
187 idVec3 idAASLocal::AreaCenter( int areaNum ) const {
191 return file->GetArea( areaNum ).center;
196 idAASLocal::AreaFlags
199 int idAASLocal::AreaFlags( int areaNum ) const {
203 return file->GetArea( areaNum ).flags;
208 idAASLocal::AreaTravelFlags
211 int idAASLocal::AreaTravelFlags( int areaNum ) const {
215 return file->GetArea( areaNum ).travelFlags;
223 bool idAASLocal::Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const {
225 trace.fraction = 0.0f;
226 trace.lastAreaNum = 0;
230 return file->Trace( trace, start, end );
238 const idPlane &idAASLocal::GetPlane( int planeNum ) const {
240 static idPlane dummy;
243 return file->GetPlane( planeNum );
248 idAASLocal::GetEdgeVertexNumbers
251 void idAASLocal::GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const {
253 verts[0] = verts[1] = 0;
256 const int *v = file->GetEdge( abs(edgeNum) ).vertexNum;
257 verts[0] = v[INTSIGNBITSET(edgeNum)];
258 verts[1] = v[INTSIGNBITNOTSET(edgeNum)];
266 void idAASLocal::GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const {
272 const int *v = file->GetEdge( abs(edgeNum) ).vertexNum;
273 start = file->GetVertex( v[INTSIGNBITSET(edgeNum)] );
274 end = file->GetVertex( v[INTSIGNBITNOTSET(edgeNum)] );