- Mesaj
- 275
- Çözümler
- 11
- Beğeni
- 67
- Puan
- 704
- Ticaret Puanı
- 0
Zemini 2 kat fazla alan yüklenmesi için çalışıyorum aşağıdaki kod kısmını kurcalıyorum sonuc alamadım kod okuyabilen yardımcı olabilir mi?
1:
bool CMapOutdoor::Update(float fX, float fY, float fZ)
{
D3DXVECTOR3 v3Player(fX, fY, fZ);
m_v3Player=v3Player;
DWORD t1=ELTimer_GetMSec();
int ix, iy;
PR_FLOAT_TO_INT(fX, ix);
if ( fY < 0 )
fY = -fY;
PR_FLOAT_TO_INT(fY, iy);
short sCoordX = MINMAX(0, ix / CTerrainImpl::TERRAIN_XSIZE, m_sTerrainCountX - 1);
short sCoordY = MINMAX(0, iy / CTerrainImpl::TERRAIN_YSIZE, m_sTerrainCountY - 1);
#ifdef __PERFORMANCE_CHECKER__
DWORD t2=ELTimer_GetMSec();
#endif
bool bNeedInit = (m_PrevCoordinate.m_sTerrainCoordX == -1 || m_PrevCoordinate.m_sTerrainCoordY == -1);
if ( bNeedInit ||
(m_CurCoordinate.m_sTerrainCoordX/LOAD_SIZE_WIDTH) != (sCoordX/LOAD_SIZE_WIDTH) ||
(m_CurCoordinate.m_sTerrainCoordY/LOAD_SIZE_WIDTH) != (sCoordY/LOAD_SIZE_WIDTH) )
{
if (bNeedInit)
{
m_PrevCoordinate.m_sTerrainCoordX = sCoordX;
m_PrevCoordinate.m_sTerrainCoordY = sCoordY;
}
else
{
m_PrevCoordinate.m_sTerrainCoordX = m_CurCoordinate.m_sTerrainCoordX;
m_PrevCoordinate.m_sTerrainCoordY = m_CurCoordinate.m_sTerrainCoordY;
}
m_CurCoordinate.m_sTerrainCoordX = sCoordX;
m_CurCoordinate.m_sTerrainCoordY = sCoordY;
m_lCurCoordStartX = sCoordX * CTerrainImpl::TERRAIN_XSIZE;
m_lCurCoordStartY = sCoordY * CTerrainImpl::TERRAIN_YSIZE;
WORD wCellCoordX = (ix % CTerrainImpl::TERRAIN_XSIZE) / CTerrainImpl::CELLSCALE;
WORD wCellCoordY = (iy % CTerrainImpl::TERRAIN_YSIZE) / CTerrainImpl::CELLSCALE;
short sReferenceCoordMinX, sReferenceCoordMaxX, sReferenceCoordMinY, sReferenceCoordMaxY;
sReferenceCoordMinX = max(m_CurCoordinate.m_sTerrainCoordX - LOAD_SIZE_WIDTH, 0);
sReferenceCoordMaxX = min(m_CurCoordinate.m_sTerrainCoordX + LOAD_SIZE_WIDTH, m_sTerrainCountX - 1);
sReferenceCoordMinY = max(m_CurCoordinate.m_sTerrainCoordY - LOAD_SIZE_WIDTH, 0);
sReferenceCoordMaxY = min(m_CurCoordinate.m_sTerrainCoordY + LOAD_SIZE_WIDTH, m_sTerrainCountY - 1);
for (WORD usY = sReferenceCoordMinY; usY <=sReferenceCoordMaxY; ++usY)
{
for (WORD usX = sReferenceCoordMinX; usX <= sReferenceCoordMaxX; ++usX)
{
LoadTerrain(usX, usY, wCellCoordX, wCellCoordY);
LoadArea(usX, usY, wCellCoordX, wCellCoordY);
}
}
AssignTerrainPtr();
m_lOldReadX = -1;
Tracenf("Update::Load spent %d ms\n", ELTimer_GetMSec() - t1);
}