开发者

Blitting with a camera leads to seams (due to floating point errors?)

I'm working on a tilemap implementation with blitting (in Flash but I don't think it's language relevant). The problem I'm having is that as I pan my camera around, 1 pixel seams start to become visible depending on the location.

Here's how I decide my blitting point:

var destination : Point = _position.toPoint();

if (camera != null)
{
    destination.x -= camera.position.x;
    destination.y -= camera.position.y;
}

// the actual blit, not really relevant:
canvas.bitmapData.copyPixels(_bitmapData, _sou开发者_Python百科rceRectangle, destination, null, null, true);

As I scroll my camera around, I can see the position becoming really wonky. Here's some traces:

     pre-camera: 443 534
     post-camera: 396.3333333333333 294
     pre-camera: 476 534
     post-camera: 429.3333333333333 294
     pre-camera: 509 534
     post-camera: 462.3333333333333 294

The seams only appear with those .3333333333 post camera positions.

Does it seem logical that these floating point issues are what's causing the seams? Is it safe to just floor / round the destination values since you can't blit to half a pixel anyways.

Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