コード例 #1
0
ファイル: TerrainMgr.cpp プロジェクト: arcticdev/arctic-test
float TerrainMgr::GetLandHeight(float x, float y)
{
	if(!AreCoordinatesValid(x, y))
		return 0.0f;

	// Convert the co-ordinates to cells.
	uint32 CellX = ConvertGlobalXCoordinate(x);
	uint32 CellY = ConvertGlobalYCoordinate(y);

	if(!CellInformationLoaded(CellX, CellY) && !LoadCellInformation(CellX, CellY))
		return 0.0f;

	// Convert the co-ordinates to cell's internal
	// system.
	float IntX = ConvertInternalXCoordinate(x, CellX);
	float IntY = ConvertInternalYCoordinate(y, CellY);

	// Calculate x index.
	float TempFloat = IntX * (MAP_RESOLUTION / CellsPerTile / _cellSize);
	uint32 XOffset = FL2UINT(TempFloat);
	if((TempFloat - (XOffset * _cellSize)) >= 0.5f)
		++XOffset;

	// Calculate y index.
	TempFloat = IntY * (MAP_RESOLUTION / CellsPerTile / _cellSize);
	uint32 YOffset = FL2UINT(TempFloat);
	if((TempFloat - (YOffset * _cellSize)) >= 0.5f)
		++YOffset;

	// Return our cached information.
	return GetCellInformation(CellX, CellY)->Z[XOffset][YOffset];
}
コード例 #2
0
ファイル: TerrainMgr.cpp プロジェクト: AegisEmu/AegisEmu
bool TerrainMgr::WriteNewHeightToPos(float x, float y, float new_z)
{
	if(!AreCoordinatesValid(x, y))
		return false;

	// Convert the co-ordinates to cells.
	uint32 CellX = ConvertGlobalXCoordinate(x);
	uint32 CellY = ConvertGlobalYCoordinate(y);

	if(!CellInformationLoaded(CellX, CellY) && !LoadCellInformation(CellX, CellY))
		return false;

	// Convert the co-ordinates to cell's internal
	// system.
	float IntX = ConvertInternalXCoordinate(x, CellX);
	float IntY = ConvertInternalYCoordinate(y, CellY);

	// Calculate x index.
	float TempFloat = IntX * (MAP_RESOLUTION / CellsPerTile / _cellSize);
	uint32 XOffset = FL2UINT(TempFloat);
	if((TempFloat - (XOffset * _cellSize)) >= 0.5f)
		++XOffset;

	// Calculate y index.
	TempFloat = IntY * (MAP_RESOLUTION / CellsPerTile / _cellSize);
	uint32 YOffset = FL2UINT(TempFloat);
	if((TempFloat - (YOffset * _cellSize)) >= 0.5f)
		++YOffset;

	if( CellX > 511 )
		CellX = 511;
	if( CellY > 511 )
		CellY = 511;
	if( XOffset > 31 )
		XOffset = 31;
	if( YOffset > 31 )
		YOffset = 31;

	// Return our cached information.
	CellInformation[CellX][CellY]->Z[XOffset][YOffset] = new_z;
	return true;
}
コード例 #3
0
ファイル: TerrainMgr.cpp プロジェクト: arcticdev/arctic-test
uint16 TerrainMgr::GetAreaID(float x, float y)
{
	if(!AreCoordinatesValid(x, y))
		return 0;

	// Convert the co-ordinates to cells.
	uint32 CellX = ConvertGlobalXCoordinate(x);
	uint32 CellY = ConvertGlobalYCoordinate(y);

	if(!CellInformationLoaded(CellX, CellY) && !LoadCellInformation(CellX, CellY))
		return 0;

	// Convert the co-ordinates to cell's internal
	// system.
	float IntX = ConvertInternalXCoordinate(x, CellX);
	float IntY = ConvertInternalYCoordinate(y, CellY);

	// Find the offset in the 2d array.
	return GetCellInformation(CellX, CellY)->AreaID[ConvertTo2dArray(IntX)][ConvertTo2dArray(IntY)];
}
コード例 #4
0
ファイル: TerrainMgr.cpp プロジェクト: arcticdev/arctic-test
void TerrainMgr::CellGoneIdle(uint32 x, uint32 y)
{
	// If we're not an instance, unload our cell info.
	if(!Instance && CellInformationLoaded(x, y) && sWorld.UnloadMapFiles)
		UnloadCellInformation(x, y);
}
コード例 #5
0
ファイル: TerrainMgr.cpp プロジェクト: arcticdev/arctic-test
void TerrainMgr::CellGoneActive(uint32 x, uint32 y)
{
	// Load cell information if it's not already loaded.
	if(!CellInformationLoaded(x, y))
		LoadCellInformation(x, y);
}