Пример #1
0
void CTerrainData::setCellAttribute(int nCellX, int nCellY, unsigned char uAtt)
{
	if (isCellIn(nCellX,nCellY))
	{
		getCell(nCellX,nCellY)->uAttribute = uAtt;
	}
}
Пример #2
0
bool CSceneData::pickCell(int nCellX, int nCellY, const Vec3D& vRayPos, const Vec3D& vRayDir, Vec3D* pPos)const
{
	if (isCellIn(nCellX,nCellY))
	{
		const TerrainCell* cell = getCell(nCellX,nCellY);
		Vec3D v0((float)(nCellX),	cell->fHeight,					(float)(nCellY));
		Vec3D v1((float)(nCellX),	(cell+m_nWidth+1)->fHeight,		(float)(nCellY+1));
		Vec3D v2((float)(nCellX+1),	(cell+m_nWidth+1+1)->fHeight,	(float)(nCellY+1));
		Vec3D v3((float)(nCellX+1),	(cell+1)->fHeight,				(float)(nCellY));
		Vec3D vOut;
		if(IntersectTri(v1,v2,v0,vRayPos,vRayDir,vOut))
		{
			if (pPos)
			{
				*pPos = vOut;
			}
			return true;
		}
		else if (IntersectTri(v3,v0,v2,vRayPos,vRayDir,vOut))
		{
			if (pPos)
			{
				*pPos = vOut;
			}
			return true;
		}
	}
	return false;
}
Пример #3
0
void CSceneData::setCellAttribute(int x, int y, unsigned char uAtt)
{
	if (isCellIn(x,y))
	{
		getCell(x,y)->uAttribute = uAtt;
	}
}
Пример #4
0
unsigned char CSceneData::getCellAttribute(int x, int y)const
{
	if (isCellIn(x,y))
	{
		return getCell(x,y)->uAttribute;
	}
	return 0;
}
Пример #5
0
unsigned char CTerrainData::getCellAttribute(int nCellX, int nCellY)const
{
	if (isCellIn(nCellX,nCellY))
	{
		return getCell(nCellX,nCellY)->uAttribute;
	}
	return 0;
}
Пример #6
0
void CSceneData::setCellTileID(int x, int y, unsigned char uTileID, size_t layer)
{
	if (isCellIn(x,y))
	{
		if (2>layer)
		{
			getCell(x,y)->uTileID[layer] = uTileID;
		}
	}
}
Пример #7
0
void CTerrainData::SetCellTileID(int nCellX, int nCellY, unsigned char uTileID, size_t layer)
{
	if (isCellIn(nCellX,nCellY))
	{
		if (2>layer)
		{
			getCell(nCellX,nCellY)->uTileID[layer] = uTileID;
		}
	}
}
Пример #8
0
unsigned char CSceneData::getCellTileID(int x, int y, size_t layer)const
{
	if (isCellIn(x,y))
	{
		if (2>layer)
		{
			return getCell(x,y)->uTileID[layer];
		}
	}
	return 0;
}
Пример #9
0
unsigned char CTerrainData::GetCellTileID(int nCellX, int nCellY, size_t layer)const
{
	if (isCellIn(nCellX,nCellY))
	{
		if (2>layer)
		{
			return getCell(nCellX,nCellY)->uTileID[layer];
		}
	}
	return 0;
}
Пример #10
0
bool CSceneData::checkHash(int x,int y)
{
	if (!isCellIn(x,y))
	{
		return false;
	}
	TerrainCell* pCell = getCell(x,y);

	if (pCell->uAttribute&TERRAIN_ATT_TYPE_BALK)
	{
		return false;
	}
	if (pCell->SearchedFlag == m_SearchedFlag)// 可检查节点是否访问过
	{
		return false;
	}
	return true;
}
Пример #11
0
void CTerrainData::AddNode(int x,int y,int tx,int ty,unsigned char dir,int level,int father)
{
	if (!isCellIn(x,y))
	{
		return;
	}
	//if (((x!=tx) || (y!=ty))/* && (dir!=DIR_INVALID)*/)
	{
		if (getCell(x,y)->uAttribute&TERRAIN_ATT_TYPE_BALK)
		{
			return;
		}
		if (m_Searched[getVertexIndex(x,y)])// 可检查节点是否访问过
		{
			return;
		}
	}

	m_nNodeCount++;
	int p = m_nNodeCount;
	int f = level + (7*abs(x-tx)+7*abs(y-ty)+3*abs(abs(x-tx)-abs(y-ty))) / 2;//启发函数定义
	while( p > 1 )
	{
		int q = p >> 1;
		if( f < node[q].f )
			node[p] = node[q];
		else
			break;
		p = q;
	}
	node[p].x = x;
	node[p].y = y;
	node[p].f = f;
	node[p].level = level;
	node[p].n = m_nAllNodeCount;

	assert(m_nAllNodeCount<MAX_ALLNODE);

	m_allnode[m_nAllNodeCount].dir = dir;
	m_allnode[m_nAllNodeCount].father = father;
	m_nAllNodeCount++;

	m_Searched[getVertexIndex(x,y)]=true;
}