private void landPatchCallbackCulled(Simulator simulator, int x, int y, int width, float[] data) { SimulatorCull sc; ulong regionhandle = simulator.Handle; lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) { SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); } lock (sc) { SimPatchInfo p = new SimPatchInfo(simulator, x, y, width, data); Vector3d p3d = p.pos; p3d.Z = CameraPosition.Z; if (Vector3d.Distance(CameraPosition, p3d) > LandSightDistance) { sc.PatchesCulled.Add(p); return; } else { if (sc.PatchesSent.Contains(p)) { return; } sc.PatchesSent.Add(p); } } landPatchCallback(simulator, x, y, width, data); }
private void newPrim(SimulatorCull sc, Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation) { lock (sc) { List <Primitive> prims; if (prim.ParentID == 0) { sc.ParentsSent[prim.LocalID] = prim; if (sc.ChildsCulled.TryGetValue(prim.LocalID, out prims)) { sc.ChildsCulled.Remove(prim.LocalID); foreach (var p in prims) { newPrim(sc, simulator, p, regionHandle, timeDilation); } } if (sc.PrimsAwaitingParent.TryGetValue(prim.LocalID, out prims)) { sc.PrimsAwaitingParent.Remove(prim.LocalID); foreach (var p in prims) { newPrim(sc, simulator, p, regionHandle, timeDilation); } } } else { if (!sc.ChildsSent.TryGetValue(prim.ParentID, out prims)) { sc.ChildsSent[prim.ParentID] = prims = new List <Primitive>(); prims.Add(prim); } else { if (!prims.Contains(prim)) { prims.Add(prim); } } } } if (OnObjectAdd != null) { OnObjectAdd(new VSimulator(simulator), prim, regionHandle, timeDilation); } }
private void OnSelfUpdatedObjects(SimulatorCull sc) { List <Primitive> sendprims = new List <Primitive>(); foreach (var p in sc.ParentsCulled.Values) { if (Vector3d.Distance(CameraPosition, GlobalPos(p.RegionHandle, p.Position)) < MAX_DIST) { sendprims.Add(p); } } foreach (var p in sendprims) { sc.ParentsCulled.Remove(p.LocalID); if (sc.ChildsCulled.ContainsKey(p.LocalID)) { sc.PrimsAwaitingParent[p.LocalID] = sc.ChildsCulled[p.LocalID]; } newPrimCulled(sc.simulator, p, sc.simulator.Handle, 0); } sendprims.Clear(); foreach (var p in sc.ParentsSent.Values) { if (Vector3d.Distance(CameraPosition, GlobalPos(p.RegionHandle, p.Position)) > MAX_DIST) { sendprims.Add(p); } } foreach (var p in sendprims) { sc.ParentsSent.Remove(p.LocalID); sc.ParentsCulled[p.LocalID] = p; if (sc.ChildsSent.ContainsKey(p.LocalID)) { sc.ChildsCulled[p.LocalID] = new List <Primitive>(sc.ChildsSent[p.LocalID]); foreach (var pc in sc.ChildsSent[p.LocalID]) { objectKilledCallback(sc.simulator, pc.LocalID); } sc.ChildsSent[p.LocalID].Clear(); } objectKilledCallback(sc.simulator, p.LocalID); } }
private void newPrimCulled(Simulator simulator, Primitive prim, ulong regionhandle, ushort timedilation) { if (prim.RegionHandle == 0) { prim.RegionHandle = regionhandle; } SimulatorCull sc; lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) { SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); } if (!ObjectsToManagedLayerIsRangeBased) { newPrim(sc, simulator, prim, regionhandle, timedilation); return; } lock (sc) { List <Primitive> prims; if (prim.ParentID == 0) { if (sc.PrimsAwaitingParent.TryGetValue(prim.LocalID, out prims)) { if (Sendable(prim)) { //sc.PrimsAwaitingParent.Remove(prim.LocalID); //// send the childs //foreach (Primitive p in prims) //{ // newPrim(sc, simulator, p, regionhandle, timedilation); //} newPrim(sc, simulator, prim, regionhandle, timedilation); return; } else { sc.PrimsAwaitingParent.Remove(prim.LocalID); sc.ParentsCulled[prim.LocalID] = prim; sc.ChildsCulled[prim.LocalID] = prims; return; } } else { if (Sendable(prim)) { newPrim(sc, simulator, prim, regionhandle, timedilation); return; } else { sc.ParentsCulled[prim.LocalID] = prim; return; } } } if (sc.ParentsCulled.ContainsKey(prim.ParentID)) { if (!sc.ChildsCulled.TryGetValue(prim.ParentID, out prims)) { sc.ChildsCulled[prim.ParentID] = prims = new List <Primitive>(); prims.Add(prim); return; } else { if (!prims.Contains(prim)) { prims.Add(prim); return; } } } // child with parent already sent if (sc.ParentsSent.ContainsKey(prim.ParentID)) { //this is an update newPrim(sc, simulator, prim, regionhandle, timedilation); return; } // child with culled parent if (sc.ParentsCulled.ContainsKey(prim.ParentID)) { if (!sc.ChildsCulled.TryGetValue(prim.ParentID, out prims)) { sc.ChildsCulled[prim.ParentID] = prims = new List <Primitive>(); prims.Add(prim); } else { if (!prims.Contains(prim)) { prims.Add(prim); } } return; } if (sc.ChildsSent.ContainsKey(prim.ParentID)) { //this is an update newPrim(sc, simulator, prim, regionhandle, timedilation); return; } if (sc.ParentsSent.ContainsKey(prim.ParentID)) { //this is an update newPrim(sc, simulator, prim, regionhandle, timedilation); return; } if (!sc.PrimsAwaitingParent.TryGetValue(prim.ParentID, out prims)) { sc.PrimsAwaitingParent[prim.ParentID] = prims = new List <Primitive>(); prims.Add(prim); return; } else { if (!prims.Contains(prim)) { prims.Add(prim); return; } return; } } }
private void objectKilledCallbackCulled(Simulator simulator, uint objectid) { if (!ObjectsToManagedLayerIsRangeBased) { objectKilledCallback(simulator, objectid); return; } SimulatorCull sc; ulong regionhandle = simulator.Handle; lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) { SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); } lock (sc) { List <Primitive> childs; if (sc.ChildsCulled.TryGetValue(objectid, out childs)) { childs.Clear(); sc.ChildsCulled.Remove(objectid); } if (sc.ChildsSent.TryGetValue(objectid, out childs)) { childs.Clear(); sc.ChildsSent.Remove(objectid); } if (sc.ParentsCulled.ContainsKey(objectid)) { sc.ParentsCulled.Remove(objectid); return; } if (sc.ParentsSent.ContainsKey(objectid)) { sc.ParentsSent.Remove(objectid); objectKilledCallback(simulator, objectid); return; } // this is a child Primitive prim = null; foreach (List <Primitive> ch in sc.PrimsAwaitingParent.Values) { foreach (var p in ch) { if (p.LocalID == objectid) { prim = p; break; } } if (prim == null) { continue; } ch.Remove(prim); break; } //if (prim != null) return; foreach (List <Primitive> ch in sc.ChildsCulled.Values) { foreach (var p in ch) { if (p.LocalID == objectid) { prim = p; break; } } if (prim == null) { continue; } ch.Remove(prim); return; } foreach (List <Primitive> ch in sc.ChildsSent.Values) { foreach (var p in ch) { if (p.LocalID == objectid) { prim = p; break; } } if (prim == null) { continue; } ch.Remove(prim); break; } objectKilledCallback(simulator, objectid); } }
private void objectKilledCallbackCulled(Simulator simulator, uint objectid) { if (!ObjectsToManagedLayerIsRangeBased) { objectKilledCallback(simulator, objectid); return; } SimulatorCull sc; ulong regionhandle = simulator.Handle; lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) { SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); } lock (sc) { List<Primitive> childs; if (sc.ChildsCulled.TryGetValue(objectid, out childs)) { childs.Clear(); sc.ChildsCulled.Remove(objectid); } if (sc.ChildsSent.TryGetValue(objectid, out childs)) { childs.Clear(); sc.ChildsSent.Remove(objectid); } if (sc.ParentsCulled.ContainsKey(objectid)) { sc.ParentsCulled.Remove(objectid); return; } if (sc.ParentsSent.ContainsKey(objectid)) { sc.ParentsSent.Remove(objectid); objectKilledCallback(simulator, objectid); return; } // this is a child Primitive prim = null; foreach (List<Primitive> ch in sc.PrimsAwaitingParent.Values) { foreach (var p in ch) { if (p.LocalID == objectid) { prim = p; break; } } if (prim == null) continue; ch.Remove(prim); break; } //if (prim != null) return; foreach (List<Primitive> ch in sc.ChildsCulled.Values) { foreach (var p in ch) { if (p.LocalID == objectid) { prim = p; break; } } if (prim == null) continue; ch.Remove(prim); return; } foreach (List<Primitive> ch in sc.ChildsSent.Values) { foreach (var p in ch) { if (p.LocalID == objectid) { prim = p; break; } } if (prim == null) continue; ch.Remove(prim); break; } objectKilledCallback(simulator, objectid); } }
private void newPrimCulled(Simulator simulator, Primitive prim, ulong regionhandle, ushort timedilation) { if (prim.RegionHandle == 0) { prim.RegionHandle = regionhandle; } SimulatorCull sc; lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) { SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); } if (!ObjectsToManagedLayerIsRangeBased) { newPrim(sc, simulator, prim, regionhandle, timedilation); return; } lock (sc) { List<Primitive> prims; if (prim.ParentID == 0) { if (sc.PrimsAwaitingParent.TryGetValue(prim.LocalID, out prims)) { if (Sendable(prim)) { //sc.PrimsAwaitingParent.Remove(prim.LocalID); //// send the childs //foreach (Primitive p in prims) //{ // newPrim(sc, simulator, p, regionhandle, timedilation); //} newPrim(sc, simulator, prim, regionhandle, timedilation); return; } else { sc.PrimsAwaitingParent.Remove(prim.LocalID); sc.ParentsCulled[prim.LocalID] = prim; sc.ChildsCulled[prim.LocalID] = prims; return; } } else { if (Sendable(prim)) { newPrim(sc, simulator, prim, regionhandle, timedilation); return; } else { sc.ParentsCulled[prim.LocalID] = prim; return; } } } if (sc.ParentsCulled.ContainsKey(prim.ParentID)) { if (!sc.ChildsCulled.TryGetValue(prim.ParentID, out prims)) { sc.ChildsCulled[prim.ParentID] = prims = new List<Primitive>(); prims.Add(prim); return; } else { if (!prims.Contains(prim)) { prims.Add(prim); return; } } } // child with parent already sent if (sc.ParentsSent.ContainsKey(prim.ParentID)) { //this is an update newPrim(sc, simulator, prim, regionhandle, timedilation); return; } // child with culled parent if (sc.ParentsCulled.ContainsKey(prim.ParentID)) { if (!sc.ChildsCulled.TryGetValue(prim.ParentID, out prims)) { sc.ChildsCulled[prim.ParentID] = prims = new List<Primitive>(); prims.Add(prim); } else { if (!prims.Contains(prim)) { prims.Add(prim); } } return; } if (sc.ChildsSent.ContainsKey(prim.ParentID)) { //this is an update newPrim(sc, simulator, prim, regionhandle, timedilation); return; } if (sc.ParentsSent.ContainsKey(prim.ParentID)) { //this is an update newPrim(sc, simulator, prim, regionhandle, timedilation); return; } if (!sc.PrimsAwaitingParent.TryGetValue(prim.ParentID, out prims)) { sc.PrimsAwaitingParent[prim.ParentID] = prims = new List<Primitive>(); prims.Add(prim); return; } else { if (!prims.Contains(prim)) { prims.Add(prim); return; } return; } } }
private void newPrim(SimulatorCull sc, Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation) { lock (sc) { List<Primitive> prims; if (prim.ParentID == 0) { sc.ParentsSent[prim.LocalID] = prim; if (sc.ChildsCulled.TryGetValue(prim.LocalID, out prims)) { sc.ChildsCulled.Remove(prim.LocalID); foreach (var p in prims) { newPrim(sc, simulator, p, regionHandle, timeDilation); } } if (sc.PrimsAwaitingParent.TryGetValue(prim.LocalID, out prims)) { sc.PrimsAwaitingParent.Remove(prim.LocalID); foreach (var p in prims) { newPrim(sc, simulator, p, regionHandle, timeDilation); } } } else { if (!sc.ChildsSent.TryGetValue(prim.ParentID, out prims)) { sc.ChildsSent[prim.ParentID] = prims = new List<Primitive>(); prims.Add(prim); } else { if (!prims.Contains(prim)) { prims.Add(prim); } } } } if (OnObjectAdd != null) { OnObjectAdd(new VSimulator(simulator), prim, regionHandle, timeDilation); } }
private void landPatchCallbackCulled(Simulator simulator, int x, int y, int width, float[] data) { SimulatorCull sc; ulong regionhandle = simulator.Handle; lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) { SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); } lock (sc) { SimPatchInfo p = new SimPatchInfo(simulator, x, y, width, data); Vector3d p3d = p.pos; p3d.Z = CameraPosition.Z; if (Vector3d.Distance(CameraPosition, p3d) > LandSightDistance) { sc.PatchesCulled.Add(p); return; } else { if (sc.PatchesSent.Contains(p)) return; sc.PatchesSent.Add(p); } } landPatchCallback(simulator, x, y, width, data); }
private void OnSelfUpdatedObjects(SimulatorCull sc) { List<Primitive> sendprims = new List<Primitive>(); foreach (var p in sc.ParentsCulled.Values) { if (Vector3d.Distance(CameraPosition, GlobalPos(p.RegionHandle, p.Position)) < MAX_DIST) { sendprims.Add(p); } } foreach (var p in sendprims) { sc.ParentsCulled.Remove(p.LocalID); if (sc.ChildsCulled.ContainsKey(p.LocalID)) { sc.PrimsAwaitingParent[p.LocalID] = sc.ChildsCulled[p.LocalID]; } newPrimCulled(sc.simulator, p, sc.simulator.Handle, 0); } sendprims.Clear(); foreach (var p in sc.ParentsSent.Values) { if (Vector3d.Distance(CameraPosition, GlobalPos(p.RegionHandle, p.Position)) > MAX_DIST) { sendprims.Add(p); } } foreach (var p in sendprims) { sc.ParentsSent.Remove(p.LocalID); sc.ParentsCulled[p.LocalID] = p; if (sc.ChildsSent.ContainsKey(p.LocalID)) { sc.ChildsCulled[p.LocalID] = new List<Primitive>(sc.ChildsSent[p.LocalID]); foreach (var pc in sc.ChildsSent[p.LocalID]) { objectKilledCallback(sc.simulator, pc.LocalID); } sc.ChildsSent[p.LocalID].Clear(); } objectKilledCallback(sc.simulator, p.LocalID); } }