public void Init(Vector3D v, MyDynamicAABBTreeD tree, double maxDistanceSq) { _vec = v; _tree = tree; _maxDistanceSq = maxDistanceSq; Reset(); }
internal void Init(MyFrustumCullQuery query, MyDynamicAABBTreeD renderables) { Debug.Assert(query.List.Count == 0, "List not cleared before use"); Debug.Assert(query.IsInsideList.Count == 0, "IsInsideList not cleared before use"); m_query = query; m_renderables = renderables; }
internal MyLodMeshMerge(MyClipmap parentClipmap, int lod, int lodDivisions, ref MatrixD worldMatrix, ref Vector3D massiveCenter, float massiveRadius, RenderFlags renderFlags) { Debug.Assert(parentClipmap != null, "Parent clipmap cannot be null"); Debug.Assert(lod >= 0, "Lod level must be non-negative"); Debug.Assert(lodDivisions >= 0, "Invalid number of lod divisions"); m_parentClipmap = parentClipmap; m_lod = lod; m_lodDivisions = lodDivisions; if (m_lodDivisions <= 0) return; m_dirtyProxyIndices = new HashSet<int>(); m_cellProxyToAabbProxy = new Dictionary<MyClipmapCellProxy, int>(); m_boundingBoxes = new MyDynamicAABBTreeD(Vector3D.Zero); int cellCount = lodDivisions*lodDivisions*lodDivisions; m_mergeJobs = new MergeJobInfo[cellCount]; m_mergedLodMeshProxies = new MyClipmapCellProxy[cellCount]; m_trackedActors = new HashSet<MyActor>[cellCount]; for (int divideIndex = 0; divideIndex < cellCount; ++divideIndex) { m_mergedLodMeshProxies[divideIndex] = new MyClipmapCellProxy(new MyCellCoord(Lod, GetCellFromDivideIndex(divideIndex)), ref worldMatrix, massiveCenter, massiveRadius, renderFlags, true); m_mergeJobs[divideIndex] = new MergeJobInfo { CurrentWorkId = 0, LodMeshesBeingMerged = new List<LodMeshId>(), NextPossibleMergeStartTime = MyCommon.FrameCounter }; m_trackedActors[divideIndex] = new HashSet<MyActor>(); m_dirtyProxyIndices.Add(divideIndex); } }
static void Init() { m_aabbTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); m_targetsTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); m_sensableTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); m_voxelMapsTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); }
/// <summary> /// Goes through all renderables and adds the ones that are in the given frustums to the lists in frustumCullQuery /// </summary> protected override void DispatchCullQuery(MyCullQuery frustumCullQueries, MyDynamicAABBTreeD renderables) { ProfilerShort.Begin("DispatchFrustumCulling"); for (int frustumQueryIndex = 1; frustumQueryIndex < frustumCullQueries.Size; ++frustumQueryIndex) { var cullWork = MyObjectPoolManager.Allocate<MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[frustumQueryIndex], renderables); m_tmpCullingTasks.Add(Parallel.Start(cullWork)); } if (frustumCullQueries.Size > 0) { var cullWork = MyObjectPoolManager.Allocate<MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[0], renderables); cullWork.DoWork(); } foreach (Task cullingTask in m_tmpCullingTasks) { cullingTask.Wait(); } m_tmpCullingTasks.Clear(); foreach (MyFrustumCullingWork cullWork in m_tmpAllocatedWork) { MyObjectPoolManager.Deallocate(cullWork); } m_tmpAllocatedWork.Clear(); ProfilerShort.End(); }
/// <summary> /// Goes through all renderables and adds the ones that are in the given frustums to the lists in frustumCullQuery /// </summary> protected override void DispatchCullQuery(MyCullQuery frustumCullQueries, MyDynamicAABBTreeD renderables) { ProfilerShort.Begin("DispatchFrustumCulling"); for (int frustumQueryIndex = 1; frustumQueryIndex < frustumCullQueries.Size; ++frustumQueryIndex) { var cullWork = MyObjectPoolManager.Allocate <MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[frustumQueryIndex], renderables); m_tmpCullingTasks.Add(Parallel.Start(cullWork)); } if (frustumCullQueries.Size > 0) { var cullWork = MyObjectPoolManager.Allocate <MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[0], renderables); cullWork.DoWork(); } foreach (Task cullingTask in m_tmpCullingTasks) { cullingTask.Wait(); } m_tmpCullingTasks.Clear(); foreach (MyFrustumCullingWork cullWork in m_tmpAllocatedWork) { MyObjectPoolManager.Deallocate(cullWork); } m_tmpAllocatedWork.Clear(); ProfilerShort.End(); }
internal MyLodMeshMerge(MyClipmap parentClipmap, int lod, int lodDivisions, ref MatrixD worldMatrix, ref Vector3D massiveCenter, float massiveRadius, RenderFlags renderFlags) { Debug.Assert(parentClipmap != null, "Parent clipmap cannot be null"); Debug.Assert(lod >= 0, "Lod level must be non-negative"); Debug.Assert(lodDivisions >= 0, "Invalid number of lod divisions"); m_parentClipmap = parentClipmap; m_lod = lod; m_lodDivisions = lodDivisions; if (!IsUsed()) { return; } m_dirtyProxyIndices = new HashSet <int>(); m_cellProxyToAabbProxy = new Dictionary <MyClipmapCellProxy, int>(); m_boundingBoxes = new MyDynamicAABBTreeD(Vector3D.Zero); int cellCount = lodDivisions * lodDivisions * lodDivisions; m_mergeJobs = new MergeJobInfo[cellCount]; m_mergedLodMeshProxies = new MyClipmapCellProxy[cellCount]; m_trackedActors = new HashSet <MyActor> [cellCount]; for (int divideIndex = 0; divideIndex < cellCount; ++divideIndex) { m_mergedLodMeshProxies[divideIndex] = new MyClipmapCellProxy(new MyCellCoord(Lod, GetCellFromDivideIndex(divideIndex)), ref worldMatrix, massiveCenter, massiveRadius, renderFlags, true); m_mergeJobs[divideIndex] = new MergeJobInfo { CurrentWorkId = 0, LodMeshesBeingMerged = new List <LodMeshId>(), NextPossibleMergeStartTime = MyCommon.FrameCounter }; m_trackedActors[divideIndex] = new HashSet <MyActor>(); m_dirtyProxyIndices.Add(divideIndex); } }
internal MyGeometryRenderer(MyDynamicAABBTreeD renderablesDBVH, MyShadows shadowHandler) { m_renderablesDBVH = renderablesDBVH; m_shadowHandler = shadowHandler; m_cullQuery = new MyCullQuery(); m_visibilityCuller = new MyFrustumCuller(); m_renderingDispatcher = new MyRenderingDispatcher(); }
private void PrepareSectors() { m_children = new MyDynamicAABBTreeD(Vector3D.Zero); Hierarchy.QueryAABBImpl = Hierarchy_QueryAABB; Hierarchy.QueryLineImpl = Hierarchy_QueryLine; Hierarchy.QuerySphereImpl = Hierarchy_QuerySphere; }
public void Dispose() { _tmp.Clear(); _tree = null; if (_cache.Count < 12) { _cache.Enqueue(this); } }
public override void Init(ITorchBase torch) { base.Init(torch); Settings = Persistent <Settings> .Load(Path.Combine(StoragePath, "Concealment.cfg")); Settings.Data.PropertyChanged += Data_PropertyChanged; _concealedAabbTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); RegisterEntityStorage("Concealment", Id); }
internal void PerformCulling(MyCullQuery cullQuery, MyDynamicAABBTreeD renderableBVH) { ProfilerShort.Begin("DispatchCulling"); DispatchCullQuery(cullQuery, renderableBVH); ProfilerShort.BeginNextBlock("ProcessCullResults"); ProcessCullQueryResults(cullQuery); ProfilerShort.End(); }
public static IEnumerator <NearestNodeResult> SortedByDistance(this MyDynamicAABBTreeD tree, Vector3D test, double maxDistanceSq = double.PositiveInfinity) { NearestNodeQuery query; if (!_cache.TryDequeue(out query)) { query = new NearestNodeQuery(_cache); } query.Init(test, tree, maxDistanceSq); return(query); }
public static IEnumerator <KeyValuePair <int, double> > SortedByDistance(this MyDynamicAABBTreeD tree, Vector3D test) { NearestNodeQuery query; if (!_cache.TryDequeue(out query)) { query = new NearestNodeQuery(_cache); } query.Init(test, tree); return(query); }
protected MyCullableRenderObject(uint id, string debugName) : base(id, debugName) { CulledObjects = new MyDynamicAABBTreeD(MyRender.PrunningExtension); EntitiesContained = 0; for (int i = 0; i < Enum.GetValues(typeof(MyOcclusionQueryID)).Length; i++) { m_queries[i] = new MyOcclusionQueryIssue(this); m_queries[i].RenderType = MyOcclusionQueryRenderType.HWDepth; } m_queries[(int)MyOcclusionQueryID.MAIN_RENDER].RenderType = MyOcclusionQueryRenderType.CustomDepth; }
internal static int UpdateBvh(MyDynamicAABBTreeD bvh, LightId lid, bool enabled, int proxy, ref BoundingBoxD aabb) { if (enabled && proxy == -1) { return(bvh.AddProxy(ref aabb, lid, 0)); } else if (enabled && proxy != -1) { bvh.MoveProxy(proxy, ref aabb, Vector3.Zero); return(proxy); } else { bvh.RemoveProxy(proxy); } return(-1); }
public override void Init(ITorchBase torch) { base.Init(torch); try { Settings = Persistent <Settings> .Load(Path.Combine(StoragePath, "Concealment.cfg")); } catch (Exception e) { Log.Warn(e); } if (Settings?.Data == null) { Settings = new Persistent <Settings>(Path.Combine(StoragePath, "Concealment.cfg"), new Settings()); } Settings.Data.PropertyChanged += Data_PropertyChanged; _concealedAabbTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); torch.Managers.GetManager <ITorchSessionManager>()?.AddFactory(CreateManager); }
/// <summary> /// Goes through all renderables and adds the ones that are in the given frustums to the lists in frustumCullQuery /// </summary> protected override void DispatchCullQuery(MyCullQuery frustumCullQueries, MyDynamicAABBTreeD renderables) { ProfilerShort.Begin("DispatchFrustumCulling"); for (int frustumQueryIndex = 1; frustumQueryIndex < frustumCullQueries.Size; ++frustumQueryIndex) { var cullWork = MyObjectPoolManager.Allocate <MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[frustumQueryIndex], renderables); m_tmpCullingTasks.Add(Parallel.Start(cullWork)); } if (frustumCullQueries.Size > 0) { var cullWork = MyObjectPoolManager.Allocate <MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[0], renderables); cullWork.DoWork(); } foreach (Task cullingTask in m_tmpCullingTasks) { cullingTask.Wait(); } m_tmpCullingTasks.Clear(); int i = 0; foreach (MyFrustumCullingWork cullWork in m_tmpAllocatedWork) { ProfilerShort.Begin(frustumCullQueries.FrustumCullQueries[i].Type.ToString()); ProfilerShort.End(frustumCullQueries.FrustumCullQueries[i].List.Count + frustumCullQueries.FrustumCullQueries[i].List2.Count, new VRage.Library.Utils.MyTimeSpan(cullWork.Elapsed)); MyObjectPoolManager.Deallocate(cullWork); i++; } m_tmpAllocatedWork.Clear(); ProfilerShort.End(); }
private void PrepareSectors() { ComputeSectorParameters(); m_planetEnvironmentSectors = new Dictionary <MyPlanetSectorId, MyPlanetEnvironmentSector>(); m_sectorsToRemove = new List <MyPlanetSectorId>((int)(Math.Ceiling(SECTOR_LOD1_EXTENT) * Math.Ceiling(SECTOR_LOD1_EXTENT) * 2)); SECTOR_LOD0_EXTENT = BASE_SECTOR_LOD0_EXTENT;// *m_numSectors / 7f; SECTOR_LOD1_EXTENT = MathHelper.Lerp(BASE_SECTOR_LOD1_EXTENT, MAX_SECTOR_LOD1_EXTENT, (Provider.Radius - 9500) / (60000 - 9500)); ComputeSectorRanges(); m_sectors = new MyDynamicAABBTreeD(Vector3D.Zero); Hierarchy.QueryAABBImpl = Hierarchy_QueryAABB; Hierarchy.QueryLineImpl = Hierarchy_QueryLine; Hierarchy.QuerySphereImpl = Hierarchy_QuerySphere; InitCounters(); }
/// <summary> /// Goes through all renderables and adds the ones that are in the given frustums to the lists in frustumCullQuery /// </summary> protected override void DispatchCullQuery(MyCullQuery frustumCullQueries, MyDynamicAABBTreeD renderables) { ProfilerShort.Begin("DispatchFrustumCulling"); for (int frustumQueryIndex = 1; frustumQueryIndex < frustumCullQueries.Size; ++frustumQueryIndex) { var cullWork = MyObjectPoolManager.Allocate<MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[frustumQueryIndex], renderables); m_tmpCullingTasks.Add(Parallel.Start(cullWork)); } if (frustumCullQueries.Size > 0) { var cullWork = MyObjectPoolManager.Allocate<MyFrustumCullingWork>(); m_tmpAllocatedWork.Add(cullWork); cullWork.Init(frustumCullQueries.FrustumCullQueries[0], renderables); cullWork.DoWork(); } foreach (Task cullingTask in m_tmpCullingTasks) { cullingTask.Wait(); } m_tmpCullingTasks.Clear(); int i = 0; foreach (MyFrustumCullingWork cullWork in m_tmpAllocatedWork) { ProfilerShort.Begin(frustumCullQueries.FrustumCullQueries[i].Type.ToString()); ProfilerShort.End(frustumCullQueries.FrustumCullQueries[i].List.Count + frustumCullQueries.FrustumCullQueries[i].List2.Count, new VRage.Library.Utils.MyTimeSpan(cullWork.Elapsed)); MyObjectPoolManager.Deallocate(cullWork); i++; } m_tmpAllocatedWork.Clear(); ProfilerShort.End(); }
static void Init() { m_topMostEntitiesTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); m_voxelMapsTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); }
protected abstract void DispatchCullQuery(MyCullQuery frustumCullQueries, MyDynamicAABBTreeD renderables);
static void Init() { m_dynamicObjectsTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); m_voxelMapsTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); m_staticObjectsTree = new MyDynamicAABBTreeD(Vector3D.Zero); }
internal void Cleanup() { m_query = null; m_renderables = null; }
public override void LoadData() { base.LoadData(); m_updateCounter = 0; m_envItems = new Dictionary<long, MyEnvironmentItems>(10); m_forestAreas = new List<Area>(100); m_highLevelBoxes = new List<BoundingBoxD>(); m_tmpItemInfos = new List<ItemInfo>(500); m_tmpAreas = new List<Area>(); m_tmpAreas2 = new List<Area>(); m_checkedSectors = new HashSet<Vector3I>(); m_checkQueue = new Queue<long>(); m_initialForestLocations = new Queue<Vector3D>(); m_tmpSectors = new List<Vector3I>(); m_aabbTree = new MyDynamicAABBTreeD(Vector3D.Zero); // MW:TODO growing items on allowed materials m_allowedMaterials = new HashSet<MyStringHash>(); m_loadPhase = true; m_findValidForestPhase = false; MyEntities.OnEntityAdd += MyEntities_OnEntityAdd; MyEntities.OnEntityRemove += MyEntities_OnEntityRemove; Static = this; }
static void GetEntitiesFromPrunningStructure(MyDynamicAABBTreeD tree, ref BoundingBoxD boundingBox, List<MyElement> list) { tree.OverlapAllBoundingBox(ref boundingBox, list, 0, false); }
public static MyRenderObject GetAnyIntersectionWithLine(MyDynamicAABBTreeD tree, ref VRageMath.LineD line, MyRenderObject ignoreObject0, MyRenderObject ignoreObject, List<MyLineSegmentOverlapResult<MyElement>> elementList) { tree.OverlapAllLineSegment(ref line, elementList); foreach (MyLineSegmentOverlapResult<MyElement> element in elementList) { MyRenderObject renderObject = ((MyRenderObject)element.Element); Debug.Assert(!renderObject.NearFlag); //Debug.Assert(renderObject.Visible); // Objects to ignore if ((renderObject == ignoreObject0) || (renderObject == ignoreObject)) continue; //Vector3? testResultEx; if (renderObject.GetIntersectionWithLine(ref line)) { return renderObject; } /* if (testResultEx != null) { Vector3 dir = line.Direction; if (Vector3.Dot((testResultEx.Value - line.From), dir) > 0) { if (ret == null) { ret = testResultEx; currentObject = renderObject; } if ((testResultEx.Value - line.From).Length() < (ret.Value - line.From).Length()) { ret = testResultEx; currentObject = renderObject; } } } */ } return null; }
protected override void DispatchCullQuery(MyCullQuery frustumCullQueries, MyDynamicAABBTreeD renderables) { throw new NotImplementedException(); }
internal void Init(MyCpuFrustumCullPass pass, MyDynamicAABBTreeD renderables, List <MyInstanceComponent> out_visibleInstances) { m_cpuFrustumCullPass = pass; m_renderables = renderables; m_visibleInstances = out_visibleInstances; }
internal void Cleanup() { m_cpuFrustumCullPass = null; m_renderables = null; }
public MyHierarchicalCulledEntitiesManager() { AabbTree = new MyDynamicAABBTreeD(MyRender11Constants.PRUNNING_EXTENSION); }
private void PrepareSectors() { ComputeSectorParameters(); m_planetEnvironmentSectors = new Dictionary<MyPlanetSectorId, MyPlanetEnvironmentSector>(); m_sectorsToRemove = new List<MyPlanetSectorId>((int)(Math.Ceiling(SECTOR_LOD1_EXTENT) * Math.Ceiling(SECTOR_LOD1_EXTENT) * 2)); SECTOR_LOD0_EXTENT = BASE_SECTOR_LOD0_EXTENT;// *m_numSectors / 7f; SECTOR_LOD1_EXTENT = MathHelper.Lerp(BASE_SECTOR_LOD1_EXTENT, MAX_SECTOR_LOD1_EXTENT, (Provider.Radius - 9500) / (60000 - 9500)); ComputeSectorRanges(); m_sectors = new MyDynamicAABBTreeD(Vector3D.Zero); Hierarchy.QueryAABBImpl = Hierarchy_QueryAABB; Hierarchy.QueryLineImpl = Hierarchy_QueryLine; Hierarchy.QuerySphereImpl = Hierarchy_QuerySphere; InitCounters(); }
public void Init(Vector3D v, MyDynamicAABBTreeD tree) { _vec = v; _tree = tree; Reset(); }
internal static int UpdateBvh(MyDynamicAABBTreeD bvh, LightId lid, bool enabled, int proxy, ref BoundingBoxD aabb) { if(enabled && proxy == -1) { return bvh.AddProxy(ref aabb, lid, 0); } else if(enabled && proxy != -1) { bvh.MoveProxy(proxy, ref aabb, Vector3.Zero); return proxy; } else { bvh.RemoveProxy(proxy); } return -1; }
/* * private MyDynamicAABBTreeD GetPrunningStructure() { * return m_aabbTree; * } */ private void Init() { MathTree = new MyDynamicAABBTreeD(AABB_EXTENSION); TreeId = LastAssignedTreeId + 1; LastAssignedTreeId = TreeId; }