コード例 #1
0
/*****************************************************************************\
	Compute the distance metrics for each entry in the display list 
	given the new view point.  Entries below the bottom Z value given will
	be removed from the list and placed into the "lowList" chain.  Entries
	which are too high will go into the "highList" chain.

    this version ONLY calculates the distance for the objects in it's list
\*****************************************************************************/
void ObjectDisplayList::UpdateMetrics(const Tpoint *pos)
{
	register float	x = pos->x;
	register float	y = pos->y;
//	register float	z = pos->z;

	DrawableObject	*p;

	// Quit now if we don't have at least one list entry
	if ( !head ) return;

	// Run through the whole list and compute the sorting metrics for each entry
	p = head;
	//while ( p )
	while ( p && !F4IsBadReadPtr(p, sizeof(DrawableObject))) // JB 010318 CTD
	{
		// Update the distance metric (not less than 0)
		p->distance = max( (float)fabs(x - p->position.x), (float)fabs(y - p->position.y) );
		ShiAssert(!_isnan(p->distance));
		if(_isnan(p->distance))
		{
			p->distance = 0.0f;
		}
		else if (p->distance > p->Radius())
		{
			p->distance = p->distance - p->Radius();
		}
		else
		{
			p->distance = 0.0f;
		}
		p=p->next;
	}
}
コード例 #2
0
/*****************************************************************************\
	Compute the distance metrics for each entry in the display list 
	given the new view point.  Entries below the bottom Z value given will
	be removed from the list and placed into the "lowList" chain.  Entries
	which are too high will go into the "highList" chain.
\*****************************************************************************/
void ObjectDisplayList::UpdateMetrics( long listNo, const Tpoint *pos, TransportStr *transList )
{
	register float	x = pos->x;
	register float	y = pos->y;
//	register float	z = pos->z;

	DrawableObject	*p;
	DrawableObject	*q;

	long			i;

	// Quit now if we don't have at least one list entry
	if ( !head ) return;

	
#ifdef _SANITY_CHECK_
	if ( head )
	{
		DrawableObject *_cur_;
		long count=0;

		// Sanity checks
		if (head->parentList != this)
			return;
		if(head->prev)
		{

			head->prev=NULL;
		}
		_cur_=head;
		while(_cur_ && count < 10000)
		{
			if (_cur_->parentList != this)
				return;
			_cur_=_cur_->next;
			count++;
		}
		if(_cur_)
		{
			head->prev=NULL; // painless breakpoint
		}
	}
#endif

	// Run through the whole list and compute the sorting metrics for each entry
	q = head;
	while ( q ) {

		p=q;
		q=q->next;

		// Update the distance metric (not less than 0)
		p->distance = max( (float)fabs(x - p->position.x), (float)fabs(y - p->position.y) );
		ShiAssert(!_isnan(p->distance));
		if(_isnan(p->distance))
		{
			p->distance = 0.0f;
		}
		else if (p->distance > p->Radius())
		{
			p->distance = p->distance - p->Radius();
		}
		else
		{
			p->distance = 0.0f;
		}

		if (transList)
		{
			if (p->position.z >= transList->bottom[listNo] && listNo)
			{
				i=listNo-1;
				while(i > 0 && p->position.z >= transList->bottom[i])
					i--;
				// remove object from objectList
				RemoveObject(p);
				// head insert object into transport list
				p->next=transList->list[i];
				transList->list[i]=p;
			}
			else if(p->position.z < transList->top[listNo] && listNo < (_NUM_OBJECT_LISTS_-1))
			{
				i=listNo+1;
				while(i < (_NUM_OBJECT_LISTS_-1) && p->position.z < transList->top[i])
					i++;
				// remove object from objectList
				RemoveObject(p);
				// head insert object into transport list
				p->next=transList->list[i];
				transList->list[i]=p;
			}
		}
	}

#ifdef _SANITY_CHECK_
	if ( head )
	{
		DrawableObject *_cur_;
		long count=0;

		// Sanity checks
		if(head->prev)
		{
			head->prev=NULL;
		}
		_cur_=head;
		while(_cur_ && count < 10000)
		{
			_cur_=_cur_->next;
			count++;
		}
		if(_cur_)
		{
			head->prev=NULL; // painless breakpoint
		}
	}
#endif

	// Now call anyone who has registered for a callback
	for (UpdateCallBack	*nextCall = updateCBlist; nextCall; nextCall = nextCall->next) {
		nextCall->fn( nextCall->self, listNo, pos, transList );
	}
}