sources/SpriteWorld.c
void SWMergeUpdateRect(
	UpdateRectStructPtr *headRectPP,
	SWRect	*theChangedRect,
	int *countP)
{
	UpdateRectStructPtr		curRectStructP;
	int						stillNeedsMerge = true;
	int						count = 0;
		
	//will loop until there are no collisions with the update rect
	//will just fall (not fail) through if there is no head update rect
	while (stillNeedsMerge) 
	{
		stillNeedsMerge = false;

		//go through each struct
		curRectStructP = *headRectPP; 
		while(curRectStructP != NULL)
		{
			//check for intersection with other rects
			if ( SW_RECT_IS_IN_RECT( *theChangedRect, curRectStructP->updateRect) )
			{
				count ++;

				//union the rects
				SW_UNION_RECT( *theChangedRect, curRectStructP->updateRect);

				//remove the other rect from the list
				SWRemoveUpdateRectStruct( headRectPP, curRectStructP);
				
				//we need to restart the checking, break out of this iteration
				stillNeedsMerge = true;
				break;
			}
			
			//next link
			curRectStructP = curRectStructP->nextRectStructP;
		}//end while each struct
	}//end while stillneedsmerge
	
	//see if the number of merges result is wanted
	if (countP)
	{	
		*countP = count;
	}
}
///--------------------------------------------------------------------------------------
//	SWMergeUpdateRect - merge the rect with others in the list, then add
///--------------------------------------------------------------------------------------
merge the rect with others in the list, then add
merge the rect with others in the list then add
void SWMergeUpdateRect(
	UpdateRectStructPtr *headRectPP,
	SWRect	*theChangedRect,
	int *countP)
{
	UpdateRectStructPtr		curRectStructP;
	int						stillNeedsMerge = true;
	int						count = 0;
	while (stillNeedsMerge) 
	{
		stillNeedsMerge = false;
		curRectStructP = *headRectPP; 
		while(curRectStructP != NULL)
		{
			if ( SW_RECT_IS_IN_RECT( *theChangedRect, curRectStructP->updateRect) )
			{
				count ++;
				SW_UNION_RECT( *theChangedRect, curRectStructP->updateRect);
				SWRemoveUpdateRectStruct( headRectPP, curRectStructP);
				stillNeedsMerge = true;
				break;
			}
			curRectStructP = curRectStructP->nextRectStructP;
		}
	}
	if (countP)
	{	
		*countP = count;
	}
}
void SWMergeUpdateRect ( UpdateRectStructPtr * headRectPP , SWRect * theChangedRect , int * countP ) { UpdateRectStructPtr curRectStructP ; int stillNeedsMerge = true ; int count = 0 ; while ( stillNeedsMerge ) { stillNeedsMerge = false ; curRectStructP = * headRectPP ; while ( curRectStructP != NULL ) { if ( SW_RECT_IS_IN_RECT ( * theChangedRect , curRectStructP -> updateRect ) ) { count ++ ; SW_UNION_RECT ( * theChangedRect , curRectStructP -> updateRect ) ; SWRemoveUpdateRectStruct ( headRectPP , curRectStructP ) ; stillNeedsMerge = true ; break ; } curRectStructP = curRectStructP -> nextRectStructP ; } } if ( countP ) { * countP = count ; } }
SWMergeUpdateRect - merge the rect with others in the list, then add
SWMergeUpdateRect - merge the rect with others in the list then add
//will loop until there are no collisions with the update rect //will just fall (not fail) through if there is no head update rect //go through each struct //check for intersection with other rects //union the rects //remove the other rect from the list //we need to restart the checking, break out of this iteration //next link //end while each struct //end while stillneedsmerge //see if the number of merges result is wanted