void MeshSequenceReader::trackerUpdate(TrackerOutputInfo& outputInfo)
{
    TICK("visualRenderingUpdate");

    UpdateRenderingData(outputInfo, KK, camPose, currentMesh);
    UpdateRenderingDataFast(outputInfo, KK, currentMesh);

    if(useVisibilityMask)
    {
        UpdateVisibilityMaskGL(outputInfo, visibilityMask, KK, camPose, m_nWidth, m_nHeight);
        //UpdateVisibilityMask(outputInfo, visibilityMask, m_nWidth, m_nHeight);
        UpdateColorDiff(outputInfo, visibilityMask, colorImageSplit);
    }

    TOCK("visualRenderingUpdate");
}
void MeshPyramidReader::setMeshPyramid()
{
    visibilityMaskPyramid.resize(m_nNumMeshLevels);
    outputInfoPyramid.resize(m_nNumMeshLevels);
    outputPropPyramid.resize(m_nNumMeshLevels);

    for(int i = 0; i < m_nNumMeshLevels; ++i)
    {
        int numVertices = currentMeshPyramid.levels[i].numVertices;
        visibilityMaskPyramid[i].resize(numVertices,true);

        vector<CoordinateType> proj2D;
        proj2D.resize(2); proj2D[0] = 0; proj2D[1] = 0;

        outputInfoPyramid[i].meshData = currentMeshPyramid.levels[i];
        outputInfoPyramid[i].nRenderLevel = i;
        outputInfoPyramid[i].meshProj.resize(numVertices, proj2D);
        outputInfoPyramid[i].visibilityMask.resize(numVertices, true);
        
        // memset(outputInfoPyramid[i].camPose, 0, 6*sizeof(double));
        // UpdateRenderingData(outputInfoPyramid[i], KK, camPose, outputInfoPyramid[i].meshData);
        UpdateRenderingDataFast(outputInfoPyramid[i], KK, outputInfoPyramid[i].meshData);
        
        if(!meshLoadingSettings.fastLoading)
        {
            outputInfoPyramid[i].meshDataGT = outputInfoPyramid[i].meshData;
            outputInfoPyramid[i].meshDataColorDiff = outputInfoPyramid[i].meshData;
            outputInfoPyramid[i].meshProjGT = outputInfoPyramid[i].meshProj;
        }

        // update the visibility of each vertex
        if(useVisibilityMask)
        {

            TICK( "visibilityMaskLevel" + std::to_string(i) );
            
            UpdateVisibilityMaskGL(outputInfoPyramid[i], visibilityMaskPyramid[i], KK, camPose, m_nWidth, m_nHeight);
            
            if(!meshLoadingSettings.fastLoading)
            UpdateColorDiff(outputInfoPyramid[i], outputInfoPyramid[i].visibilityMask, colorImageSplit);

            TOCK( "visibilityMaskLevel"  + std::to_string(i) );
        }

        //////////////////////////// outputPropPyramid
        if(meshLoadingSettings.loadProp)
        {
            outputPropPyramid[i].meshData = propMeshPyramid.levels[i];
            outputPropPyramid[i].nRenderLevel = i;
            outputPropPyramid[i].meshProj.resize(numVertices, proj2D);
            outputPropPyramid[i].visibilityMask.resize(numVertices, true);
            
            // memset(outputPropPyramid[i].camPose, 0, 6*sizeof(double));
            // UpdateRenderingData(outputPropPyramid[i], KK, camPose, propMeshPyramid.levels[i]);
            UpdateRenderingDataFast(outputPropPyramid[i], KK, propMeshPyramid.levels[i]);
            if(!meshLoadingSettings.fastLoading)
            {
                outputPropPyramid[i].meshDataGT = propMeshPyramid.levels[i];
                outputPropPyramid[i].meshDataColorDiff = propMeshPyramid.levels[i];
                outputPropPyramid[i].meshProjGT = outputPropPyramid[i].meshProj;
            }
            
            // update the visibility of each vertex
            if(useVisibilityMask)
            {
                UpdateVisibilityMaskGL(outputPropPyramid[i], visibilityMaskPyramid[i], KK, camPose, m_nWidth, m_nHeight);
                if(!meshLoadingSettings.fastLoading)
                UpdateColorDiff(outputPropPyramid[i], outputPropPyramid[i].visibilityMask, colorImageSplit);
            }
        }
    }
}