Changeset 2685


Ignore:
Timestamp:
05/17/08 01:15:07 (16 years ago)
Author:
mattausch
Message:

fixed bugs: pixel measurement for pgv now working, fixed renderpvs crash

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2680 r2685  
    15091509                        int pvsSize; 
    15101510 
    1511                         float error = GetPixelError(pvsSize); 
    1512  
    1513                         mPvsErrorBuffer[i].mError = error; 
     1511                        mPvsErrorBuffer[i].mError = GetPixelError(pvsSize); 
    15141512                        mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    15151513 
     
    15871585                //cout << "\n\nvp: " << (*sit) << endl; 
    15881586                SimpleRay sray = *sit; 
    1589                 int pvsSize = 0; 
     1587                int pvsSize = -1; 
    15901588 
    15911589                // set frame id for saving the error buffer 
     
    15991597                { 
    16001598                        // compute the pixel error 
    1601                         const float error = GetPixelError(pvsSize); 
    1602  
    1603                         mPvsErrorBuffer[i].mError = error; 
     1599                        mPvsErrorBuffer[i].mError = GetPixelError(pvsSize); 
    16041600                        mPvsErrorBuffer[i].mPvsSize = pvsSize; 
    16051601 
    1606                         const int pixelError = (int)mPvsErrorBuffer[i].mError * GetWidth() * GetHeight(); 
    1607  
    1608                         if (0 && (pixelError > 0) && (pvsSize > 0))  
     1602                        if (0 && (mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() > 0) && (pvsSize > 0))  
    16091603                        { 
    1610                                 cout << "err: " << i << "," << mViewPoint << "," << mViewDirection << " "  
     1604                                cout << "error in frame " << i << "," << mViewPoint << "," << mViewDirection << " "  
    16111605                                         << mPvsErrorBuffer[i].mError * GetWidth() * GetHeight() << endl; 
    16121606                        } 
     
    16201614                 
    16211615                if (//(mFrame > 0) &&  
    1622                         (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0))  
     1616                        (err >=  -1e-6f) && (err < (1.0f - 1e-6f)) && (pvsSize != 0))  
    16231617                { 
    16241618                        if (err > mPvsStat.maxError) 
    16251619                        { 
    16261620                                mPvsStat.maxError = err; 
    1627  
    16281621                                cout << "new max error: " << mPvsStat.maxError * GetWidth() * GetHeight()  << endl; 
    16291622                        } 
     
    16381631                        // moved it back here not to count frames with negative err (backfacing triangle) 
    16391632                        ++ mPvsStat.frames; 
     1633                } 
     1634                else 
     1635                { 
     1636                        cerr << "warning: negative error " << err << " at pvs size " << pvsSize << endl; 
    16401637                } 
    16411638 
     
    18431840} 
    18441841 
     1842 
    18451843void GlRenderer::_UpdatePvsIndices(KdNode *node, int &indexBufferSize) 
    18461844{ 
     
    18721870                        { 
    18731871                                obj->mRenderedFrame = mCurrentFrame; 
    1874  
    1875                                 mIndices[indexBufferSize + 0] = (obj->GetId() - 1) * 3 + 0; 
    1876                                 mIndices[indexBufferSize + 1] = (obj->GetId() - 1) * 3 + 1; 
    1877                                 mIndices[indexBufferSize + 2] = (obj->GetId() - 1) * 3 + 2; 
     1872                                 
     1873                                const int id = obj->GetId() * 3; 
     1874 
     1875                                mIndices[indexBufferSize + 0] = id + 0; 
     1876                                mIndices[indexBufferSize + 1] = id + 1; 
     1877                                mIndices[indexBufferSize + 2] = id + 2; 
    18781878 
    18791879                                indexBufferSize += 3; 
     
    18901890void GlRenderer::CreateVertexArrays(SceneGraphLeaf *leaf) 
    18911891{ 
    1892     mData = new Vector3[leaf->mGeometry.size() * 6]; 
    1893         mIndices = new unsigned int[leaf->mGeometry.size() * 3]; 
    1894  
    18951892        size_t offset = leaf->mGeometry.size() * 3; 
     1893 
     1894    mData = new Vector3[offset * 2]; 
     1895        mIndices = new unsigned int[offset]; 
     1896 
    18961897 
    18971898        for (size_t i = 0; i < leaf->mGeometry.size(); ++ i) 
     
    19091910                mData[offset + i * 3 + 1] = n; 
    19101911                mData[offset + i * 3 + 2] = n; 
     1912 
     1913                mIndices[i * 3 + 0] = 0; 
     1914                mIndices[i * 3 + 1] = 0; 
     1915                mIndices[i * 3 + 2] = 0; 
    19111916        } 
    19121917 
     
    19211926                glNormalPointer(GL_FLOAT, 0, (char *)NULL + offset * sizeof(Vector3)); 
    19221927 
    1923                 glBufferDataARB(GL_ARRAY_BUFFER_ARB, leaf->mGeometry.size() * 6 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB); 
     1928                glBufferDataARB(GL_ARRAY_BUFFER_ARB, offset * 2 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB); 
    19241929                glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
    19251930 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2682 r2685  
    15351535        } 
    15361536#else 
    1537         return mObjects[id - 1]; 
     1537        return mObjects[id]; 
    15381538#endif 
    15391539} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2683 r2685  
    581581        glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 
    582582 
    583 #if 0// DYNAMIC_OBJECTS_HACK 
     583#if DYNAMIC_OBJECTS_HACK 
    584584        // handle dynamic objects 
    585585        DynamicObjectsContainer::const_iterator dit, dit_end = mDynamicObjects.end(); 
     
    819819  if (e->modifiers() & Qt::AltModifier)  
    820820        if (mCurrentDynamicObjectIdx >= 0) { 
    821           //      preprocessor->ScheduleUpdateDynamicObjects(); 
     821          // preprocessor->ScheduleUpdateDynamicObjects(); 
    822822        } 
    823823} 
     
    829829        float TURN_SENSITIVITY = 0.1f; 
    830830        float TILT_SENSITIVITY = 32.0 ; 
    831         float TURN_ANGLE= M_PI  /36.0 ; 
     831        float TURN_ANGLE= M_PI / 36.0 ; 
    832832 
    833833        int x = e->pos().x(); 
     
    843843                mViewPoint.y += (y-mousePoint.y)*MOVE_SENSITIVITY / 2.0; 
    844844                mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 
    845         }  
     845        } 
    846846#if DYNAMIC_OBJECTS_HACK 
    847847        else if (e->modifiers() & Qt::AltModifier) 
     
    883883                        } 
    884884 
    885 #if USE_TRANSFORMED_MESH_INSTANCE_HACK 
    886                         TransformedMeshInstance *tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 
    887                         tmi->ApplyWorldTransform(tm); 
    888 #else 
    889885                        SceneGraphLeaf *l = 
    890886                          mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 
    891887                        l->ApplyTransform(tm); 
    892888                         
    893 #endif 
    894889                        updateGL(); 
    895890                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj

    r2680 r2685  
    157157                                LinkIncremental="1" 
    158158                                AdditionalLibraryDirectories="&quot;$(QTDIR)\lib&quot;;..\src\GL;&quot;..\lib05\$(ConfigurationName)&quot;;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;&quot;..\MultiLevelRayTracing\RTScene\$(ConfigurationName)&quot;;&quot;..\MultiLevelRayTracing\RTWorld\$(ConfigurationName)&quot;;&quot;QtInterface\$(ConfigurationName)&quot;;&quot;..\..\..\..\..\..\NonGTP\Xerces\xerces-c_2_8_0\lib&quot;;&quot;$(CG_LIB_PATH)&quot;" 
    159                                 GenerateDebugInformation="true" 
     159                                GenerateDebugInformation="false" 
    160160                                SubSystem="1" 
    161161                                LargeAddressAware="2" 
Note: See TracChangeset for help on using the changeset viewer.