Exemplo n.º 1
0
void OrphanLocUpdateManager::addOrphanUpdate(const SpaceObjectReference& observed, const Sirikata::Protocol::Loc::LocationUpdate& update) {
    assert( ObjectReference(update.object()) == observed.object() );
    UpdateInfoList& info_list = mUpdates[observed];
    info_list.push_back(
        UpdateInfoPtr(new UpdateInfo(observed, new Sirikata::Protocol::Loc::LocationUpdate(update), mContext->simTime() + mTimeout))
    );
}
    void notifyLocUpdate() {
        // We don't really need the protocol version of the loc
        // update, but it's a convenient way to construct the update
        // we need.
        Sirikata::Protocol::Loc::LocationUpdate update;
        update.set_object(UUID((uint32)mContext->id()));
        update.set_seqno(mSeqnoSource++);

        // Bogus index ID (as used in prox update) so manual queries can route
        // updates to the right place
        update.add_index_id(1);

        Sirikata::Protocol::ITimedMotionVector motion = update.mutable_location();
        motion.set_t(mContext->simTime());
        motion.set_position(mRegion.center());
        motion.set_velocity(Vector3f(0,0,0));

        Sirikata::Protocol::ITimedMotionQuaternion msg_orient = update.mutable_orientation();
        msg_orient.set_t(Time::null());
        msg_orient.set_position(Quaternion::identity());
        msg_orient.set_velocity(Quaternion::identity());

        Sirikata::Protocol::IAggregateBoundingInfo msg_bounds = update.mutable_aggregate_bounds();
        msg_bounds.set_center_offset( Vector3f(0,0,0) );
        msg_bounds.set_center_bounds_radius( mRegion.toBoundingSphere().radius() );
        msg_bounds.set_max_object_size(mLargest);

        update.set_query_data(mQueryData);

        // notify wants to only pass through values and tries to copy the
        // LocProtocolLocUpdate by default -- we need to jump through hoops and
        // specify the exact template types explicitly to make this work
        NopTimeSynced nop_ts;
	LocProtocolLocUpdate tmp(update, nop_ts);//need to assign a temporary for llvm compilers
        notify<void(PintoServerQuerierListener::*)(const Sirikata::LocUpdate&), const LocProtocolLocUpdate&>(&PintoServerQuerierListener::onPintoServerLocUpdate, tmp);
    }
Exemplo n.º 3
0
void StandardLocationService::receiveMessage(Message* msg) {
    assert(msg->dest_port() == SERVER_PORT_LOCATION);
    Sirikata::Protocol::Loc::BulkLocationUpdate contents;
    bool parsed = parsePBJMessage(&contents, msg->payload());

    if (parsed) {
        for(int32 idx = 0; idx < contents.update_size(); idx++) {
            Sirikata::Protocol::Loc::LocationUpdate update = contents.update(idx);

            // Its possible we'll get an out of date update. We only use this update
            // if (a) we have this object marked as a replica object and (b) we don't
            // have this object marked as a local object
            if (type(update.object()) != Replica)
                continue;

            LocationMap::iterator loc_it = mLocations.find( update.object() );
            // We can safely make this assertion right now because space server
            // to space server loc and prox are on the same reliable channel. If
            // this goes away then a) we can't make this assertion and b) we
            // need an OrphanLocUpdateManager to save updates where this
            // condition is false so they can be applied once the prox update
            // arrives.
            assert(loc_it != mLocations.end());

            if (update.has_location()) {
                TimedMotionVector3f newloc(
                    update.location().t(),
                    MotionVector3f( update.location().position(), update.location().velocity() )
                );
                loc_it->second.location = newloc;
                notifyReplicaLocationUpdated( update.object(), newloc );

                CONTEXT_SPACETRACE(serverLoc, msg->source_server(), mContext->id(), update.object(), newloc );
            }

            if (update.has_orientation()) {
                TimedMotionQuaternion neworient(
                    update.orientation().t(),
                    MotionQuaternion( update.orientation().position(), update.orientation().velocity() )
                );
                loc_it->second.orientation = neworient;
                notifyReplicaOrientationUpdated( update.object(), neworient );
            }

            if (update.has_bounds()) {
                BoundingSphere3f newbounds = update.bounds();
                loc_it->second.bounds = newbounds;
                notifyReplicaBoundsUpdated( update.object(), newbounds );
            }

            if (update.has_mesh()) {
                String newmesh = update.mesh();
                loc_it->second.mesh = newmesh;
                notifyReplicaMeshUpdated( update.object(), newmesh );
            }

            if (update.has_physics()) {
                String newphy = update.physics();
                loc_it->second.physics = newphy;
                notifyReplicaPhysicsUpdated( update.object(), newphy );
            }
        }
    }

    delete msg;
}