示例#1
0
void AssetDownloadTask::downloadAssetFile() {
    assert( !mAssetURI.empty() );

    ResourceDownloadTaskPtr dl = ResourceDownloadTask::construct(
        mAssetURI, mScene->transferPool(),
        mPriority,
        std::tr1::bind(&AssetDownloadTask::weakAssetFileDownloaded, getWeakPtr(), _1, _2)
    );
    mActiveDownloads[mAssetURI] = dl;
    dl->start();
}
示例#2
0
void AssetDownloadTask::handleAssetParsed(Mesh::MeshdataPtr md) {
    mAsset = md;

    if (!md) {
        SILOG(ogre,error,"Failed to parse mesh " << mAssetURI.toString());
        mCB();
        return;
    }

    // This is a sanity check. There's no way Ogre can reasonably handle meshes
    // that require a ton of draw calls. Estimate them here and if its too high,
    // destroy the data and invoke the callback to make it look like failure.
    {
        // Draw calls =
        //   Number of instances * number of primitives in instance
        uint32 draw_calls = 0;
        Meshdata::GeometryInstanceIterator geoinst_it = md->getGeometryInstanceIterator();
        uint32 geoinst_idx;
        Matrix4x4f pos_xform;
        while( geoinst_it.next(&geoinst_idx, &pos_xform) )
            draw_calls += md->geometry[ md->instances[geoinst_idx].geometryIndex ].primitives.size();

        // Arbitrary number, but probably more than we should even allow given
        // that there are probably hundreds or thousands of other objects
        if (draw_calls > 500) {
            SILOG(ogre,error,"Excessively complicated mesh: " << mAssetURI.toString() << " has " << draw_calls << " draw calls. Ignoring this mesh.");
            mAsset = Mesh::MeshdataPtr();
            mCB();
            return;
        }
    }

    mRemainingDownloads = md->textures.size();

    // Special case for no dependent downloads
    if (mRemainingDownloads == 0) {
        mCB();
        return;
    }

    String assetURIString = mAssetURI.toString();
    for(TextureList::const_iterator it = md->textures.begin(); it != md->textures.end(); it++) {
        String texURIString = assetURIString.substr(0, assetURIString.rfind("/")+1) + (*it);
        Transfer::URI texURI(texURIString);
        ResourceDownloadTaskPtr dl = ResourceDownloadTask::construct(
            texURI, mScene->transferPool(),
            mPriority,
            std::tr1::bind(&AssetDownloadTask::weakTextureDownloaded, getWeakPtr(), _1, _2)
        );
        mActiveDownloads[texURI] = dl;
        dl->start();
    }
}
示例#3
0
void AssetDownloadTask::downloadAssetFile() {
    assert( !mAssetURI.empty() );

    boost::mutex::scoped_lock lok(mDependentDownloadMutex);

    ResourceDownloadTaskPtr dl = ResourceDownloadTask::construct(
        mAssetURI, mScene->transferPool(),
        mPriority,
        std::tr1::bind(&AssetDownloadTask::weakAssetFileDownloaded, getWeakPtr(), _1, _2, _3)
    );
    mActiveDownloads[dl->getIdentifier()] = dl;
    dl->start();
}