[help] the TextureStretch Assertion

Grom

09-02-2007 09:04:17

I am getting this assertion when my program loads

Expression: mImages[channel].getHeight() / (mParent->getOptions()->PageSize - 1) == mParent->getOptions()->TextureStretchFactor && String("(texture size / (pagesize-1)) and texture stretch factor defined in terrain config file doesn't fit.").c_str()

and I've read around to see that apparently it means the TextureStretchFactor in my cfg file doesn't match the one I used with the mapslitter. My heightmap/texture are both 2049 before being split. the TextureStretchFactor I'm using is 4. I don't get anything in the logs. I am frustrated.

Grom

10-02-2007 13:32:30

After trying it 3-4 more times with different styles of cfg files and whatnot, I got it to work.

seljo

12-03-2009 22:11:36

What was your fix? I am having the same problem. Hope this thread is not dead.

DragonM

22-03-2009 22:16:10

There is a config file option that will solve this problem, but it's the wrong solution. Setting TextureStretchFactor=0 will make the assert go away. That's hides another problem though.

Even when your config files are otherwise correct and all resources are being successfully located, the assert is triggering because the existing code fails to load any data, even if it's present. Evidently the behavior of Ogre::Image has changed. Formerly it appeared to clear its data buffer to zero if it wasn't initialized. That is no longer the case, so a PLSM check for data was coming back erroneously true.

There's also a problem where PLSM attempts to clear a data buffer by using loadDynamicImage with a null data pointer. Ogre no longer tolerates that and will crash. I've chosen to comment out the two problem lines. This may not be the correct long term solution.

Here's the patch:
Index: OgrePagingLandScapeTexture.cpp
===================================================================
--- OgrePagingLandScapeTexture.cpp (revision 2654)
+++ OgrePagingLandScapeTexture.cpp (working copy)
@@ -94,7 +94,7 @@

for (size_t i = 0; i < mNumTexture; i++)
{
- mImages[i].loadDynamicImage (0, 0, 0, 1, PF_R8G8B8A8, true, 1, 0);
+ //mImages[i].loadDynamicImage (0, 0, 0, 1, PF_R8G8B8A8, true, 1, 0);
}

}
@@ -818,7 +818,7 @@
isTextureModified[i] = false;
mBuffers[i].setNull ();
mTextures[i].setNull ();
- mImages[i].loadDynamicImage (0, 0, 0, 1, PF_R8G8B8A8, true, 1, 0);
+ //mImages[i].loadDynamicImage (0, 0, 0, 1, PF_R8G8B8A8, true, 1, 0);
}
// Anyway, they're surely null already, as they're freed by delete page()

@@ -962,7 +962,7 @@
//-----------------------------------------------------------------------
void PagingLandScapeTexture::loadTexture(const String &filename, Image &img)
{
- if (img.getData () == 0)
+ if (img.getSize() == 0)
{
img.load(filename, mParent->getOptions()->groupName);
}
As usual, save to a file such as texture.patch and (in Windows) use TortoiseSVN to apply it to your source. In Linux, the patch command is your friend.

DM