// Copyright (C) 2007 Id Software, Inc. // #pragma hdrstop #include "precompiled.h" #include "NAV_local.h" #include "../Game_local.h" // for print and error #include "NAVCallback_FindCoverArea.h" /* ============ idNAVCallback_FindCoverArea::idNAVCallback_FindCoverArea ============ */ idNAVCallback_FindCoverArea::idNAVCallback_FindCoverArea( const idVec3& hideFromPos ) { int numPVSAreas; idBounds bounds( hideFromPos - idVec3( 16, 16, 0 ), hideFromPos + idVec3( 16, 16, 64 ) ); // setup PVS numPVSAreas = gameLocal.pvs.GetPVSAreas( bounds, PVSAreas, MAX_PVS_AREAS ); hidePVS = gameLocal.pvs.SetupCurrentPVS( PVSAreas, numPVSAreas ); } /* ============ idNAVCallback_FindCoverArea::~idNAVCallback_FindCoverArea ============ */ idNAVCallback_FindCoverArea::~idNAVCallback_FindCoverArea() { gameLocal.pvs.FreeCurrentPVS( hidePVS ); } /* ============ idNAVCallback_FindCoverArea::AreaIsGoal ============ */ bool idNAVCallback_FindCoverArea::AreaIsGoal( const idNAV* aas, int areaNum ) { idVec3 areaCenter; int numPVSAreas; int PVSAreas[ MAX_PVS_AREAS ]; areaCenter = aas->AreaCenter( areaNum ); areaCenter[ 2 ] += 1.0f; numPVSAreas = gameLocal.pvs.GetPVSAreas( idBounds( areaCenter ).Expand( 16.0f ), PVSAreas, MAX_PVS_AREAS ); if( !gameLocal.pvs.InCurrentPVS( hidePVS, PVSAreas, numPVSAreas ) ) { return true; } return false; }