Ejemplo n.º 1
0
        public void RemovePrim(LLUUID primID)
        {
            IObjectSet result = db.Query(new UUIDQuery(primID));

            if (result.Count > 0)
            {
                PrimData found = (PrimData)result.Next();
                db.Delete(found);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Loads a specific object from storage
 /// </summary>
 /// <param name="prim">The object to load</param>
 public void PrimFromStorage(PrimData prim)
 {
     try
     {
         if (prim.LocalID >= this._primCount)
         {
             _primCount = prim.LocalID + 1;
         }
         OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage");
         Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
         nPrim.CreateFromStorage(prim);
         this.Entities.Add(nPrim.uuid, nPrim);
     }
     catch (Exception e)
     {
         OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Failed with exception " + e.ToString());
     }
 }
Ejemplo n.º 3
0
        public void StorePrim(PrimData prim)
        {
            IObjectSet result = db.Query(new UUIDQuery(prim.FullID));

            if (result.Count > 0)
            {
                //prim already in storage
                //so update it
                PrimData found = (PrimData)result.Next();
                found.PathBegin        = prim.PathBegin;
                found.PathCurve        = prim.PathCurve;
                found.PathEnd          = prim.PathEnd;
                found.PathRadiusOffset = prim.PathRadiusOffset;
                found.PathRevolutions  = prim.PathRevolutions;
                found.PathScaleX       = prim.PathScaleX;
                found.PathScaleY       = prim.PathScaleY;
                found.PathShearX       = prim.PathShearX;
                found.PathShearY       = prim.PathShearY;
                found.PathSkew         = prim.PathSkew;
                found.PathTaperX       = prim.PathTaperX;
                found.PathTaperY       = prim.PathTaperY;
                found.PathTwist        = prim.PathTwist;
                found.PathTwistBegin   = prim.PathTwistBegin;
                found.PCode            = prim.PCode;
                found.ProfileBegin     = prim.ProfileBegin;
                found.ProfileCurve     = prim.ProfileCurve;
                found.ProfileEnd       = prim.ProfileEnd;
                found.ProfileHollow    = prim.ProfileHollow;
                found.Position         = prim.Position;
                found.Rotation         = prim.Rotation;
                found.Texture          = prim.Texture;
                db.Set(found);
                db.Commit();
            }
            else
            {
                //not in storage
                db.Set(prim);
                db.Commit();
            }
        }
        public bool RezObject(SimClient simClient, Packet packet)
        {
            RezObjectPacket rezPacket = (RezObjectPacket)packet;
            AgentInventory  inven     = this._inventoryCache.GetAgentsInventory(simClient.AgentID);

            if (inven != null)
            {
                if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
                {
                    AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
                    if (asset != null)
                    {
                        PrimData  primd = new PrimData(asset.Data);
                        Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
                        nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true);
                        this.Entities.Add(nPrim.uuid, nPrim);
                        this._primCount++;
                        this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 5
0
        public void CreateFromStorage(PrimData store, LLVector3 posi, uint localID, bool newprim)
        {
            //need to clean this up as it shares a lot of code with CreateFromPacket()
            ObjectUpdatePacket objupdate = new ObjectUpdatePacket();

            objupdate.RegionData.RegionHandle = m_regionHandle;
            objupdate.RegionData.TimeDilation = 64096;
            objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];

            this.primData                             = store;
            objupdate.ObjectData[0]                   = new ObjectUpdatePacket.ObjectDataBlock();
            objupdate.ObjectData[0].PSBlock           = new byte[0];
            objupdate.ObjectData[0].ExtraParams       = new byte[1];
            objupdate.ObjectData[0].MediaURL          = new byte[0];
            objupdate.ObjectData[0].NameValue         = new byte[0];
            objupdate.ObjectData[0].Text              = new byte[0];
            objupdate.ObjectData[0].TextColor         = new byte[4];
            objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
            objupdate.ObjectData[0].JointPivot        = new LLVector3(0, 0, 0);
            objupdate.ObjectData[0].Material          = 3;
            objupdate.ObjectData[0].UpdateFlags       = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
            objupdate.ObjectData[0].TextureAnim       = new byte[0];
            objupdate.ObjectData[0].Sound             = LLUUID.Zero;

            if (store.Texture == null)
            {
                LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
                objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
            }
            else
            {
                objupdate.ObjectData[0].TextureEntry = store.Texture;
            }

            objupdate.ObjectData[0].State         = 0;
            objupdate.ObjectData[0].Data          = new byte[0];
            objupdate.ObjectData[0].OwnerID       = this.primData.OwnerID;
            objupdate.ObjectData[0].PCode         = this.primData.PCode;
            objupdate.ObjectData[0].PathBegin     = this.primData.PathBegin;
            objupdate.ObjectData[0].PathEnd       = this.primData.PathEnd;
            objupdate.ObjectData[0].PathScaleX    = this.primData.PathScaleX;
            objupdate.ObjectData[0].PathScaleY    = this.primData.PathScaleY;
            objupdate.ObjectData[0].PathShearX    = this.primData.PathShearX;
            objupdate.ObjectData[0].PathShearY    = this.primData.PathShearY;
            objupdate.ObjectData[0].PathSkew      = this.primData.PathSkew;
            objupdate.ObjectData[0].ProfileBegin  = this.primData.ProfileBegin;
            objupdate.ObjectData[0].ProfileEnd    = this.primData.ProfileEnd;
            objupdate.ObjectData[0].Scale         = this.primData.Scale;
            objupdate.ObjectData[0].PathCurve     = this.primData.PathCurve;
            objupdate.ObjectData[0].ProfileCurve  = this.primData.ProfileCurve;
            objupdate.ObjectData[0].ParentID      = 0;
            objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
            //finish off copying rest of shape data
            objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
            objupdate.ObjectData[0].PathRevolutions  = this.primData.PathRevolutions;
            objupdate.ObjectData[0].PathTaperX       = this.primData.PathTaperX;
            objupdate.ObjectData[0].PathTaperY       = this.primData.PathTaperY;
            objupdate.ObjectData[0].PathTwist        = this.primData.PathTwist;
            objupdate.ObjectData[0].PathTwistBegin   = this.primData.PathTwistBegin;

            objupdate.ObjectData[0].ID     = localID; // (uint)store.LocalID;
            objupdate.ObjectData[0].FullID = store.FullID;

            objupdate.ObjectData[0].ObjectData     = new byte[60];
            objupdate.ObjectData[0].ObjectData[46] = 128;
            objupdate.ObjectData[0].ObjectData[47] = 63;
            LLVector3 pos1 = posi; // store.Position;

            //update position
            byte[] pb = pos1.GetBytes();
            Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);

            this.uuid      = objupdate.ObjectData[0].FullID;
            this.localid   = objupdate.ObjectData[0].ID;
            this.Pos       = pos1;
            this.OurPacket = objupdate;
            if (newprim)
            {
                this.newPrimFlag = true;
            }
        }
Ejemplo n.º 6
0
 public void CreateFromStorage(PrimData store)
 {
     this.CreateFromStorage(store, store.Position, store.LocalID, false);
 }
Ejemplo n.º 7
0
        public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
        {
            ObjectUpdatePacket objupdate = new ObjectUpdatePacket();

            objupdate.RegionData.RegionHandle = m_regionHandle;
            objupdate.RegionData.TimeDilation = 64096;

            objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
            PrimData PData = new PrimData();

            this.primData = PData;
            this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;

            objupdate.ObjectData[0]                   = new ObjectUpdatePacket.ObjectDataBlock();
            objupdate.ObjectData[0].PSBlock           = new byte[0];
            objupdate.ObjectData[0].ExtraParams       = new byte[1];
            objupdate.ObjectData[0].MediaURL          = new byte[0];
            objupdate.ObjectData[0].NameValue         = new byte[0];
            objupdate.ObjectData[0].Text              = new byte[0];
            objupdate.ObjectData[0].TextColor         = new byte[4];
            objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
            objupdate.ObjectData[0].JointPivot        = new LLVector3(0, 0, 0);
            objupdate.ObjectData[0].Material          = 3;
            objupdate.ObjectData[0].UpdateFlags       = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
            objupdate.ObjectData[0].TextureAnim       = new byte[0];
            objupdate.ObjectData[0].Sound             = LLUUID.Zero;
            LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
            this.primData.Texture         = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
            objupdate.ObjectData[0].State = 0;
            objupdate.ObjectData[0].Data  = new byte[0];
            PData.OwnerID                          = objupdate.ObjectData[0].OwnerID = agentID;
            PData.PCode                            = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
            PData.PathBegin                        = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
            PData.PathEnd                          = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
            PData.PathScaleX                       = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
            PData.PathScaleY                       = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
            PData.PathShearX                       = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
            PData.PathShearY                       = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
            PData.PathSkew                         = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
            PData.ProfileBegin                     = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
            PData.ProfileEnd                       = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
            PData.Scale                            = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
            PData.PathCurve                        = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
            PData.ProfileCurve                     = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
            PData.ParentID                         = objupdate.ObjectData[0].ParentID = 0;
            PData.ProfileHollow                    = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
            PData.PathRadiusOffset                 = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
            PData.PathRevolutions                  = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
            PData.PathTaperX                       = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
            PData.PathTaperY                       = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
            PData.PathTwist                        = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
            PData.PathTwistBegin                   = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
            objupdate.ObjectData[0].ID             = (uint)(localID);
            objupdate.ObjectData[0].FullID         = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000"));
            objupdate.ObjectData[0].ObjectData     = new byte[60];
            objupdate.ObjectData[0].ObjectData[46] = 128;
            objupdate.ObjectData[0].ObjectData[47] = 63;
            LLVector3 pos1 = addPacket.ObjectData.RayEnd;

            //update position
            byte[] pb = pos1.GetBytes();
            Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
            this.newPrimFlag       = true;
            this.primData.FullID   = this.uuid = objupdate.ObjectData[0].FullID;
            this.localid           = objupdate.ObjectData[0].ID;
            this.primData.Position = this.Pos = pos1;
            this.OurPacket         = objupdate;
        }
Ejemplo n.º 8
0
        public static Graph PrimMST(Graph g)
        {
            if (g.Directed)
            {
                Output.WriteLine("Can't run Prim's algorithm on a directed graph");
                return null;
            }

            Graph copy = new Graph();
            Graph mst = new Graph();
            //Create a copy to preserve g's state
            g.CopyTo(copy);

            List<Vertex> vertices = copy.GetVertices();
            foreach (Vertex vert in vertices)
            {
                mst.AddVertex(vert);
            }

            PrimData v = new PrimData();
            v.Predecessor = null;
            v.Seen = true;
            v.V = vertices[0];
            v.D = 0;
            v.InMST = true;
            v.EdgeLength = float.PositiveInfinity;
            vertices[0].Tag = v;

            foreach (Vertex u in vertices)
            {
                if (!v.V.Equals(u))
                {
                    PrimData pd = new PrimData();
                    pd.D = float.PositiveInfinity;
                    pd.V = u;
                    pd.InMST = false;
                    pd.Seen = false;
                    u.Tag = pd;
                }
            }

            Heap<PrimData> q = new Heap<PrimData>(true);
            q.Add(vertices[0].Tag as PrimData);

            while (q.HasNext())
            {
                PrimData pd = q.Next();
                if (pd.Predecessor == null)
                {
                    //mst.AddVertex(pd.V);
                }
                else
                {
                    string label = pd.V.Label;
                    mst.AddEdge(new Edge(pd.Predecessor, pd.V, pd.EdgeLength));
                    pd.V.Label = label;
                    pd.InMST = true;
                }

                foreach (Edge e in pd.V.GetOutEdges())
                {
                    Vertex connectedVertex = e.GetToVertex();
                    PrimData data = connectedVertex.Tag as PrimData;
                    if (!data.Seen)
                    {
                        q.Add(data);
                        data.Predecessor = pd.V;
                        data.EdgeLength = e.Weight;
                        data.Seen = true;
                    }

                    if (data.D > e.Weight && !data.InMST)
                    {
                        data.D = e.Weight;
                        data.Predecessor = pd.V;
                        data.EdgeLength = e.Weight;
                        q.Update(data);
                    }
                }
                /*foreach (Edge e in pd.V.GetInEdges())
                {
                    Vertex connectedVertex = e.GetFromVertex();
                    PrimData data = connectedVertex.Tag as PrimData;
                    if (!data.Seen)
                    {
                        q.Add(data);
                        data.Predecessor = pd.V;
                        data.EdgeLength = e.Weight;
                        data.Seen = true;
                    }

                    if (data.D > e.Weight && !data.InMST)
                    {
                        data.D = e.Weight;
                        data.Predecessor = pd.V;
                        data.EdgeLength = e.Weight;
                        q.Update(data);
                    }
                }*/
            }

            return mst;
        }
Ejemplo n.º 9
0
 public bool Match(PrimData prim)
 {
     return(prim.FullID == _findID);
 }