示例#1
0
		void BP_Endpoint::move(Ogre::Real x, BP_Scene& scene, T_Overlap overlap)
		{
			int sign = MT_sign(x - m_pos);

			m_pos = x;

			switch (sign) {
	case -1: {
		GEN_Link *prev = getPrev();
		if (!prev->isHead() && (*this < *(BP_Endpoint *)prev)) {
			remove();
			do {
				encounters(*(BP_Endpoint *)prev, *this, scene, overlap);
				prev = prev->getPrev();
			}
			while (!prev->isHead() && (*this < *(BP_Endpoint *)prev));
			insertAfter(prev);
		}
		break;
			 }
	case 1: {
		GEN_Link *next = getNext();
		if (!next->isTail() && (*(BP_Endpoint *)next < *this)) {
			remove();
			do {
				encounters(*this, *(BP_Endpoint *)next, scene, overlap);
				next = next->getNext();
			}
			while (!next->isTail() && (*(BP_Endpoint *)next < *this));
			insertBefore(next);   
		}
		break;
			}
	case 0:
		// nothing to do 
		break;
	default:
		assert(false);
			}
		}
示例#2
0
void BP_EndpointList::move(DT_Index index, DT_Scalar pos, Uint32 type,  
						   BP_Scene& scene, T_Overlap overlap)
{
	assert(invariant());
	
	BP_Endpoint endpoint = (*this)[index];
    DT_Scalar delta = pos - endpoint.getPos();
	
    if (delta != DT_Scalar(0.0)) 
	{
		endpoint.setPos(pos, type);
		if (delta < DT_Scalar(0.0)) 
		{
			while (index != 0 && endpoint < (*this)[index - 1]) 
			{
				(*this)[index] = (*this)[index - 1];
				(*this)[index].getIndex() = index;
				encounters((*this)[index], endpoint, scene, overlap);
				--index;
			}
		}
		else 
		{
			DT_Index last = size() - 1;
			while (index != last && (*this)[index + 1] < endpoint) 
			{
				(*this)[index] = (*this)[index + 1];
				(*this)[index].getIndex() = index;
				encounters(endpoint, (*this)[index], scene, overlap);
				++index;
			}
		}
		(*this)[index] = endpoint;
		(*this)[index].getIndex() = index;
    }

	assert(invariant());
}