// Check for intersection
BOOL _rect_place(L_rect &r, lm_layer* D)
{
	L_rect R;

	// Normal
	{
		u32 x_max = c_LMAP_size-r.b.x; 
		u32 y_max = c_LMAP_size-r.b.y; 
		for (u32 _Y=0; _Y<y_max; _Y++)
		{
			for (u32 _X=0; _X<x_max; _X++)
			{
				if (surface[_Y*c_LMAP_size+_X]) continue;
				R.init(_X,_Y,_X+r.b.x,_Y+r.b.y);
				if (Place_Perpixel	(R,D,FALSE)) {
					_rect_register	(R,D,FALSE);
					r.set			(R);
					return TRUE;
				}
			}
		}
	}
	
	// Rotated
	{
		u32 x_max = c_LMAP_size-r.b.y; 
		u32 y_max = c_LMAP_size-r.b.x; 
		for (u32 _Y=0; _Y<y_max; _Y++)
		{
			for (u32 _X=0; _X<x_max; _X++)
			{
				if (surface[_Y*c_LMAP_size+_X]) continue;
				
				R.init(_X,_Y,_X+r.b.y,_Y+r.b.x);
				if (Place_Perpixel	(R,D,TRUE)) {
					_rect_register	(R,D,TRUE);
					r.set			(R);
					return TRUE;
				}
			}
		}
	}
	
	return FALSE;
};
示例#2
0
文件: xrMergeLM.cpp 项目: 2asoft/xray
// Check for intersection
BOOL _rect_place(_rect &r, CDeflector* D)
{
	// Normal
	{
		_rect R;
		u32 x_max = lmap_size-r.b.x; 
		u32 y_max = lmap_size-r.b.y; 
		for (u32 _Y=0; _Y<y_max; _Y++)
		{
			for (u32 _X=0; _X<x_max; _X++)
			{
				if (surface[_Y*lmap_size+_X]) continue;
				R.init(_X,_Y,_X+r.b.x,_Y+r.b.y);
				if (Place_Perpixel(R,D,FALSE)) {
					_rect_register(R,D,FALSE);
					return TRUE;
				}
			}
		}
	}

	// Rotated
	{
		_rect R;
		u32 x_max = lmap_size-r.b.y; 
		u32 y_max = lmap_size-r.b.x; 
		for (u32 _Y=0; _Y<y_max; _Y++)
		{
			for (u32 _X=0; _X<x_max; _X++)
			{
				if (surface[_Y*lmap_size+_X]) continue;

				R.init(_X,_Y,_X+r.b.y,_Y+r.b.x);
				if (Place_Perpixel(R,D,TRUE)) {
					_rect_register(R,D,TRUE);
					return TRUE;
				}
			}
		}
	}

	return FALSE;
};