예제 #1
0
        internal override void OnRemove(MyActor owner)
        {
            if (m_children != null)
            {
                for (int i = 0; i < m_children.Count; i++)
                {
                    m_children[i].RemoveComponent(m_children[i].GetGroupLeaf());
                }
                m_children = null;
            }

            foreach (var val in m_materialGroups.Values)
            {
                val.Release();
            }
            m_materialGroups.Clear();

            m_dirtyTree = true;

            if (m_proxy != null)
            {
                MyCullProxy_2.Free(m_proxy);
                m_proxy = null;
            }

            if (m_btreeProxy != -1)
            {
                MyScene.GroupsDBVH.RemoveProxy(m_btreeProxy);
                m_btreeProxy = -1;
            }

            base.OnRemove(owner);

            this.Deallocate();
        }
예제 #2
0
        internal static MyCullProxy_2 Allocate()
        {
            MyCullProxy_2 cullProxy2 = null;

            Pool.AllocateOrCreate(out cullProxy2);
            cullProxy2.Construct();
            return(cullProxy2);
        }
예제 #3
0
        internal override void Construct()
        {
            base.Construct();
            Type = MyActorComponentEnum.GroupRoot;

            m_children       = null;
            m_dirtyPosition  = false;
            m_dirtyTree      = false;
            m_btreeProxy     = -1;
            m_dirtyProxy     = false;
            m_materialGroups = new Dictionary <int, MyMaterialMergeGroup>();

            m_proxy = MyCullProxy_2.Allocate();
        }
예제 #4
0
        private static void RecordMeshPartCommands(MeshId model, MyActor actor, MyGroupRootComponent group,
                                                   MyCullProxy_2 proxy, MyOutlineDesc desc, ref float maxThickness)
        {
            MeshSectionId sectionId;
            bool          found = MyMeshes.TryGetMeshSection(model, 0, desc.SectionIndex, out sectionId);

            if (!found)
            {
                return;
            }

            OutlineConstantsLayout constants = new OutlineConstantsLayout();

            maxThickness    = Math.Max(desc.Thickness, maxThickness);
            constants.Color = desc.Color.ToVector4();
            if (desc.PulseTimeInFrames > 0)
            {
                constants.Color.W *= (float)Math.Pow((float)Math.Cos(2.0 * Math.PI * (float)MyRender11.Settings.GameplayFrame / (float)desc.PulseTimeInFrames), 2.0);
            }

            MyMeshSectionInfo1 section = sectionId.Info;

            MyMeshSectionPartInfo1[] meshes = section.Meshes;
            for (int idx = 0; idx < meshes.Length; idx++)
            {
                MyMaterialMergeGroup materialGroup;
                found = group.TryGetMaterialGroup(meshes[idx].Material, out materialGroup);
                if (!found)
                {
                    DebugRecordMeshPartCommands(model, desc.SectionIndex, meshes[idx].Material);
                    return;
                }

                int actorIndex;
                found = materialGroup.TryGetActorIndex(actor, out actorIndex);
                if (!found)
                {
                    return;
                }

                var mapping = MyMapping.MapDiscard(MyCommon.OutlineConstants);
                mapping.WriteAndPosition(ref constants);
                mapping.Unmap();

                MyOutlinePass.Instance.RecordCommands(ref proxy.Proxies[materialGroup.Index], actorIndex, meshes[idx].PartIndex);
            }
        }
예제 #5
0
        static void RecordMeshPartCommands(MeshId model, MyActor actor, MyGroupRootComponent group,
                                           MyCullProxy_2 proxy, MyHighlightDesc desc)
        {
            MeshSectionId sectionId;
            bool          found = MyMeshes.TryGetMeshSection(model, 0, desc.SectionName, out sectionId);

            if (!found)
            {
                return;
            }

            WriteHighlightConstants(ref desc);

            MyMeshSectionInfo1 section = sectionId.Info;

            MyMeshSectionPartInfo1[] meshes = section.Meshes;
            for (int idx = 0; idx < meshes.Length; idx++)
            {
                MyMaterialMergeGroup materialGroup;
                found = group.TryGetMaterialGroup(meshes[idx].Material, out materialGroup);
                if (!found)
                {
                    DebugRecordMeshPartCommands(model, desc.SectionName, meshes[idx].Material);
                    return;
                }

                int actorIndex;
                found = materialGroup.TryGetActorIndex(actor, out actorIndex);
                if (!found)
                {
                    return;
                }

                MyHighlightPass.Instance.RecordCommands(ref proxy.Proxies[materialGroup.Index], actorIndex, meshes[idx].PartIndex);
            }
        }
예제 #6
0
 internal static void Free(MyCullProxy_2 o)
 {
     Pool.Deallocate(o);
 }
