当前位置: 首页>>代码示例>>C++>>正文


C++ CLine::Next方法代码示例

本文整理汇总了C++中CLine::Next方法的典型用法代码示例。如果您正苦于以下问题:C++ CLine::Next方法的具体用法?C++ CLine::Next怎么用?C++ CLine::Next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLine的用法示例。


在下文中一共展示了CLine::Next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _AddPathPortion

void COptimizePath::_AddPathPortion(CLine& line, const A3DPOINT2& dest, const int newCount)
{
	int index;
	int old_count = 0;
	for (index = m_CurIndex +1; index < (int)m_Path.size(); index++)
	{
		old_count++;
		//clear  the old footprint
		int x, y;
		x = (int)m_Path[index].x;
		y = (int)m_Path[index].y;
		SetFootprint(x, y, 0);
		if (x == dest.x && y == dest.y)
		{
			break;
		}
	}

	assert(index < (int)m_Path.size() );

	//adjust the path space between current to dest,  have old_count, need newCount 
	if (old_count > newCount)
	{
		//erase 
		abase::vector<APointF>::iterator it1, it2;
		it1 = &m_Path[m_CurIndex+1];
		it2 = it1 + old_count - newCount;
		m_Path.erase(it1, it2);
	}
	else if (old_count < newCount)
	{
		//insert
		abase::vector<APointF>::iterator it1;
		it1 = &m_Path[m_CurIndex+1];
		m_Path.insert(it1, newCount - old_count, APointF());
	}
	
	//replace the old path portion
	index = m_CurIndex+1;
	while (line.GetCount() < newCount)
	{
		m_Path[index] = line.Next();
		index++;
	}

}
开发者ID:fengqk,项目名称:Art,代码行数:46,代码来源:OptimizePath.cpp

示例2: _LineTo

bool COptimizePath::_LineTo(CLine& line, APointF& to)
{

#define  LOCAL_STRICT_LINE
	A3DPOINT2 to_pt((int)to.x, (int)to.y);
	A3DPOINT2 cur_pt((int)line.GetFrom().x, (int)line.GetFrom().y);

	CMoveMap * pMoveMap = g_MoveAgentManager.GetMoveMap();
	assert(pMoveMap);

#ifdef LOCAL_STRICT_LINE
	A3DPOINT2  last_pt(cur_pt);

#endif
	while (cur_pt != to_pt )
	{
		
		APointF cur(line.Next());
		cur_pt.x = (int)cur.x;
		cur_pt.y = (int)cur.y;

		if (!pMoveMap->IsPosReachable(cur_pt))
		{
			return false;
		}

#ifdef LOCAL_STRICT_LINE
		if ((cur_pt.x != last_pt.x && cur_pt.y != last_pt.y) 
			&&(!pMoveMap->IsPosReachable(last_pt.x, cur_pt.y)
			  || !pMoveMap->IsPosReachable(cur_pt.x, last_pt.y)) )
		{
			return false;
		}
		last_pt = cur_pt;
#endif

	}
	
#undef  LOCAL_STRICT_LINE
	return true;
}
开发者ID:fengqk,项目名称:Art,代码行数:41,代码来源:OptimizePath.cpp


注:本文中的CLine::Next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。