DragonNest/Common/EternityEngine/EtOcclusionMng.cpp
2024-12-20 16:56:44 +08:00

76 lines
No EOL
3.2 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "StdAfx.h"
#include "EtOcclusionMng.h"
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
#endif
CEtOcclusionMng::CEtOcclusionMng(void)
{
m_nAllocCount = 0;
}
CEtOcclusionMng::~CEtOcclusionMng(void)
{
SAFE_DELETE_PVEC( m_vecOcclusionQuery );
}
int CEtOcclusionMng::AllocOcclusion()
{
int nAllocIndex;
nAllocIndex = m_nAllocCount;
if( nAllocIndex >= ( int )m_vecOcclusionQuery.size() )
{
CEtOcclusionQuery *pQuery = new CEtOcclusionQuery();
// pQuery->SetAsyncType( true );
m_vecOcclusionQuery.push_back( pQuery );
}
m_nAllocCount++;
return nAllocIndex;
}
void CEtOcclusionMng::BeginOcclusion( int nIndex )
{
ASSERT( nIndex >= 0 && nIndex < ( int )m_vecOcclusionQuery.size() );
if( nIndex < 0 || nIndex >= ( int )m_vecOcclusionQuery.size() )
{
return;
}
m_vecOcclusionQuery[ nIndex ]->Begin();
}
void CEtOcclusionMng::EndOcclusion( int nIndex )
{
ASSERT( nIndex >= 0 && nIndex < ( int )m_vecOcclusionQuery.size() );
if( nIndex < 0 || nIndex >= ( int )m_vecOcclusionQuery.size() )
{
return;
}
m_vecOcclusionQuery[ nIndex ]->End();
}
DWORD CEtOcclusionMng::ResultOcclusion( int nIndex )
{
ASSERT( nIndex >= 0 && nIndex < ( int )m_vecOcclusionQuery.size() );
if( nIndex < 0 || nIndex >= ( int )m_vecOcclusionQuery.size() )
{
return 0xffffffff;
}
DWORD dwResult;
if( m_vecOcclusionQuery[ nIndex ]->GetResult( dwResult ) )
{
return dwResult;
}
else
{
// 오클루전 체크 실패 했으니깐 무조건 그려야 한다.
return 0xffffffff;
}
}
void CEtOcclusionMng::FlushBuffer()
{
SAFE_DELETE_PVEC( m_vecOcclusionQuery );
}