public object GetClusterForPosition(Vector3D pos) { var bs = new BoundingSphereD(pos, 1); m_clusterTree.OverlapAllBoundingSphere(ref bs, m_returnedClusters); return(m_returnedClusters.Count > 0 ? m_returnedClusters.Single().UserData : null); }
public static void GetAllEntitiesInSphere(ref BoundingSphereD sphere, List <MyEntity> result) { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGamePruningStructure::GetAllEntitiesInSphere"); m_topMostEntitiesTree.OverlapAllBoundingSphere <MyEntity>(ref sphere, result, false); int topmostCount = result.Count; for (int i = 0; i < topmostCount; i++) { if (result[i].Hierarchy != null) { result[i].Hierarchy.QuerySphere(ref sphere, result); } } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
protected void OverlapAllBoundingSphere(ref BoundingSphereD sphere, List <MyObjectSeed> list) { m_cellsTree.OverlapAllBoundingSphere(ref sphere, m_tempProceduralCellsList); foreach (var cell in m_tempProceduralCellsList) { cell.OverlapAllBoundingSphere(ref sphere, list); } m_tempProceduralCellsList.Clear(); }
protected void GetAllObjectsInSphere(ref BoundingSphereD sphere, List <MyObjectSeed> outList) { List <MyProceduralCell> cells = new List <MyProceduralCell>(); m_cellsTree.OverlapAllBoundingSphere(ref sphere, cells); foreach (var cell in cells) { cell.OverlapAllBoundingSphere(ref sphere, outList); } cells.Clear(); }
/// <summary> /// Gets all objects that are inside the given Bounding sphere and puts them into the /// outObjects list. /// </summary> /// <param name="sphere"></param> /// <param name="outObjects"></param> public void GetObjectsInSphere(BoundingSphereD sphere, List <MyObjectSeed> outObjects) { GenerateObjectsData(ref sphere); List <MyProceduralCell> cells = new List <MyProceduralCell>(); m_cellsTree.OverlapAllBoundingSphere(ref sphere, cells); foreach (var cell in cells) { cell.OverlapAllBoundingSphere(ref sphere, outObjects); } cells.Clear(); }
public static void GetAllEntitiesInSphere(ref BoundingSphereD sphere, List <MyEntity> result, MyEntityQueryType qtype = MyEntityQueryType.Both) { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGamePruningStructure::GetAllEntitiesInSphere"); if (qtype.HasDynamic()) { m_dynamicObjectsTree.OverlapAllBoundingSphere <MyEntity>(ref sphere, result, false); } if (qtype.HasStatic()) { m_staticObjectsTree.OverlapAllBoundingSphere <MyEntity>(ref sphere, result, false); } int topmostCount = result.Count; for (int i = 0; i < topmostCount; i++) { if (result[i].Hierarchy != null) { result[i].Hierarchy.QuerySphere(ref sphere, result); } } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
public static void GetAllBroadcastersInSphere(BoundingSphereD sphere, List <MyDataBroadcaster> result) { m_aabbTree.OverlapAllBoundingSphere <MyDataBroadcaster>(ref sphere, result, false); for (int i = result.Count - 1; i >= 0; i--) { var x = result[i]; var dst = (sphere.Radius + ((MyRadioBroadcaster)x).BroadcastRadius); dst *= dst; if (Vector3D.DistanceSquared(sphere.Center, x.BroadcastPosition) > dst) { result.RemoveAtFast(i); } } }
public int RevealGridsInSphere(BoundingSphereD sphere) { var revealed = 0; _concealedAabbTree.OverlapAllBoundingSphere(ref sphere, _intersectGroups); Log.Trace($"{_intersectGroups.Count} groups"); foreach (var group in _intersectGroups) { revealed += RevealGroup(group); } _intersectGroups.Clear(); return(revealed); }
public static void GetAllAreasInSphere(BoundingSphereD sphere, List <MyPlaceArea> result) { m_aabbTree.OverlapAllBoundingSphere <MyPlaceArea>(ref sphere, result, false); }
public static void GetAllVoxelMapsInSphere(ref BoundingSphereD sphere, List <MyVoxelBase> result) { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGamePruningStructure::GetAllVoxelMapsInSphere"); m_voxelMapsTree.OverlapAllBoundingSphere <MyVoxelBase>(ref sphere, result, false); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
public override void UpdateBeforeSimulation() { { m_trackedEntities.ApplyChanges(); foreach (var module in m_modulesToAdd) { m_modules.Add(module); } foreach (var module in m_modules) { var needsFullUpdate = m_modulesToAdd.Remove(module); if (!module.RunOnClients && !Utilities.IsDecisionMaker) { return; } m_stopwatch.Restart(); foreach (var entity in m_trackedEntities.Values) { if (!entity.ShouldGenerate()) { continue; } foreach (var result in module.Generate(entity.CurrentView, needsFullUpdate ? null : (BoundingSphereD?)entity.PreviousView)) { AddToTree(result); } } var elapsed = m_stopwatch.Elapsed; if (elapsed > TolerableLag) { Log(MyLogSeverity.Warning, "Module {0} took {1} to generate", module.GetType().Name, elapsed); } } foreach (var entity in m_trackedEntities.Values) { if (entity.ShouldGenerate()) { m_dirtyVolumes.Enqueue(entity.PreviousView); entity.UpdatePrevious(); } } } if (m_dirtyVolumes.Count == 0) { return; } var dirtyObjectList = m_objectListPool.Get(); try { // Query tree for objects in volume. dirtyObjectList.Clear(); while (m_dirtyVolumes.Count > 0) { var volume = m_dirtyVolumes.Dequeue(); m_tree.OverlapAllBoundingSphere(ref volume, dirtyObjectList, false); } // Remove those not included by another entity foreach (var t in dirtyObjectList) { bool any = false; foreach (TrackedEntity entity in m_trackedEntities.Values) { if (t.m_boundingBox.Intersects(entity.CurrentView)) { any = true; break; } } if (!any) { t.RaiseRemoved(); } } } finally { m_objectListPool.Return(dirtyObjectList); } }
public void OverlapAllBoundingSphere(ref BoundingSphereD sphere, List <MyObjectSeed> list, bool clear = false) { m_tree.OverlapAllBoundingSphere(ref sphere, list, clear); }
public void GetAllShieldsInSphere(BoundingSphereD sphere, List <DefenseShields> result) { _aabbTree.OverlapAllBoundingSphere(ref sphere, result, false); }
private void Hierarchy_QuerySphere(BoundingSphereD query, List <MyEntity> results) { m_sectors.OverlapAllBoundingSphere <MyEntity>(ref query, results, clear: false); }
public static void GetAllTargetsInSphere <T>(ref BoundingSphereD sphere, List <T> result) { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGamePruningStructure::GetAllTargetsInSphere"); m_targetsTree.OverlapAllBoundingSphere <T>(ref sphere, result, false); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }
public void GetAllEntitiesInSphere <T>(ref BoundingSphereD sphere, List <T> result) { MathTree.OverlapAllBoundingSphere <T>(ref sphere, result, false); }
public static void GetAllBroadcastersInSphere(BoundingSphereD sphere, List <MyDataBroadcaster> result) { m_aabbTree.OverlapAllBoundingSphere <MyDataBroadcaster>(ref sphere, result, false); result.RemoveAll((x) => Vector3D.Distance(sphere.Center, x.BroadcastPosition) > sphere.Radius + (x as MyRadioBroadcaster).BroadcastRadius); }