Exemplo n.º 1
0
      void copy( VertexAttributeSetSharedPtr const& src, VertexAttributeSetSharedPtr const& dst )
      {
        if ( src != dst )
        {
          dst->setName( src->getName() );
          dst->setAnnotation( src->getAnnotation() );
          dst->setHints( src->getHints() );
          dst->setUserData( src->getUserData() );

          for ( unsigned int i=0 ; i<2*static_cast<unsigned int>(VertexAttributeSet::AttributeID::VERTEX_ATTRIB_COUNT) ; ++i )
          {
            VertexAttributeSet::AttributeID id = static_cast<VertexAttributeSet::AttributeID>(i);
            if ( src->getSizeOfVertexData( id ) )
            {
              DP_ASSERT( ( src->getOffsetOfVertexData( id ) == 0 ) && src->isContiguousVertexData( id ) );
              dst->setVertexData( id, src->getSizeOfVertexData( id ), src->getTypeOfVertexData( id )
                                , src->getVertexBuffer( id ), src->getOffsetOfVertexData( id )
                                , src->getStrideOfVertexData( id ), src->getNumberOfVertexData( id ) );
              dst->setEnabled( id, src->isEnabled( id ) );
              if ( id >= VertexAttributeSet::AttributeID::VERTEX_ATTRIB_COUNT )
              {
                dst->setNormalizeEnabled( id, src->isNormalizeEnabled( id ) );
              }
            }
          }
        }
      }
Exemplo n.º 2
0
      void copySelectedVertices( const VertexAttributeSetSharedPtr & from, const VertexAttributeSetSharedPtr & to
                               , std::vector<std::vector<unsigned int> > &indices )
      {
        // indexMap below is intended to hold vertex indices, which should not exceed 32-bit precision by definition!
        std::vector<unsigned int> indexMap( from->getNumberOfVertices(), ~0 );
        std::vector<unsigned int> iFrom; iFrom.reserve(from->getNumberOfVertices());
        for ( size_t i=0 ; i<indices.size() ; i++ )
        {
          for ( size_t j=0 ; j<indices[i].size() ; j++ )
          {
            if ( indexMap[indices[i][j]] == ~0 )
            {
              indexMap[indices[i][j]] = dp::checked_cast<unsigned int>(iFrom.size());
              iFrom.push_back(indices[i][j]);
            }
          }
        }

        for ( unsigned int slot=0 ; slot<static_cast<unsigned int>(VertexAttributeSet::AttributeID::VERTEX_ATTRIB_COUNT) ; slot++ )
        {
          VertexAttributeSet::AttributeID id = static_cast<VertexAttributeSet::AttributeID>(slot);
          if ( from->getSizeOfVertexData( id ) )
          {
            BufferSharedPtr oldData = from->getVertexBuffer(id);
            Buffer::DataReadLock lock( oldData );

            unsigned int size = from->getSizeOfVertexData( id );
            dp::DataType type = from->getTypeOfVertexData( id );

            to->setVertexData( id, NULL, &iFrom[0], size, type, lock.getPtr()
                             , from->getStrideOfVertexData( id )
                             , dp::checked_cast<unsigned int>(iFrom.size()) );

            // inherit enable states from source id
            // normalize-enable state only meaningful for generic aliases!
            to->setEnabled(id, from->isEnabled(id)); // conventional

            id = static_cast<VertexAttributeSet::AttributeID>(slot+16);    // generic
            to->setEnabled(id, from->isEnabled(id));
            to->setNormalizeEnabled(id, from->isNormalizeEnabled(id));
          }
        }

        for ( size_t i=0 ; i<indices.size() ; i++ )
        {
          for ( size_t j=0 ; j<indices[i].size() ; j++ )
          {
            indices[i][j] = indexMap[indices[i][j]];
          }
        }
      }