示例#1
0
        public void SetMultiInstancesTransformStrategy(MyInstanceData[] multiInstanceData, int instanceStart, int instancesCount)
        {
            if (m_transformStrategy is MySingleTransformStrategy)
            {
                MySingleTransformStrategy oldStrategy = (MySingleTransformStrategy)m_transformStrategy;
                MyMultiTransformStrategy  newStrategy = MyObjectPoolManager.Allocate <MyMultiTransformStrategy>();
                newStrategy.SetCoreMatrix(m_transformStrategy.GetCoreMatrixD());
                MyObjectPoolManager.Deallocate(oldStrategy);
                m_transformStrategy = newStrategy;
            }

            MyRenderProxy.Assert(m_transformStrategy is MyMultiTransformStrategy);

            MyMultiTransformStrategy multiTranformStrategy = (MyMultiTransformStrategy)m_transformStrategy;

            multiTranformStrategy.SetInstanceData(multiInstanceData, instanceStart, instancesCount);
        }
示例#2
0
        void SetSingleInstanceTransformStrategy()
        {
            if (m_transformStrategy is MySingleTransformStrategy)
            {
                return;
            }

            ITransformStrategy oldStrategy = m_transformStrategy;

            m_transformStrategy = MyObjectPoolManager.Allocate <MySingleTransformStrategy>();
            m_transformStrategy.SetCoreMatrix(m_transformStrategy.GetCoreMatrixD());
            if (oldStrategy is MyMultiTransformStrategy)
            {
                MyObjectPoolManager.Deallocate((MyMultiTransformStrategy)oldStrategy);
            }
            else if (oldStrategy is MySingleTransformStrategy)
            {
                MyObjectPoolManager.Deallocate((MySingleTransformStrategy)oldStrategy);
            }
            else
            {
                MyRenderProxy.Error("Unknown class");
            }
        }