void HostedObject::processLocationUpdate( const SpaceID& space, ProxyObjectPtr proxy_obj, bool predictive, TimedMotionVector3f* loc, uint64 loc_seqno, TimedMotionQuaternion* orient, uint64 orient_seqno, BoundingSphere3f* bounds, uint64 bounds_seqno, String* mesh, uint64 mesh_seqno, String* phy, uint64 phy_seqno ) { if (loc) proxy_obj->setLocation(*loc, loc_seqno); if (orient) proxy_obj->setOrientation(*orient, orient_seqno); if (bounds) proxy_obj->setBounds(*bounds, bounds_seqno); if (mesh) proxy_obj->setMesh(Transfer::URI(*mesh), mesh_seqno); if (phy && *phy != "") proxy_obj->setPhysics(*phy, phy_seqno); }
ProxyObjectPtr ProxyManager::createObject( const SpaceObjectReference& id, const TimedMotionVector3f& tmv, const TimedMotionQuaternion& tmq, const AggregateBoundingInfo& bs, const Transfer::URI& meshuri, const String& phy, bool isAggregate, uint64 seqNo ) { PROXYMAN_SERIALIZED(); ProxyObjectPtr newObj; // Try to reuse an existing object, even if we only have a valid // weak pointer to it. assert(id.space() == mID.space()); ProxyMap::iterator iter = mProxyMap.find(id.object()); if (iter != mProxyMap.end()) { // From strong ref newObj = iter->second.ptr; if (!newObj) { // From weak ref newObj = iter->second.wptr.lock(); // And either update the strong ref or clear out the entry // if its not even valid anymore. if (newObj) iter->second.ptr = newObj; else mProxyMap.erase(iter); } } // If we couldn't get a valid existing copy, create and insert a // new one. if (!newObj) { newObj = ProxyObject::construct(getSharedPtr(), id); std::pair<ProxyMap::iterator, bool> result = mProxyMap.insert( ProxyMap::value_type( newObj->getObjectReference().object(), ProxyData(newObj) ) ); iter = result.first; } assert(newObj); assert(newObj->getObjectReference() == id); assert(newObj->getOwner().get() == this); // This makes things simpler elsewhere: For new objects, we ensure // all the values are set properly so that when the notification // happens below, the proxy passed to listeners (for // onCreateProxy) will be completely setup, making it valid for // use. We don't need this for old ProxyObjects since they were // already initialized. The seqNo of 0 only updates something if it wasn't // set yet. newObj->setLocation(tmv, 0); newObj->setOrientation(tmq, 0); newObj->setBounds(bs, 0); if(meshuri) newObj->setMesh(meshuri, 0); if(phy.size() > 0) newObj->setPhysics(phy, 0); newObj->setIsAggregate(isAggregate, 0); // Notification of the proxy will have already occured, but // updates via, e.g., PositionListener or MeshListener, will go // out here, so the potentially invalid initial data automatically // filled when the object was created by createObject() shouldn't // matter. newObj->setLocation(tmv, seqNo); newObj->setOrientation(tmq, seqNo); newObj->setBounds(bs, seqNo); if(meshuri) newObj->setMesh(meshuri, seqNo); if(phy.size() > 0) newObj->setPhysics(phy, seqNo); newObj->setIsAggregate(isAggregate, seqNo); // Notification has to happen either way notify(&ProxyCreationListener::onCreateProxy, newObj); return newObj; }