Vec2I GetMapMotionPosition( Vec2 pos ) { Vec2 pf = ( pos - mapMotionPosition ) * gridCellSizeInv; Vec2I p = new Vec2I( (int)pf.X, (int)pf.Y ); p.Clamp( new Vec2I( 0, 0 ), mapMaxIndex ); return p; }
RectI GetMapMotionRectangle( Rect rect ) { Vec2 minf = ( rect.Minimum - mapMotionPosition ) * gridCellSizeInv; Vec2 maxf = ( rect.Maximum - mapMotionPosition ) * gridCellSizeInv; Vec2I min = new Vec2I( (int)minf.X, (int)minf.Y ); Vec2I max = new Vec2I( (int)maxf.X, (int)maxf.Y ); min.Clamp( new Vec2I( 0, 0 ), mapMaxIndex ); max.Clamp( new Vec2I( 0, 0 ), mapMaxIndex ); return new RectI( min, max ); }