public PlaneClipMask IntersectPlanes(Plane[] planes, PlaneClipMask mask) { if (mask.Intersection != IntersectionType.INTERSECTING) { return(mask); } for (var i = 0; i < planes.Length; ++i) { if (mask.Intersecting(i)) { IntersectionType value = this.IntersectPlane(planes[i]); mask.Set(i, value); if (value == IntersectionType.OUTSIDE) { break; } } } return(mask); }
public PlaneClipMask IntersectPlanes(Plane[] planes) { return(IntersectPlanes(planes, PlaneClipMask.GetDefaultMask())); }
public void Traverse(int frameCount, List <CamState> camStates) { if (camStates.Count == 0) { return; } this.FrameNumberOfLastTraversal = frameCount; // TODO: optimize run speed // cull by bounding sphere bool isInSide = false; float screenDiameter = 0; float minDistance = float.MaxValue; foreach (CamState camState in camStates) { PlaneClipMask mask = this.BoundingSphere.IntersectPlanes(camState.planes, PlaneClipMask.GetDefaultMask()); if (mask.Intersection != IntersectionType.OUTSIDE) { isInSide = true; screenDiameter = Mathf.Max(screenDiameter, this.BoundingSphere.ScreenDiameter(camState.pixelSizeVector)); float distance = this.BoundingSphere.DistanceTo(camState.position); minDistance = Mathf.Min(distance, minDistance); // We take the min in case multiple cameras, reset dist to max float on frame reset } } if (isInSide == false) { this.EnableRenderer(false); MarkStagingChildren(); return; } // traverse based on screenDiameter if (screenDiameter < MaxScreenDiameter || this.ChildrenFiles.Count == 0) { this.EnableRenderer(true); MarkStagingChildren(); } else { // commited if (this.childrenStatus == ChildrenStatus.Commited) { this.EnableRenderer(false); this.unity3mxComponent.LRUCache.MarkUsed(this); foreach (PagedLOD pagedLOD in this.CommitedChildren) { pagedLOD.Traverse(Time.frameCount, camStates); } } else if (this.childrenStatus == ChildrenStatus.Staged) { this.EnableRenderer(true); this.unity3mxComponent.LRUCache.MarkUsed(this); } else { this.EnableRenderer(true); if (this.childrenStatus == ChildrenStatus.Unstaged) { if (!RequestManager.Current.Full()) { this.childrenStatus = ChildrenStatus.Staging; Promise <bool> finished = new Promise <bool>(); finished.Then((success) => { if (this.CommitedChildren.Count >= this.ChildrenFiles.Count) { this.childrenStatus = PagedLOD.ChildrenStatus.Staged; this.unity3mxComponent.LRUCache.Add(this); this.unity3mxComponent.CommitingQueue.Enqueue(this); } else { this.childrenStatus = ChildrenStatus.Unstaged; } }); Promise started = new Promise(); started.Then(() => { this.unity3mxComponent.StartCoroutine(this.StageChildrenCo(finished)); }); Request request = new Request(this, this.Priority(minDistance), started, finished); RequestManager.Current.EnqueRequest(request); } } } } }