Devious Journal Entry

3 min read

Deviation Actions

KillerBeer01's avatar
By
Published:
178 Views
This is a post for Inochi-PM:

The PMXView's Edit->Bone->Duplicate/Duplicate Child commands contain a bug. Depending on which command is selected, either the parent or a child link of a newly added bone is broken. I don't believe it's the intended functionality, and I think it can be fixed by editing PmxEditorLib.PmxEditor.CE.DuplicateBone:

        public static void DuplicateBone(PmxS pmx, int[] boneIx, bool parent = true)
        {
            if (boneIx.Length != 0)
            {
                pmx.EditWithRefIndex(delegate
                {
                    PmxBone[] array = new PmxBone[boneIx.Length];
                    PmxBone[] array2 = new PmxBone[boneIx.Length];
                    for (int i = 0; i < boneIx.Length; i++)
                    {
                        array[i] = pmx.BoneList[boneIx[i]];
                        array2[i] = array[i].Clone();
                        if (parent)
                        {
                            array2[i].Name += "-";
                            array2[i].RefParent = array[i].RefParent;
                            array[i].RefParent = array2[i];
                            array2[i].SetFlag(PmxBone.BoneFlags.ToBone, val: true);
                            array2[i].RefTo_Bone = array[i];
                        }
                        else
                        {
                            array2[i].Name += "+";
                            array2[i].RefParent = array[i];
                            if (array[i].GetFlag(PmxBone.BoneFlags.ToBone))
                            {
                                array2[i].RefTo_Bone = array[i].RefTo_Bone;
                                array[i].RefTo_Bone = array2[i];
                            }
                        }
                    }
Actually, the main PmxEditor window's Add->Add Duplicate command (from context menu of the bone list) is broken as well, as the duplicate bone links the wrong destination bone. I *think* it can be fixed by editing PmxEditorCore.PmxEditor.PmxForm.SetCMenuEvent_Bone:

        private void SetCMenuEvent_Bone()
        {
            ...
            CMenuItem_BoneAddCopy.Click += delegate
            {
                try
                {
                    int selectedIndex3 = lstBone.SelectedIndex;
                    if (selectedIndex3 >= 0)
                    {
                        InsertBone(new PmxBone { Name="temp name" }, selectedIndex3 + 1);
                        m_pmx.BoneList[selectedIndex3+1]=m_pmx.BoneList[selectedIndex3].Clone();
                    }

Unfortunately, right now I can't check any of these fixes, as dnSpy suddenly stopped obeying to me. Any changes I do to PmxEditorCore makes the PMXE fail to load. If I launch the edited version through dnSpy's debugger, the log window states that I'm "overriding a method that's already been overridden". First time it happened, I repeated same changes I made before minus one of functions that seemed suspicious to me, and could work further. This time, though, I restore all files to default, edit any random method, compile and save it without actually changing anything, and get an inoperable PMXE. Did something similar happen to you, and do you have any idea what might be the reason?

Thanks.
© 2018 - 2024 KillerBeer01
Comments0
Join the community to add your comment. Already a deviant? Log In