Ticket #2024: branch.patch

File branch.patch, 3.2 KB (added by tuan kuranes, 11 years ago)
  • source/graphics/LOSTexture.cpp

     
    309309    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]);
    310310}
    311311
    312 size_t CLOSTexture::GetBitmapSize(size_t w, size_t h)
     312size_t CLOSTexture::GetBitmapSize(const size_t w, const size_t h) const
    313313{
    314314    return (w + g_BlurSize - 1) * (h + g_BlurSize - 1);
    315315}
    316316
    317 void CLOSTexture::GenerateBitmap(ICmpRangeManager::CLosQuerier los, u8* losData, size_t w, size_t h)
     317
     318void CLOSTexture::GenerateBitmap(ICmpRangeManager::CLosQuerier los, u8* const losData, const size_t w, const size_t h)
    318319{
    319320    const size_t rowSize = w + g_BlurSize-1; // size of losData rows
    320 
     321    const size_t halfBlurSize = g_BlurSize / 2;
    321322    u8 *dataPtr = losData;
     323       
     324    memset(dataPtr, 0, rowSize*h);
    322325
    323326    // Initialise the top padding
    324     for (size_t j = 0; j < g_BlurSize/2; ++j)
    325         for (size_t i = 0; i < rowSize; ++i)
    326             *dataPtr++ = 0;
    327 
    328     for (size_t j = 0; j < h; ++j)
     327    dataPtr += rowSize*halfBlurSize;
     328    for (size_t j = 0; j < h; j++)
    329329    {
    330         // Initialise the left padding
    331         for (size_t i = 0; i < g_BlurSize/2; ++i)
    332             *dataPtr++ = 0;
     330        // Initialise the left padding 
     331        dataPtr += halfBlurSize;           
    333332
    334333        // Fill in the visibility data
    335         for (size_t i = 0; i < w; ++i)
     334        for (size_t i = 0; i < w; i++)
    336335        {
    337336            if (los.IsVisible_UncheckedRange(i, j))
    338                 *dataPtr++ = 255;
     337                *dataPtr = 255;
    339338            else if (los.IsExplored_UncheckedRange(i, j))
    340                 *dataPtr++ = 127;
    341             else
    342                 *dataPtr++ = 0;
     339                *dataPtr = 127;
     340            dataPtr++;
    343341        }
    344342
    345         // Initialise the right padding
    346         for (size_t i = 0; i < g_BlurSize/2; ++i)
    347             *dataPtr++ = 0;
     343        // move after the right padding
     344        dataPtr += halfBlurSize;   
    348345    }
    349 
    350     // Initialise the bottom padding
    351     for (size_t j = 0; j < g_BlurSize/2; ++j)
    352         for (size_t i = 0; i < rowSize; ++i)
    353             *dataPtr++ = 0;
    354 
     346   
    355347    // Horizontal blur:
    356 
    357     for (size_t j = g_BlurSize/2; j < h + g_BlurSize/2; ++j)
     348    for (size_t j = halfBlurSize; j < h + halfBlurSize; j++)
    358349    {
    359         for (size_t i = 0; i < w; ++i)
     350        const size_t jrowSize = j*rowSize;
     351        for (size_t i = 0; i < w; i++)
    360352        {
    361             u8* d = &losData[i+j*rowSize];
     353            u8* const d = &losData[i+jrowSize];
    362354            *d = (
    363355                1*d[0] +
    364356                6*d[1] +
     
    375367
    376368    for (size_t j = 0; j < h; ++j)
    377369    {
     370        const size_t jrowSize =j*rowSize;
    378371        for (size_t i = 0; i < w; ++i)
    379372        {
    380             u8* d = &losData[i+j*rowSize];
     373            u8* const d = &losData[i+jrowSize];
    381374            *d = (
    382375                1*d[0*rowSize] +
    383376                6*d[1*rowSize] +
  • source/graphics/LOSTexture.h

     
    8181    void ConstructTexture(int unit);
    8282    void RecomputeTexture(int unit);
    8383
    84     size_t GetBitmapSize(size_t w, size_t h);
    85     void GenerateBitmap(ICmpRangeManager::CLosQuerier los, u8* losData, size_t w, size_t h);
     84    size_t GetBitmapSize(const size_t w, const size_t h) const ;
     85    void GenerateBitmap(ICmpRangeManager::CLosQuerier los, u8* const losData, const size_t w, const size_t h);
    8686
    8787    CSimulation2& m_Simulation;
    8888