當前位置: 首頁>>代碼示例>>C#>>正文


C# PlaygroundParticlesC.RefreshMaskSorting方法代碼示例

本文整理匯總了C#中ParticlePlayground.PlaygroundParticlesC.RefreshMaskSorting方法的典型用法代碼示例。如果您正苦於以下問題:C# PlaygroundParticlesC.RefreshMaskSorting方法的具體用法?C# PlaygroundParticlesC.RefreshMaskSorting怎麽用?C# PlaygroundParticlesC.RefreshMaskSorting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ParticlePlayground.PlaygroundParticlesC的用法示例。


在下文中一共展示了PlaygroundParticlesC.RefreshMaskSorting方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ThreadedCalculations

        public static void ThreadedCalculations(PlaygroundParticlesC playgroundParticles)
        {
            // Refresh delta time
            if (!playgroundParticles.isPrewarming) {
                playgroundParticles.localDeltaTime = (PlaygroundC.globalTime-playgroundParticles.lastTimeUpdated)*playgroundParticles.particleTimescale;
                playgroundParticles.localTime += playgroundParticles.localDeltaTime;
                playgroundParticles.lastTimeUpdated = PlaygroundC.globalTime;
            }

            // Set delta time
            playgroundParticles.t = playgroundParticles.localDeltaTime;

            if (playgroundParticles.particleCount<=0 ||
                playgroundParticles.playgroundCache.color.Length!=playgroundParticles.particleCount ||
                playgroundParticles.playgroundCache.targetPosition.Length!=playgroundParticles.particleCount ||
                playgroundParticles.playgroundCache.targetDirection.Length!=playgroundParticles.particleCount ||
                playgroundParticles.source==SOURCEC.State && playgroundParticles.states[playgroundParticles.activeState].IsInitializing() ||
                playgroundParticles.isYieldRefreshing || !PlaygroundC.IsReady() || playgroundParticles.isSettingParticleTime) {
                playgroundParticles.isDoneThread = true;
                playgroundParticles.threadHadNoActiveParticles = false;
                return;
            }
            if (PlaygroundC.reference.calculate && playgroundParticles.calculate && !playgroundParticles.inTransition && playgroundParticles.hasActiveParticles) {}
            else if (playgroundParticles.source!=SOURCEC.Script) {
                playgroundParticles.isDoneThread = true;
                playgroundParticles.cameFromNonCalculatedFrame = true;
                return;
            } else {
                playgroundParticles.isDoneThread = true;
                return;
            }

            // Check that simplex turbulence is available (will be next frame in case not)
            if (!playgroundParticles.onlySourcePositioning && !playgroundParticles.onlyLifetimePositioning && playgroundParticles.turbulenceStrength>0 && playgroundParticles.turbulenceType!=TURBULENCETYPE.None) {
                if (playgroundParticles.turbulenceType==TURBULENCETYPE.Simplex && playgroundParticles.turbulenceSimplex==null) {
                    playgroundParticles.isDoneThread = true;
                    playgroundParticles.threadHadNoActiveParticles = false;
                    return;
                }
            }

            float t = playgroundParticles.t;

            // Prepare variables for particle source positions
            Matrix4x4 fMx = new Matrix4x4();
            if (playgroundParticles.source==SOURCEC.State || playgroundParticles.source==SOURCEC.WorldObject || playgroundParticles.source==SOURCEC.SkinnedWorldObject) {
                fMx.SetTRS(Vector3.zero, playgroundParticles.stRot, new Vector3(1f,1f,1f));
            }

            bool noActiveParticles = true;
            if (playgroundParticles.source==SOURCEC.Transform)
                for (int i = 0; i<playgroundParticles.sourceTransforms.Count; i++)
                    playgroundParticles.sourceTransforms[i].UpdateMatrix();

            // Update skinned mesh vertices
            if (playgroundParticles.source==SOURCEC.SkinnedWorldObject && playgroundParticles.skinnedWorldObjectReady && !playgroundParticles.forceSkinnedMeshUpdateOnMainThread && PlaygroundC.reference.skinnedMeshThreadMethod==ThreadMethodComponent.InsideParticleCalculation) {
                playgroundParticles.skinnedWorldObject.Update();
            }

            // Misc
            int pCount = playgroundParticles.particleCache.Length;

            // Check that cache is correct
            if (playgroundParticles.playgroundCache.lifetimeSubtraction.Length!=pCount)
                SetLifetimeSubtraction(playgroundParticles);
            if (playgroundParticles.playgroundCache.maskAlpha.Length!=pCount) {
                playgroundParticles.playgroundCache.maskAlpha = new float[pCount];
                playgroundParticles.playgroundCache.isMasked = new bool[pCount];
            }
            if (playgroundParticles.playgroundCache.manipulatorId.Length!=pCount)
                playgroundParticles.playgroundCache.manipulatorId = new int[pCount];
            if (playgroundParticles.playgroundCache.excludeFromManipulatorId.Length!=pCount)
                playgroundParticles.playgroundCache.excludeFromManipulatorId = new int[pCount];
            if (playgroundParticles.playgroundCache.noForce.Length!=pCount)
                playgroundParticles.playgroundCache.noForce = new bool[pCount];
            if (playgroundParticles.playgroundCache.isNonBirthed.Length!=pCount)
                playgroundParticles.playgroundCache.isNonBirthed = new bool[pCount];
            if (playgroundParticles.playgroundCache.isFirstLoop.Length!=pCount)
                playgroundParticles.playgroundCache.isFirstLoop = new bool[pCount];
            if (playgroundParticles.playgroundCache.isCalculatedThisFrame.Length!=pCount)
                playgroundParticles.playgroundCache.isCalculatedThisFrame = new bool[pCount];
            if (playgroundParticles.playgroundCache.simulate.Length!=pCount) {
                playgroundParticles.playgroundCache.simulate = new bool[pCount];
                for (int p = 0; p<pCount; p++)
                    playgroundParticles.playgroundCache.simulate[p] = true;
            }
            if (playgroundParticles.applyParticleMask && (playgroundParticles.playgroundCache.maskSorting==null || playgroundParticles.playgroundCache.maskSorting.Length!=pCount || playgroundParticles.particleMaskSorting!=playgroundParticles.previousMaskSorting))
                playgroundParticles.RefreshMaskSorting();

            Vector3 zero = Vector3.zero;
            Vector3 up = Vector3.up;
            float initYpos = PlaygroundC.initialTargetPosition.y;

            // Calculation loop
            for (int p = 0; p<playgroundParticles.particleCount; p++) {

                // Check that particle count is correct
                if (pCount != playgroundParticles.particleCache.Length || playgroundParticles.isYieldRefreshing || playgroundParticles.isSettingParticleTime || playgroundParticles.isSettingParticleCount) {
                    playgroundParticles.cameFromNonEmissionFrame = false;
                    playgroundParticles.isDoneThread = true;
//.........這裏部分代碼省略.........
開發者ID:PawkaHub,項目名稱:Lore-Unity,代碼行數:101,代碼來源:PlaygroundParticlesC.cs


注:本文中的ParticlePlayground.PlaygroundParticlesC.RefreshMaskSorting方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。