Пример #1
0
    void OptimitzedBaatchesRendering(QuadTreeNode parent)
    {
        if (!parent.bOpmitizedRendering)
        {
            Effect.SceneFadeInOutMaterialFloat m_FadeFloat = null;

            parent.bOpmitizedRendering = true;

            int length = parent.m_LeavesList.Count;
            for (int j = 0; j < length; j++)
            {
                QuadTreeLeaves leaf = parent.m_LeavesList[j];
                leaf.m_ResInfo.OptimitzedMemory();
                leaf.m_ResInfo.OptimitzedRendering(parent.FadeMaterialList);
            }



            if (Batches_TreeNodeFadeTable.TryGetValue(parent, out m_FadeFloat))
            {
                m_FadeFloat.SetMaterialInstance(parent.FadeMaterialList);
                m_FadeFloat.enabled = true;

                parent.isDistanceFadingOut = true;

                if (!parent.isDistanceFadingIn)
                {
                    m_FadeFloat.FadeOutFrom     = 0.0f;
                    m_FadeFloat.FadeOutTo       = 1.0f;
                    m_FadeFloat.FadeOutDuartion = FadeTime;
                    m_FadeFloat.Play();
                }
                else
                {
                    m_FadeFloat.FadeOutDuartion = m_FadeFloat.FadeTimer;
                    m_FadeFloat.FadeOutFrom     = m_FadeFloat.currentFloat;
                    m_FadeFloat.FadeOutTo       = 1;
                    m_FadeFloat.FadeTimer       = 0;
                    m_FadeFloat.Update();
                    m_FadeFloat.ReStartFadeOutFinish_Constant();
                }

                parent.isDistanceFadingIn = false;
            }
        }
    }
    void FadeInFromOcclusCulling(SceneResInfo res, bool testLog = false)
    {
        if (!GoablEnabledOcclusCulling)
        {
            return;
        }

        if (!res || res.hostTreeNode == null)
        {
            return;
        }
        QuadTreeNode parent = res.hostTreeNode;

        if (!parent.bOpmitizedRendering)
        {
            if (!res.CheckSupportFading())
            {
                return;
            }

            Material[] matList = GetFadingMaterial(res);
            if (null == matList)
            {
                return;
            }
            res.UpdateOcclusFadeIn(matList);
            if (!parent.isDistanceFadingIn)
            {
                if (!res.occlusFadingOut)
                {
                    if (!res.occlusFadingIn)
                    {
                        res.occlusFadingIn  = true;
                        res.occlusFadingOut = false;

                        Effect.SceneFadeInOutMaterialFloat occlusFade = GetFadeInstance(res);
                        occlusFade.SetMaterialInstance(matList);
                        occlusFade.FadeOutDuartion = FadeTime;
                        occlusFade.FadeOutFrom     = 1;
                        occlusFade.FadeOutTo       = 0;
                        occlusFade.enabled         = true;
                        occlusFade.Play();
                    }
                }
                else
                {
                    res.occlusFadingIn  = true;
                    res.occlusFadingOut = false;

                    Effect.SceneFadeInOutMaterialFloat occlusFade = res.occlusFadInstance;
                    occlusFade.SetMaterialInstance(matList);
                    occlusFade.FadeOutDuartion = occlusFade.FadeTimer;
                    occlusFade.FadeOutFrom     = occlusFade.currentFloat;
                    occlusFade.FadeOutTo       = 0;
                    occlusFade.FadeTimer       = 0;



                    occlusFade.Update();

                    if (occlusFade)
                    {
                        occlusFade.ReStartFadeOutFinish_Constant();
                    }
                }
            }
            else
            {
                res.occlusFadingIn        = true;
                res.occlusFadingOut       = false;
                parent.isDistanceFadingIn = false;

                Effect.SceneFadeInOutMaterialFloat distanceFade = Batches_TreeNodeFadeTable[parent];
                Effect.SceneFadeInOutMaterialFloat occlusFade   = GetFadeInstance(res);
                occlusFade.enabled = true;


                occlusFade.SetMaterialInstance(matList);
                occlusFade.FadeOutDuartion = distanceFade.FadeTimer;
                occlusFade.FadeOutFrom     = distanceFade.currentFloat;
                occlusFade.FadeOutTo       = 0;
                occlusFade.FadeTimer       = 0;
                occlusFade.Update();

                if (occlusFade)
                {
                    occlusFade.Play();
                }


                distanceFade.enabled = false;
                distanceFade.Stop();
            }
        }
    }