public bool TryGetSceneAt(Vector3d position, bool onlyEnabled, out SceneInfo sceneInfo) { IScene[] scenes = null; if (m_sceneFactory != null) { scenes = m_sceneFactory.GetScenes(); } if (scenes != null) { for (int i = 0; i < scenes.Length; i++) { IScene scene = scenes[i]; Vector3d minPosition = scene.MinPosition; Vector3d maxPosition = scene.MaxPosition; // Point-AABB test if (minPosition.X <= position.X && position.X <= maxPosition.X && minPosition.Y <= position.Y && position.Y <= maxPosition.Y && minPosition.Z <= position.Z && position.Z <= maxPosition.Z) { sceneInfo = SceneInfo.FromScene(scene); return(true); } } } sceneInfo = null; return(false); }
public bool TryGetRegionRange(Vector3d minPosition, Vector3d maxPosition, out IList <SceneInfo> scenes) { scenes = new List <SceneInfo>(); IScene[] sceneArray = null; if (m_sceneFactory != null) { sceneArray = m_sceneFactory.GetScenes(); } for (int i = 0; i < sceneArray.Length; i++) { IScene scene = sceneArray[i]; Vector3d sceneMin = scene.MinPosition; Vector3d sceneMax = scene.MaxPosition; // AABB overlap test if (sceneMin.X <= maxPosition.X && sceneMin.Y <= maxPosition.Y && sceneMin.Z <= maxPosition.Z && sceneMax.X >= minPosition.X && sceneMax.Y >= minPosition.Y && sceneMax.Z >= minPosition.Z) { scenes.Add(SceneInfo.FromScene(scene)); } } return(true); }
public bool TryGetScene(UUID sceneID, out SceneInfo sceneInfo) { IScene scene; if (m_sceneFactory != null && m_sceneFactory.TryGetScene(sceneID, out scene)) { sceneInfo = SceneInfo.FromScene(scene); return(true); } sceneInfo = null; return(false); }
private void CreateMapTile(IScene scene) { if (m_renderer != null && m_gridClient != null) { Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, 256, 256, 256f, 256f); Image image = m_renderer.Render(scene, viewport); if (image != null) { m_gridClient.AddOrUpdateMapTile(SceneInfo.FromScene(scene), image); } else { m_log.Warn("Failed to render map tile for " + scene.Name); } } }
private void SceneStartHandler(IScene scene) { if (scene.ID == m_scene.ID) { #region region/online // Fetch nearby regions and notify them we're online if (m_gridClient != null) { IList <SceneInfo> scenes; if (m_gridClient.TryGetRegionRange(scene.MinPosition - NEIGHBOR_RADIUS, scene.MaxPosition + NEIGHBOR_RADIUS, out scenes)) { for (int i = 0; i < scenes.Count; i++) { SceneInfo curScene = scenes[i]; // Skip our own scene if (curScene.ID != scene.ID) { SendRegionOnline(curScene); } } } else { m_log.Warn("Failed to fetch neighbor regions for " + scene.Name); } } else { m_log.Warn("No IGridClient found, skipping neighbor online notifications"); } #endregion region/online } else { // Another local scene came online, track it m_scene.AddNeighbor(SceneInfo.FromScene(scene)); } }
public bool TryGetSceneNear(Vector3d position, bool onlyEnabled, out SceneInfo sceneInfo) { IScene[] scenes = null; if (m_sceneFactory != null) { scenes = m_sceneFactory.GetScenes(); } IScene closestScene = null; double minDist = Double.MaxValue; if (scenes != null) { for (int i = 0; i < scenes.Length; i++) { IScene scene = scenes[i]; // Get the midpoint of this scene Vector3d midpoint = (scene.MaxPosition + scene.MinPosition) * 0.5d; // Compare this distance against the current minimum distance (squared, to avoid an unncessary sqrt) double distance = Vector3d.DistanceSquared(position, midpoint); if (distance < minDist) { minDist = distance; closestScene = scene; } } } if (closestScene != null) { sceneInfo = SceneInfo.FromScene(closestScene); return(true); } sceneInfo = null; return(false); }
public SceneInfo[] SearchScenes(string query, int maxNumber, bool onlyEnabled) { IScene[] scenes = null; if (m_sceneFactory != null) { scenes = m_sceneFactory.GetScenes(); } SortedList <int, SceneInfo> foundScenes = new SortedList <int, SceneInfo>(); if (scenes != null) { for (int i = 0; i < scenes.Length; i++) { IScene scene = scenes[i]; if (scene.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) { foundScenes.Add(scene.Name.Length, SceneInfo.FromScene(scene)); if (foundScenes.Count == maxNumber) { break; } } } } // Copy the (sorted) found scenes to an array SceneInfo[] sceneInfos = new SceneInfo[foundScenes.Count]; for (int i = 0; i < foundScenes.Count; i++) { sceneInfos[i] = foundScenes[i]; } return(sceneInfos); }