예제 #7
0
        private static void RecordMeshPartCommands(MeshId model, MyActor actor, MyGroupRootComponent group,
            MyCullProxy_2 proxy, MyHighlightDesc desc, ref float maxThickness)
        {
            MeshSectionId sectionId;
            bool found = MyMeshes.TryGetMeshSection(model, 0, desc.SectionIndex, out sectionId);
            if (!found)
                return;

            WriteHighlightConstants(ref desc, ref maxThickness);

            MyMeshSectionInfo1 section = sectionId.Info;
            MyMeshSectionPartInfo1[] meshes = section.Meshes;
            for (int idx = 0; idx < meshes.Length; idx++)
            {
                MyMaterialMergeGroup materialGroup;
                found = group.TryGetMaterialGroup(meshes[idx].Material, out materialGroup);
                if (!found)
                {
                    DebugRecordMeshPartCommands(model, desc.SectionIndex, meshes[idx].Material);
                    return;
                }

                int actorIndex;
                found = materialGroup.TryGetActorIndex(actor, out actorIndex);
                if (!found)
                    return;

                MyHighlightPass.Instance.RecordCommands(ref proxy.Proxies[materialGroup.Index], actorIndex, meshes[idx].PartIndex);
            }
        }
예제 #8
0
        private static void RecordMeshPartCommands(MeshId model, MyActor actor, MyGroupRootComponent group,
            MyCullProxy_2 proxy, MyOutlineDesc desc, ref float maxThickness)
        {
            MeshSectionId sectionId;
            bool found = MyMeshes.TryGetMeshSection(model, 0, desc.SectionIndex, out sectionId);
            if (!found)
                return;

            OutlineConstantsLayout constants = new OutlineConstantsLayout();
            maxThickness = Math.Max(desc.Thickness, maxThickness);
            constants.Color = desc.Color.ToVector4();
            if (desc.PulseTimeInFrames > 0)
                constants.Color.W *= (float)Math.Pow((float)Math.Cos(2.0 * Math.PI * (float)MyRender11.GameplayFrameCounter / (float)desc.PulseTimeInFrames), 2.0);

            MyMeshSectionInfo1 section = sectionId.Info;
            MyMeshSectionPartInfo1[] meshes = section.Meshes;
            for (int idx = 0; idx < meshes.Length; idx++)
            {
                MyMaterialMergeGroup materialGroup;
                found = group.TryGetMaterialGroup(meshes[idx].Material, out materialGroup);
                if (!found)
                {
                    DebugRecordMeshPartCommands(model, desc.SectionIndex, meshes[idx].Material);
                    return;
                }

                int actorIndex;
                found = materialGroup.TryGetActorIndex(actor, out actorIndex);
                if (!found)
                    return;

                var mapping = MyMapping.MapDiscard(MyCommon.OutlineConstants);
                mapping.WriteAndPosition(ref constants);
                mapping.Unmap();

                MyOutlinePass.Instance.RecordCommands(ref proxy.Proxies[materialGroup.Index], actorIndex, meshes[idx].PartIndex);
            }
        }
예제 #9
0
        internal override void OnRemove(MyActor owner)
        {
            if (m_children != null)
            {
                for (int i = 0; i < m_children.Count; i++)
                {
                    m_children[i].RemoveComponent(m_children[i].GetGroupLeaf());
                }
                m_children = null;
            }

            foreach (var val in m_materialGroups.Values)
            {
                val.Release();
            }
            m_materialGroups.Clear();

            m_dirtyTree = true;

            if (m_proxy != null)
            {
                MyCullProxy_2.Free(m_proxy);
                m_proxy = null;
            }

            if(m_btreeProxy != -1)
            {
                MyScene.GroupsDBVH.RemoveProxy(m_btreeProxy);
                m_btreeProxy = -1;
            }

            base.OnRemove(owner);

            this.Deallocate();
        }
예제 #10
0
        internal override void Construct()
        {
            base.Construct();
            Type = MyActorComponentEnum.GroupRoot;

            m_children = new List<MyActor>();
            m_dirtyPosition = false;
            m_dirtyTree = false;
            m_btreeProxy = -1;
            m_dirtyProxy = false;
            m_materialGroups = new Dictionary<int, MyMaterialMergeGroup>();
            m_mergablesCounter = 0;
            m_isMerged = false;

            m_proxy = MyCullProxy_2.Allocate();
        }
예제 #11
0
 internal static void Free(MyCullProxy_2 o)
 {
     Pool.Deallocate(o);
 }
예제 #12
0
 internal static void Free(MyCullProxy_2 cullProxy2)
 {
     cullProxy2.Clear();
     Pool.Deallocate(cullProxy2);
 }
예제 #13
0
 internal static void Free(MyCullProxy_2 cullProxy2)
 {
     cullProxy2.Clear();
     Pool.Deallocate(cullProxy2);
 }