Game Development Community

Bug with cell based imagemaps

by Greg Lincoln · in Torque Game Builder · 03/14/2005 (4:45 pm) · 3 replies

I found a bug (I think) in the code that loads imagemaps in "cell mode." (BTW, sorry if this has already been reported. I searched and couldn't find any mention of it.)

The problem is that it seems to cut off a row of pixels from the bottom and the right sides.

Here are two pictures that illustrate the problem, and below them you can see the code I changed to fix it.

This picture shows the bad behavior. On the left, there is a 32x32 png image loaded in "full" mode. On the right we see frame 0 of a 128x32 png image loaded as cells. You can see how the image on the right is off center.

mazinsoftware.com/t2d/bad.gif
Here's the expected behavior, after my fix, using the same datamaps and sprites:

mazinsoftware.com/t2d/good.gif
I changed the line below in the method fxImageMapDatablock2D::calculateCellImageMap: (linefeeds added for size)

//tMapRegion region = { x*mCellWidth * mTexelWidth, y*mCellHeight * mTexelHeight,
(x*mCellWidth+mCellWidth-1) * mTexelWidth, (y*mCellHeight+mCellHeight-1) * mTexelHeight };
tMapRegion region = { x*mCellWidth * mTexelWidth, y*mCellHeight * mTexelHeight,
(x*mCellWidth+mCellWidth) * mTexelWidth, (y*mCellHeight+mCellHeight) * mTexelHeight };

The commented line is how it was, and below shows that I removed the -1 from the second coordinate pair for my fix. I have no idea if this will break something else or if this is a "wrong" fix, but it seems to work for me. YMMV.

Greg

#1
03/15/2005 (12:28 am)
Thanks for the report Greg and you'll be pleased to hear that this problem has been fixed already and will be in the next update.

Thanks again.

- Melv.
#2
03/15/2005 (10:31 am)
Ah, so I wasn't crazy!! :) I noticed this but it was so subtle I was sure it was my eyes. Thanks for fixing this, Melv.
#3
03/15/2005 (10:33 am)
No problem. There was bound to be lots of little problems like this initially. We'll get 'em all eventually. :)

- Melv.