Пример #1
0
        internal void AddEntity(uint ID, MeshId model)
        {
            var instanceIndex = m_perInstance.Allocate();

            m_entities[ID] = new MyInstanceInfo {
                InstanceIndex = instanceIndex, PageHandles = new List <MyPackedPoolHandle>()
            };

            foreach (var id in m_meshTable.Pages(MyMeshTableSRV.MakeKey(model)))
            {
                var pageHandle = m_instancingTable.Allocate();

                m_instancingTable.Data[m_instancingTable.AsIndex(pageHandle)] = new MyInstancingTableEntry {
                    InstanceId = instanceIndex, InnerMeshId = id
                };
                m_entities[ID].PageHandles.Add(pageHandle);
            }

            m_perInstance.Data[instanceIndex] = MyPerInstanceData.FromWorldMatrix(ref MatrixD.Zero);

            m_tablesDirty = true;
        }
        internal void AddEntity(MyActor actor, MeshId model)
        {
            uint ID            = actor.ID;
            var  instanceIndex = m_perInstance.Allocate();
            var  entityIndex   = m_entityInfos.Allocate();

            Debug.Assert(instanceIndex == entityIndex);

            m_entities[ID] = new MyInstanceInfo {
                InstanceIndex = instanceIndex, PageHandles = new List <MyPackedPoolHandle>()
            };

            int pageOffset = -1;

            foreach (var id in m_meshTable.Pages(MyMeshTableSRV.MakeKey(model)))
            {
                if (pageOffset == -1)
                {
                    pageOffset = id;
                }

                var pageHandle = m_instancingTable.Allocate();

                m_instancingTable.Data[m_instancingTable.AsIndex(pageHandle)] = new MyInstancingTableEntry {
                    InstanceId = instanceIndex, InnerMeshId = id
                };

                m_entities[ID].PageHandles.Add(pageHandle);
            }

            m_perInstance.Data[instanceIndex] = MyPerInstanceData.FromWorldMatrix(ref MatrixD.Zero, 0);
            m_entityInfos.Data[instanceIndex] = new MyInstanceEntityInfo {
                EntityId = ID, PageOffset = pageOffset
            };

            m_tableDirty = true;
        }