private void DistributeCoarseLocationUpdates(List<Vector3> locations, List<UUID> uuids, RegionConnections connectiondata, ScenePresence rootPresence) { RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); //List<IClientAPI> clients = new List<IClientAPI>(); Dictionary<Vector2, RegionCoarseLocationStruct> updates = new Dictionary<Vector2, RegionCoarseLocationStruct>(); // Root Region entry RegionCoarseLocationStruct rootupdatedata = new RegionCoarseLocationStruct(); rootupdatedata.Locations = new List<Vector3>(); rootupdatedata.Uuids = new List<UUID>(); rootupdatedata.Offset = Vector2.Zero; rootupdatedata.UserAPI = rootPresence.ControllingClient; if (rootupdatedata.UserAPI != null) updates.Add(Vector2.Zero, rootupdatedata); //Each Region needs an entry or we will end up with dead minimap dots foreach (RegionData regiondata in rdata) { Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); updatedata.Locations = new List<Vector3>(); updatedata.Uuids = new List<UUID>(); updatedata.Offset = offset; if (offset == Vector2.Zero) updatedata.UserAPI = rootPresence.ControllingClient; else updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); if (updatedata.UserAPI != null) updates.Add(offset, updatedata); } // go over the locations and assign them to an IClientAPI for (int i = 0; i < locations.Count; i++) //{locations[i]/(int) Constants.RegionSize; { Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize, (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z); Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize, pPosition.Y*(int) Constants.RegionSize); if (!updates.ContainsKey(offset)) { // This shouldn't happen RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); updatedata.Locations = new List<Vector3>(); updatedata.Uuids = new List<UUID>(); updatedata.Offset = offset; if (offset == Vector2.Zero) updatedata.UserAPI = rootPresence.ControllingClient; else updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); updates.Add(offset,updatedata); } updates[offset].Locations.Add(locations[i]); updates[offset].Uuids.Add(uuids[i]); } // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is foreach (Vector2 offset in updates.Keys) { if (updates[offset].UserAPI != null) { updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations); } } }
private void DistributeCoarseLocationUpdates(List <Vector3> locations, List <UUID> uuids, RegionConnections connectiondata, ScenePresence rootPresence) { RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); //List<IClientAPI> clients = new List<IClientAPI>(); Dictionary <Vector2, RegionCoarseLocationStruct> updates = new Dictionary <Vector2, RegionCoarseLocationStruct>(); // Root Region entry RegionCoarseLocationStruct rootupdatedata = new RegionCoarseLocationStruct(); rootupdatedata.Locations = new List <Vector3>(); rootupdatedata.Uuids = new List <UUID>(); rootupdatedata.Offset = Vector2.Zero; rootupdatedata.UserAPI = rootPresence.ControllingClient; if (rootupdatedata.UserAPI != null) { updates.Add(Vector2.Zero, rootupdatedata); } //Each Region needs an entry or we will end up with dead minimap dots foreach (RegionData regiondata in rdata) { Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); updatedata.Locations = new List <Vector3>(); updatedata.Uuids = new List <UUID>(); updatedata.Offset = offset; if (offset == Vector2.Zero) { updatedata.UserAPI = rootPresence.ControllingClient; } else { updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); } if (updatedata.UserAPI != null) { updates.Add(offset, updatedata); } } // go over the locations and assign them to an IClientAPI for (int i = 0; i < locations.Count; i++) //{locations[i]/(int) Constants.RegionSize; { Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize, (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z); Vector2 offset = new Vector2(pPosition.X * (int)Constants.RegionSize, pPosition.Y * (int)Constants.RegionSize); if (!updates.ContainsKey(offset)) { // This shouldn't happen RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); updatedata.Locations = new List <Vector3>(); updatedata.Uuids = new List <UUID>(); updatedata.Offset = offset; if (offset == Vector2.Zero) { updatedata.UserAPI = rootPresence.ControllingClient; } else { updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); } updates.Add(offset, updatedata); } updates[offset].Locations.Add(locations[i]); updates[offset].Uuids.Add(uuids[i]); } // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is foreach (Vector2 offset in updates.Keys) { if (updates[offset].UserAPI != null) { updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids, updates[offset].Locations); } } }