Пример #1
0
 public LLEntityPhysical(AssetContextBase acontext, LLRegionContext rcontext,
                         ulong regionHandle, uint localID, OMV.Primitive prim) : base(rcontext, acontext)
 {
     this.Sim          = rcontext.Simulator;
     this.RegionHandle = regionHandle;
     this.LocalID      = localID;
     this.Prim         = prim;
     this.Name         = new EntityNameLL(acontext, m_prim.ID.ToString());
 }
 public LLEntityPhysical(AssetContextBase acontext, LLRegionContext rcontext, 
         ulong regionHandle, uint localID, OMV.Primitive prim)
     : base(rcontext, acontext)
 {
     this.Sim = rcontext.Simulator;
     this.RegionHandle = regionHandle;
     this.LocalID = localID;
     this.Prim = prim;
     this.Name = new EntityNameLL(acontext, m_prim.ID.ToString());
 }
 public LLEntityAvatar(AssetContextBase acontext, LLRegionContext rcontext,
                       ulong regionHandle, OMV.Avatar av) : base(rcontext, acontext)
 {
     // base(acontext, rcontext, regionHandle, av.LocalID, null) { // base for EntityPhysical
     // let people looking at IEntity's get at my avatarness
     RegisterInterface <IEntityAvatar>(this);
     this.Sim          = rcontext.Simulator;
     this.RegionHandle = regionHandle;
     this.LocalID      = av.LocalID;
     this.Avatar       = av;
     this.Name         = AvatarEntityNameFromID(acontext, m_avatar.ID);
     LogManager.Log.Log(LogLevel.DCOMMDETAIL, "LLEntityAvatar: create id={0}, lid={1}",
                        av.ID.ToString(), this.LocalID);
 }
 public LLEntityAvatar(AssetContextBase acontext, LLRegionContext rcontext, 
         ulong regionHandle, OMV.Avatar av)
     : base(rcontext, acontext)
 {
     // base(acontext, rcontext, regionHandle, av.LocalID, null) { // base for EntityPhysical
     // let people looking at IEntity's get at my avatarness
     RegisterInterface<IEntityAvatar>(this);
     this.Sim = rcontext.Simulator;
     this.RegionHandle = regionHandle;
     this.LocalID = av.LocalID;
     this.Avatar = av;
     this.Name = AvatarEntityNameFromID(acontext, m_avatar.ID);
     LogManager.Log.Log(LogLevel.DCOMMDETAIL, "LLEntityAvatar: create id={0}, lid={1}",
                     av.ID.ToString(), this.LocalID);
 }
        /// <summary>
        /// I am being updated.
        /// Make sure the parenting is correct before telling the world about any update.
        /// </summary>
        /// <param name="what"></param>
        public override void Update(UpdateCodes what)
        {
            // Make sure parenting is correct (we're in our parent's collection)
            try {
                if (this.Prim != null)      // if no prim, no parent possible
                {
                    uint parentID = this.Prim.ParentID;
                    if (parentID != 0 && this.ContainingEntity == null)
                    {
                        what |= UpdateCodes.ParentID;
                        IEntity         parentEntity = null;
                        LLRegionContext rcontext     = (LLRegionContext)this.RegionContext;
                        rcontext.TryGetEntityLocalID(parentID, out parentEntity);
                        if (parentEntity != null)
                        {
                            this.ContainingEntity = parentEntity;
                            parentEntity.AddEntityToContainer(this);
                            LogManager.Log.Log(LogLevel.DCOMMDETAIL, "ProcessEntityContainer: adding entity {0} to container {1}",
                                               this.Name, parentEntity.Name);
                        }
                        else
                        {
                            LogManager.Log.Log(LogLevel.DCOMMDETAIL, "Can't assign parent. Entity not found. ent={0}", this.Name);
                        }
                    }
                    if (parentID == 0 && this.ContainingEntity != null)
                    {
                        // the prim has been removed from it's parent
                        what |= UpdateCodes.ParentID;
                        this.DisconnectFromContainer();
                    }
                }
            }
            catch (Exception e) {
                LogManager.Log.Log(LogLevel.DBADERROR, "FAILED ProcessEntityContainer: " + e);
            }

            // tell the world about our updating
            base.Update(what);
        }
        private void UpdateHeightMap(RegionContextBase reg)
        {
            int stride  = TerrainPatchStride;
            int stride2 = stride * TerrainPatchWidth;

            lock (this) {
                float[,] newHM = new float[TerrainPatchWidth, TerrainPatchLength];
                float minHeight = 999999f;
                float maxHeight = 0f;

                if ((reg == null) || !(reg is LLRegionContext))
                {
                    // things are not set up so create a default, flat heightmap
                    LogManager.Log.Log(LogLevel.DWORLDDETAIL,
                                       "LLTerrainInfo: Building default zero terrain");
                    CreateZeroHeight(ref newHM);
                    minHeight = maxHeight = 0f;
                }
                else
                {
                    try {
                        LLRegionContext llreg = (LLRegionContext)reg;
                        OMV.Simulator   sim   = llreg.Simulator;

                        int nullPatchCount = 0;
                        for (int px = 0; px < stride; px++)
                        {
                            for (int py = 0; py < stride; py++)
                            {
                                OMV.TerrainPatch pat = sim.Terrain[px + py * stride];
                                if (pat == null)
                                {
                                    // if no patch, it's all zeros
                                    if (0.0f < minHeight)
                                    {
                                        minHeight = 0.0f;
                                    }
                                    if (0.0f > maxHeight)
                                    {
                                        maxHeight = 0.0f;
                                    }
                                    for (int xx = 0; xx < stride; xx++)
                                    {
                                        for (int yy = 0; yy < stride; yy++)
                                        {
                                            // newHM[(py * stride + yy), (px * stride + xx)] = 0.0f;
                                            newHM[(px * stride + xx), (py * stride + yy)] = 0.0f;
                                        }
                                    }
                                    nullPatchCount++;
                                }
                                else
                                {
                                    for (int xx = 0; xx < stride; xx++)
                                    {
                                        for (int yy = 0; yy < stride; yy++)
                                        {
                                            float height = pat.Data[xx + yy * stride];
                                            // newHM[(py * stride + yy), (px * stride + xx)] = height;
                                            newHM[(px * stride + xx), (py * stride + yy)] = height;
                                            if (height < minHeight)
                                            {
                                                minHeight = height;
                                            }
                                            if (height > maxHeight)
                                            {
                                                maxHeight = height;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        // LogManager.Log.Log(LogLevel.DWORLDDETAIL,
                        //         "LLTerrainInfo: UpdateHeightMap: {0} null patches = {1}", sim.Name, nullPatchCount);
                    }
                    catch {
                        // this usually happens when first starting a region
                        LogManager.Log.Log(LogLevel.DWORLDDETAIL,
                                           "LLTerrainInfo: Exception building terrain. Defaulting to zero.");
                        CreateZeroHeight(ref newHM);
                        minHeight = maxHeight = 0f;
                    }
                }
                m_heightMap       = newHM;
                m_heightMapWidth  = TerrainPatchWidth; // X
                m_heightMapLength = TerrainPatchLength;
                m_minimumHeight   = minHeight;
                m_maximumHeight   = maxHeight;
                LogManager.Log.Log(LogLevel.DWORLDDETAIL,
                                   "LLTerrainInfo: New terrain:"
                                   + " min=" + m_minimumHeight.ToString()
                                   + " max=" + m_maximumHeight.ToString()
                                   );
            }
        }
Пример #7
0
        // ===============================================================
        // given a simulator. Find the region info that we store the stuff in
        // Note that, if we are not connected, we just return null thus showing our unhappiness.
        public virtual LLRegionContext FindRegion(OMV.Simulator sim)
        {
            LLRegionContext ret = null;
            if (IsConnected) {
            lock (m_regionList) {
                if (!m_regionList.TryGetValue(sim.ID, out ret)) {
                    // we are connected but doen't have a regionContext for this simulator. Build one.
                    AssetContextBase assetContext = SelectAssetContextForGrid(sim);
                    LLTerrainInfo llterr = new LLTerrainInfo(null, assetContext);
                    llterr.WaterHeight = sim.WaterHeight;
                    // TODO: copy terrain texture IDs

                    ret = new LLRegionContext(null, assetContext, llterr, sim);
                    // ret.Name = new EntityNameLL(LoggedInGridName + "/Region/" + sim.Name.Trim());
                    ret.Name = new EntityNameLL(LoggedInGridName + "/" + sim.Name.Trim());
                    ret.RegionContext = ret;    // since we don't know ourself before
                    ret.Comm = m_client;
                    ret.TerrainInfo.RegionContext = ret;
                    m_regionList.Add(sim.ID, ret);
                    m_log.Log(LogLevel.DWORLD, "Creating region context for " + ret.Name);
                }
            }
            }
            return ret;
        }
Пример #8
0
 // return 'true' is the parent of this id exists in the world
 private bool ParentExists(LLRegionContext regionContext, uint parentID)
 {
     // if shouldn't be holding anything, fake like the parent is always here
     if (!m_shouldHoldChildren) return true;
     // if we don't need a parent no need to check
     if (parentID == 0) return true; // if no parent say we have the parent
     // see if the parent is known
     IEntity parentEntity = null;
     regionContext.TryGetEntityLocalID(parentID, out parentEntity);
     return (parentEntity != null);
 }