internal Node(PortalRenderer renderer, Portal portal, Matrix4x4 viewPose, int currentDepth = 1) { this.renderer = renderer; this.portal = portal; this.depth = currentDepth; Matrix4x4 newViewPose = portal.Destination.OutTransform.localToWorldMatrix * portal.transform.worldToLocalMatrix * viewPose; this.viewPose = newViewPose; if (currentDepth > this.renderer.MaxRecursionDepth) { return; } foreach (Portal p in PortalManager.Instance.Portals) { if (p == portal.Destination) { continue; } this.renderer.PortalCamera.transform.SetPositionAndRotation(newViewPose.GetColumn(3), newViewPose.rotation); if (p.IsVisibleWithin(this.renderer.PortalCamera, this.portal.Destination)) { this.dependencies.Add(new Node(this.renderer, p, newViewPose, currentDepth + 1)); } } }
internal VisibilityTree(PortalRenderer renderer) { this.renderer = renderer; foreach (Portal p in PortalManager.Instance.Portals) { if (p.IsVisibleFrom(this.renderer.BaseCamera)) { this.dependencies.Add(new Node(this.renderer, p, renderer.BaseCamera.transform.localToWorldMatrix)); } } }