public override IEnumerable <VFXContext> InitImplicitContexts() { if (!NeedsGlobalSort() && !m_Owners.OfType <VFXAbstractParticleOutput>().Any(o => o.NeedsOutputUpdate())) { //Early out with the most common case m_Contexts = m_Owners; return(Enumerable.Empty <VFXContext>()); } m_Contexts = new List <VFXContext>(m_Owners.Count + 2); // Allocate max number int index = 0; // First add init and updates for (index = 0; index < m_Owners.Count; ++index) { if ((m_Owners[index].contextType == VFXContextType.Output)) { break; } m_Contexts.Add(m_Owners[index]); } var implicitContext = new List <VFXContext>(); if (NeedsGlobalSort()) { // Then the camera sort var cameraSort = VFXContext.CreateImplicitContext <VFXCameraSort>(this); implicitContext.Add(cameraSort); m_Contexts.Add(cameraSort); } //additional update for (int outputIndex = index; outputIndex < m_Owners.Count; ++outputIndex) { var currentOutputContext = m_Owners[outputIndex]; var abstractParticleOutput = currentOutputContext as VFXAbstractParticleOutput; if (abstractParticleOutput == null) { continue; } if (abstractParticleOutput.NeedsOutputUpdate()) { var update = VFXContext.CreateImplicitContext <VFXOutputUpdate>(this); update.SetOutput(abstractParticleOutput); implicitContext.Add(update); m_Contexts.Add(update); } } // And finally output for (; index < m_Owners.Count; ++index) { m_Contexts.Add(m_Owners[index]); } return(implicitContext); }
public override IEnumerable <VFXContext> InitImplicitContexts() { if (!NeedsSort()) { m_Contexts = m_Owners; return(Enumerable.Empty <VFXContext>()); } m_Contexts = new List <VFXContext>(m_Owners.Count + 1); int index = 0; // First add init and updates for (index = 0; index < m_Owners.Count; ++index) { if ((m_Owners[index].contextType == VFXContextType.Output)) { break; } m_Contexts.Add(m_Owners[index]); } // Then the camera sort var cameraSort = VFXContext.CreateImplicitContext <VFXCameraSort>(this); m_Contexts.Add(cameraSort); // And finally output for (; index < m_Owners.Count; ++index) { m_Contexts.Add(m_Owners[index]); } return(new VFXContext[] { cameraSort }); }
public override IEnumerable <VFXContext> InitImplicitContexts() { if (!NeedsSort() && !m_Owners.OfType <IVFXSubRenderer>().Any(o => o.hasMotionVector)) { //Early out with the most common case m_Contexts = m_Owners; return(Enumerable.Empty <VFXContext>()); } m_Contexts = new List <VFXContext>(m_Owners.Count + 1); int index = 0; // First add init and updates for (index = 0; index < m_Owners.Count; ++index) { if ((m_Owners[index].contextType == VFXContextType.Output)) { break; } m_Contexts.Add(m_Owners[index]); } var implicitContext = new List <VFXContext>(); if (NeedsSort()) { // Then the camera sort var cameraSort = VFXContext.CreateImplicitContext <VFXCameraSort>(this); implicitContext.Add(cameraSort); m_Contexts.Add(cameraSort); } //Motion vector jobs for (int outputIndex = index; outputIndex < m_Owners.Count; ++outputIndex) { var currentOutputContext = m_Owners[outputIndex]; var abstractParticleOutput = currentOutputContext as IVFXSubRenderer; if (abstractParticleOutput != null && abstractParticleOutput.hasMotionVector) { var motionVector = VFXContext.CreateImplicitContext <VFXMotionVector>(this); motionVector.SetEncapsulatedOutput(currentOutputContext); implicitContext.Add(motionVector); m_Contexts.Add(motionVector); } } // And finally output for (; index < m_Owners.Count; ++index) { m_Contexts.Add(m_Owners[index]); } return(implicitContext); }