public void SendAllParcelOverlaysTo(IAgent agent) { var c = new byte[SizeX * SizeY / PARCEL_BLOCK_SIZE / PARCEL_BLOCK_SIZE]; m_ParcelLayerRwLock.AcquireReaderLock(() => { int bytePos = 0; UGUI agentID = agent.Owner; for (int y = 0; y < SizeY / PARCEL_BLOCK_SIZE; ++y) { for (int x = 0; x < SizeX / PARCEL_BLOCK_SIZE; ++x) { c[bytePos++] = (byte)GetParcelLayerByte(x, y, agentID); } } }); int sequenceID = 0; int offset; ParcelOverlay m; for (offset = 0; offset < c.Length; offset += 1024, ++sequenceID) { m = new ParcelOverlay { SequenceID = sequenceID, Data = (c.Length - offset >= 1024) ? new byte[1024] : new byte[c.Length - offset] }; Buffer.BlockCopy(c, offset, m.Data, 0, m.Data.Length); agent.SendMessageAlways(m, ID); } }
private void SendParcelUpdates() { lock (m_ParcelOverlayUpdateLock) { m_ParcelLayerRwLock.AcquireReaderLock(() => { int sequenceID = 0; var totalLen = (int)(SizeX / PARCEL_BLOCK_SIZE * SizeY / PARCEL_BLOCK_SIZE); var xwidth = (int)(SizeX / PARCEL_BLOCK_SIZE); for (int offset = 0; offset < totalLen; offset += 1024, ++sequenceID) { if (m_ParcelLayerDirty[offset / 1024]) { foreach (IAgent a in Agents) { var m = new ParcelOverlay { Data = (totalLen - offset >= 1024) ? new byte[1024] : new byte[totalLen - offset], SequenceID = sequenceID }; UGUI agentID = a.Owner; for (int pos = 0; pos < m.Data.Length; ++pos) { m.Data[pos] = (byte)GetParcelLayerByte((offset + pos) % xwidth, (offset + pos) / xwidth, agentID); } a.SendMessageAlways(m, ID); } m_ParcelLayerDirty[offset / 1024] = false; } } }); } }
/// <summary> /// Creates a new region /// </summary> /// <param name="handle"></param> /// <param name="host"></param> /// <param name="gridsPerRegionEdge"></param> /// <param name="gridsPerPatchEdge"></param> /// <param name="regionWidth"> in metres</param> public Region(RegionHandle handle, Host host, UInt32 gridsPerRegionEdge, UInt32 gridsPerPatchEdge, float regionWidth) { Host = host; Handle = handle; TimeDilation = 1.0f; Name = ""; Zoning = ""; IsCurrentPlayerEstateOwner = false; RegionFlags = RegionFlags.Default; RegionProtocols = RegionProtocols.None; SimAccess = SimAccess.Min; BillableFactor = 1.0f; MaxTasks = DEFAULT_MAX_REGION_WIDE_PRIM_COUNT; CentralBakeVersion = 1; CpuClassId = 0; CpuRatio = 0; ColoName = "unknown"; ProductSku = "unknown"; ProductName = "unknown"; ViewerAssetUrl = ""; CacheLoaded = false; CacheDirty = false; ReleaseNotesRequested = false; CapabilitiesReceived = false; SimulatorFeaturesReceived = false; BitsReceived = 0f; PacketsReceived = 0f; Dead = false; // TODO: LastVisitedEntry = null; InvisibilityCheckHistory = 0xffffffff; Paused = false; RegionCacheHitCount = 0; RegionCacheMissCount = 0; Width = regionWidth; OriginGlobal = handle.ToVector3Double(); //TODO: updateRenderMatrix(); Land = new Surface(SurfaceType.Land, null); //TODO: Why not set the region right away? // Create the composition layer for the surface //Composition = new VolumeLayerComposition (Land, gridsPerRegionEdge, regionWidth / gridsPerRegionEdge); //Composition.SetSurface (Land); // Create the surfaces Land.SetRegion(this); Land.Create(gridsPerRegionEdge, gridsPerPatchEdge, OriginGlobal, Width); ParcelOverlay = new ParcelOverlay(this, regionWidth); EventManager.Instance.OnParcelOverlayMessage += OnParcelOverlayChangedMessage; //TODO: CalculateCenterGlobal(); // Create the object lists // TODO: InitStats(); //TODO: create object partitions //MUST MATCH declaration of eObjectPartitions //ObjectPartition.Add (new LLHUDPartition(this)); //PARTITION_HUD //ObjectPartition.Add (new LLTerrainPartition(this)); //PARTITION_TERRAIN //ObjectPartition.Add (new LLVoidWaterPartition(this)); //PARTITION_VOIDWATER //ObjectPartition.Add (new LLWaterPartition(this)); //PARTITION_WATER //ObjectPartition.Add (new LLTreePartition(this)); //PARTITION_TREE //ObjectPartition.Add (new LLParticlePartition(this)); //PARTITION_PARTICLE //ObjectPartition.Add (new LLGrassPartition(this)); //PARTITION_GRASS //ObjectPartition.Add (new LLVolumePartition(this)); //PARTITION_VOLUME //ObjectPartition.Add (new LLBridgePartition(this)); //PARTITION_BRIDGE //ObjectPartition.Add (new LLAvatarPartition(this)); //PARTITION_AVATAR //ObjectPartition.Add (new LLControlAVPartition(this)); //PARTITION_CONTROL_AV //ObjectPartition.Add (new LLHUDParticlePartition(this));//PARTITION_HUD_PARTICLE //ObjectPartition.Add (new LLVOCachePartition(this)); //PARTITION_VO_CACHE //ObjectPartition.Add (null); //PARTITION_NONE //VOCachePartition = getVOCachePartition(); // TODO: setCapabilitiesReceivedCallback(boost::bind(&LLAvatarRenderInfoAccountant::scanNewRegion, _1)); }