예제 #1
0
void AssetDownloadTask::assetFileDownloaded(ResourceDownloadTaskPtr taskptr, Transfer::ChunkRequestPtr request, Transfer::DenseDataPtr response) {
    boost::mutex::scoped_lock lok(mDependentDownloadMutex);

    // Clear from the active download list
    assert(mActiveDownloads.size() == 1);
    mActiveDownloads.erase(taskptr->getIdentifier());
    mFinishedDownloads.push_back(taskptr->getIdentifier());

    // Lack of response data means failure of some sort
    if (!response) {
        SILOG(ogre, warn, "Failed to download resource for " << taskptr->getIdentifier());
        failDownload();
        return;
    }

    // FIXME here we could have another callback which lets them get
    // at the hash to try to use an existing copy. Even with the
    // eventual centralized loading we want, this may still be
    // beneficial since Ogre may have a copy even if we don't have a
    // copy of the raw data any more.

    mParseMeshHandle = mScene->parseMesh(
        request->getMetadata(), request->getMetadata().getFingerprint(),
        response, mIsAggregate,
        std::tr1::bind(&AssetDownloadTask::weakHandleAssetParsed, getWeakPtr(), _1)
    );
}
예제 #2
0
void AssetDownloadTask::addDependentDownload(const Transfer::URI& depUrl, const Transfer::Chunk& depChunk) {
    ResourceDownloadTaskPtr dl = ResourceDownloadTask::construct(
        depChunk, mScene->transferPool(),
        mPriority,
        std::tr1::bind(&AssetDownloadTask::weakTextureDownloaded, getWeakPtr(), depUrl, _1, _2, _3)
    );
    addDependentDownload(dl);
}
예제 #3
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();
}
예제 #4
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();
    }
}
예제 #5
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();
}
예제 #6
0
bool HostedObject::objectHostConnect(const SpaceID spaceID,
        const Location startingLocation,
        const BoundingSphere3f meshBounds,
        const String mesh,
        const String physics,
        const String query,
        const String zernike,
        const ObjectReference orefID,
        PresenceToken token)
{
  ObjectReference oref = (orefID == ObjectReference::null()) ? ObjectReference(UUID::random()) : orefID;

  SpaceObjectReference connectingSporef (spaceID,oref);

  // Note: we always use Time::null() here.  The server will fill in the
  // appropriate value.  When we get the callback, we can fix this up.
  Time approx_server_time = Time::null();
  if (mObjectHost->connect(
                           getSharedPtr(),
                           connectingSporef, spaceID,
                           TimedMotionVector3f(approx_server_time, MotionVector3f( Vector3f(startingLocation.getPosition()), startingLocation.getVelocity()) ),
                           TimedMotionQuaternion(approx_server_time,MotionQuaternion(startingLocation.getOrientation().normal(),Quaternion(startingLocation.getAxisOfRotation(),startingLocation.getAngularSpeed()))),  //normalize orientations
                           meshBounds,
                           mesh,
                           physics,
                           query,
                           zernike,
                           std::tr1::bind(&HostedObject::handleConnected, getWeakPtr(), mObjectHost, _1, _2, _3),
                           std::tr1::bind(&HostedObject::handleMigrated, getWeakPtr(), _1, _2, _3),
                           std::tr1::bind(&HostedObject::handleStreamCreated, getWeakPtr(), _1, _2, token),
                           std::tr1::bind(&HostedObject::handleDisconnected, getWeakPtr(), _1, _2)
                           )) {
    mObjectHost->registerHostedObject(connectingSporef,getSharedPtr());
    return true;
  }else {
    return false;
  }
}
예제 #7
0
void AssetDownloadTask::assetFileDownloaded(std::tr1::shared_ptr<ChunkRequest> request, std::tr1::shared_ptr<const DenseData> response) {
    // Clear from the active download list
    assert(mActiveDownloads.size() == 1);
    mActiveDownloads.erase(mAssetURI);

    // Lack of response data means failure of some sort
    if (!response) {
        failDownload();
        return;
    }

    // FIXME here we could have another callback which lets them get
    // at the hash to try to use an existing copy. Even with the
    // eventual centralized loading we want, this may still be
    // beneficial since Ogre may have a copy even if we don't have a
    // copy of the raw data any more.

    mScene->parseMesh(
        mAssetURI, request->getMetadata().getFingerprint(), response,
        std::tr1::bind(&AssetDownloadTask::weakHandleAssetParsed, getWeakPtr(), _1)
    );
}
ResourceDependencyTask* GraphicsResourceShader::createDependencyTask(DependencyManager *manager)
{
  return new ShaderDependencyTask(manager, getWeakPtr(), mResourceID.toString());
}
ResourceUnloadTask* GraphicsResourceShader::createUnloadTask(DependencyManager *manager)
{
  return new ShaderUnloadTask(manager, getWeakPtr(), mResourceID.toString(), mArchiveName, mLoadEpoch);
}
예제 #10
0
 std::tr1::shared_ptr<T> getSharedPtr() const {
     std::tr1::shared_ptr<T> retval(getWeakPtr());
     return retval;
 }
예제 #11
0
ResourceUnloadTask* GraphicsResourceMesh::createUnloadTask(DependencyManager *manager)
{
  return new MeshUnloadTask(manager, getWeakPtr(), mResourceID.toString(), mLoadEpoch);
}
예제 #12
0
 void addDependency(SharedResourcePtr newResource) {
   assert(newResource);
   mDependencies.insert(newResource);
   newResource->addDependent(getWeakPtr());
 }