[BUG] Crash with text using high-numbered unicode characters (w/ fix) - LOGGED - THREED-3167
by Manoel Neto · in Torque 3D Professional · 08/09/2011 (10:50 am) · 1 replies
Got this one suddenly after using pre-populated font caches. If your text includes a very high-numbered unicode char, you get a crash caused by uninitialized font batch sheets. Here's the fix:
In Engine/source/gfx/gfxFontRenderBatcher.cpp, in FontRenderBatcher::getSheetMarker(), replace this:
By this:
The problem was that if a character was on a sheet that was more than 1 away from the currently allocated sheets, the old code would generate non-initialized sheets in-between.
In Engine/source/gfx/gfxFontRenderBatcher.cpp, in FontRenderBatcher::getSheetMarker(), replace this:
if(mSheets.size() <= sheetID || !mSheets[sheetID])
{
if(sheetID >= mSheets.size())
mSheets.setSize(sheetID+1);
S32 size = sizeof( SheetMarker) + mLength * sizeof( CharMarker );
mSheets[sheetID] = (SheetMarker *)mStorage.alloc(size);
mSheets[sheetID]->numChars = 0;
mSheets[sheetID]->startVertex = 0; // cosmetic initialization
}By this:
for (U32 i=mSheets.size(); i<=sheetID; i++)
{
if(i >= mSheets.size())
mSheets.setSize(i+1);
S32 size = sizeof( SheetMarker) + mLength * sizeof( CharMarker );
mSheets[i] = (SheetMarker *)mStorage.alloc(size);
mSheets[i]->numChars = 0;
mSheets[i]->startVertex = 0; // cosmetic initialization
}The problem was that if a character was on a sheet that was more than 1 away from the currently allocated sheets, the old code would generate non-initialized sheets in-between.
About the author
Associate David Montgomery-Blake
David MontgomeryBlake